@@ -10,6 +10,7 @@ const {
1010const DEFAULT_MIN_VERSION = tls . DEFAULT_MIN_VERSION ;
1111
1212function test ( cmin , cmax , cprot , smin , smax , sprot , expect ) {
13+ assert ( expect ) ;
1314 connect ( {
1415 client : {
1516 checkServerIdentity : ( servername , cert ) => { } ,
@@ -26,23 +27,18 @@ function test(cmin, cmax, cprot, smin, smax, sprot, expect) {
2627 secureProtocol : sprot ,
2728 } ,
2829 } , 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 ) ;
3132 return cleanup ( ) ;
3233 }
3334
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 ) ;
4642 return cleanup ( ) ;
4743 } ) ) ;
4844}
@@ -83,17 +79,18 @@ test(U, U, 'TLS_method', U, U, 'TLSv1_method', 'TLSv1');
8379test ( U , U , 'TLSv1_2_method' , U , U , 'SSLv23_method' , 'TLSv1.2' ) ;
8480
8581if ( 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' ) ;
9087}
9188
9289if ( DEFAULT_MIN_VERSION === 'TLSv1.1' ) {
9390 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' ) ;
9592 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' ) ;
9794}
9895
9996if ( DEFAULT_MIN_VERSION === 'TLSv1' ) {
@@ -111,18 +108,18 @@ test(U, U, 'TLSv1_method', U, U, 'TLSv1_method', 'TLSv1');
111108
112109// The default default.
113110if ( 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' ) ;
118115}
119116
120117// The default with --tls-v1.1.
121118if ( DEFAULT_MIN_VERSION === 'TLSv1.1' ) {
122119 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' ) ;
124121 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' ) ;
126123}
127124
128125// The default with --tls-v1.0.
0 commit comments