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