@@ -13,6 +13,7 @@ const DEFAULT_MIN_VERSION = tls.DEFAULT_MIN_VERSION;
13
13
assert . strictEqual ( DEFAULT_MIN_VERSION , 'TLSv1' ) ;
14
14
15
15
function test ( cmin , cmax , cprot , smin , smax , sprot , expect ) {
16
+ assert ( expect ) ;
16
17
connect ( {
17
18
client : {
18
19
checkServerIdentity : ( servername , cert ) => { } ,
@@ -29,23 +30,18 @@ function test(cmin, cmax, cprot, smin, smax, sprot, expect) {
29
30
secureProtocol : sprot ,
30
31
} ,
31
32
} , common . mustCall ( ( err , pair , cleanup ) => {
32
- if ( expect && ! expect . match ( / ^ T L S / ) ) {
33
- assert ( err . message . match ( expect ) ) ;
33
+ if ( err ) {
34
+ assert . strictEqual ( err . code , expect , err + '.code !== ' + expect ) ;
34
35
return cleanup ( ) ;
35
36
}
36
37
37
- if ( expect ) {
38
- assert . ifError ( pair . server . err ) ;
39
- assert . ifError ( pair . client . err ) ;
40
- assert ( pair . server . conn ) ;
41
- assert ( pair . client . conn ) ;
42
- assert . strictEqual ( pair . client . conn . getProtocol ( ) , expect ) ;
43
- assert . strictEqual ( pair . server . conn . getProtocol ( ) , expect ) ;
44
- return cleanup ( ) ;
45
- }
46
-
47
- assert ( pair . server . err ) ;
48
- assert ( pair . client . err ) ;
38
+ assert . ifError ( err ) ;
39
+ assert . ifError ( pair . server . err ) ;
40
+ assert . ifError ( pair . client . err ) ;
41
+ assert ( pair . server . conn ) ;
42
+ assert ( pair . client . conn ) ;
43
+ assert . strictEqual ( pair . client . conn . getProtocol ( ) , expect ) ;
44
+ assert . strictEqual ( pair . server . conn . getProtocol ( ) , expect ) ;
49
45
return cleanup ( ) ;
50
46
} ) ) ;
51
47
}
@@ -82,17 +78,18 @@ test(U, U, 'TLS_method', U, U, 'TLSv1_method', 'TLSv1');
82
78
test ( U , U , 'TLSv1_2_method' , U , U , 'SSLv23_method' , 'TLSv1.2' ) ;
83
79
84
80
if ( DEFAULT_MIN_VERSION === 'TLSv1.2' ) {
85
- test ( U , U , 'TLSv1_1_method' , U , U , 'SSLv23_method' , null ) ;
86
- test ( U , U , 'TLSv1_method' , U , U , 'SSLv23_method' , null ) ;
87
- test ( U , U , 'SSLv23_method' , U , U , 'TLSv1_1_method' , null ) ;
88
- test ( U , U , 'SSLv23_method' , U , U , 'TLSv1_method' , null ) ;
81
+ test ( U , U , 'TLSv1_1_method' , U , U , 'SSLv23_method' , 'ECONNRESET' ) ;
82
+ test ( U , U , 'TLSv1_method' , U , U , 'SSLv23_method' , 'ECONNRESET' ) ;
83
+ test ( U , U , 'SSLv23_method' , U , U , 'TLSv1_1_method' ,
84
+ 'ERR_SSL_VERSION_TOO_LOW' ) ;
85
+ test ( U , U , 'SSLv23_method' , U , U , 'TLSv1_method' , 'ERR_SSL_VERSION_TOO_LOW' ) ;
89
86
}
90
87
91
88
if ( DEFAULT_MIN_VERSION === 'TLSv1.1' ) {
92
89
test ( U , U , 'TLSv1_1_method' , U , U , 'SSLv23_method' , 'TLSv1.1' ) ;
93
- test ( U , U , 'TLSv1_method' , U , U , 'SSLv23_method' , null ) ;
90
+ test ( U , U , 'TLSv1_method' , U , U , 'SSLv23_method' , 'ECONNRESET' ) ;
94
91
test ( U , U , 'SSLv23_method' , U , U , 'TLSv1_1_method' , 'TLSv1.1' ) ;
95
- test ( U , U , 'SSLv23_method' , U , U , 'TLSv1_method' , null ) ;
92
+ test ( U , U , 'SSLv23_method' , U , U , 'TLSv1_method' , 'ERR_SSL_VERSION_TOO_LOW' ) ;
96
93
}
97
94
98
95
if ( DEFAULT_MIN_VERSION === 'TLSv1' ) {
@@ -110,18 +107,18 @@ test(U, U, 'TLSv1_method', U, U, 'TLSv1_method', 'TLSv1');
110
107
111
108
// The default default.
112
109
if ( DEFAULT_MIN_VERSION === 'TLSv1.2' ) {
113
- test ( U , U , 'TLSv1_1_method' , U , U , U , null ) ;
114
- test ( U , U , 'TLSv1_method' , U , U , U , null ) ;
115
- test ( U , U , U , U , U , 'TLSv1_1_method' , null ) ;
116
- test ( U , U , U , U , U , 'TLSv1_method' , null ) ;
110
+ test ( U , U , 'TLSv1_1_method' , U , U , U , 'ECONNRESET' ) ;
111
+ test ( U , U , 'TLSv1_method' , U , U , U , 'ECONNRESET' ) ;
112
+ test ( U , U , U , U , U , 'TLSv1_1_method' , 'ERR_SSL_VERSION_TOO_LOW' ) ;
113
+ test ( U , U , U , U , U , 'TLSv1_method' , 'ERR_SSL_VERSION_TOO_LOW' ) ;
117
114
}
118
115
119
116
// The default with --tls-v1.1.
120
117
if ( DEFAULT_MIN_VERSION === 'TLSv1.1' ) {
121
118
test ( U , U , 'TLSv1_1_method' , U , U , U , 'TLSv1.1' ) ;
122
- test ( U , U , 'TLSv1_method' , U , U , U , null ) ;
119
+ test ( U , U , 'TLSv1_method' , U , U , U , 'ECONNRESET' ) ;
123
120
test ( U , U , U , U , U , 'TLSv1_1_method' , 'TLSv1.1' ) ;
124
- test ( U , U , U , U , U , 'TLSv1_method' , null ) ;
121
+ test ( U , U , U , U , U , 'TLSv1_method' , 'ERR_SSL_VERSION_TOO_LOW' ) ;
125
122
}
126
123
127
124
// The default with --tls-v1.0.
0 commit comments