@@ -10,9 +10,10 @@ var tls = require('tls');
10
10
11
11
var fs = require ( 'fs' ) ;
12
12
var nconns = 0 ;
13
- // test only in TLSv1 to use DES which is no longer supported TLSv1.2
14
- // to be safe when the default method is updated in the future
15
- var SSL_Method = 'TLSv1_method' ;
13
+
14
+ // We explicitly set TLS version to 1.2 so as to be safe when the
15
+ // default method is updated in the future
16
+ var SSL_Method = 'TLSv1_2_method' ;
16
17
var localhost = '127.0.0.1' ;
17
18
18
19
process . on ( 'exit' , function ( ) {
@@ -24,7 +25,8 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) {
24
25
secureProtocol : SSL_Method ,
25
26
key : fs . readFileSync ( common . fixturesDir + '/keys/agent2-key.pem' ) ,
26
27
cert : fs . readFileSync ( common . fixturesDir + '/keys/agent2-cert.pem' ) ,
27
- ciphers : 'DES-CBC-SHA:AES256-SHA:RC4-SHA:ECDHE-RSA-AES256-SHA' ,
28
+ ciphers : 'AES256-SHA256:AES128-GCM-SHA256:AES128-SHA256:' +
29
+ 'ECDHE-RSA-AES128-GCM-SHA256' ,
28
30
honorCipherOrder : ! ! honorCipherOrder
29
31
} ;
30
32
@@ -57,37 +59,40 @@ test1();
57
59
58
60
function test1 ( ) {
59
61
// Client has the preference of cipher suites by default
60
- test ( false , 'AES256-SHA:DES-CBC-SHA:RC4-SHA' , 'AES256-SHA' , test2 ) ;
62
+ test ( false , 'AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256' ,
63
+ 'AES128-GCM-SHA256' , test2 ) ;
61
64
}
62
65
63
66
function test2 ( ) {
64
- // Server has the preference of cipher suites where DES-CBC-SHA is in
65
- // the first.
66
- test ( true , 'AES256-SHA:DES-CBC-SHA:RC4-SHA' , 'DES-CBC-SHA' , test3 ) ;
67
+ // Server has the preference of cipher suites, and AES256-SHA256 is
68
+ // the server's top choice.
69
+ test ( true , 'AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256' ,
70
+ 'AES256-SHA256' , test3 ) ;
67
71
}
68
72
69
73
function test3 ( ) {
70
- // Server has the preference of cipher suites. RC4-SHA is given
71
- // higher priority over DES-CBC-SHA among client cipher suites.
72
- test ( true , 'RC4-SHA:AES256-SHA' , 'AES256-SHA' , test4 ) ;
74
+ // Server has the preference of cipher suites. AES128-GCM-SHA256 is given
75
+ // higher priority over AES128-SHA256 among client cipher suites.
76
+ test ( true , 'AES128-SHA256:AES128-GCM-SHA256' , 'AES128-GCM-SHA256' , test4 ) ;
77
+
73
78
}
74
79
75
80
function test4 ( ) {
76
- // As client has only one cipher, server has no choice in regardless
81
+ // As client has only one cipher, server has no choice, irrespective
77
82
// of honorCipherOrder.
78
- test ( true , 'RC4-SHA ' , 'RC4-SHA ' , test5 ) ;
83
+ test ( true , 'AES128-SHA256 ' , 'AES128-SHA256 ' , test5 ) ;
79
84
}
80
85
81
86
function test5 ( ) {
82
- // Client did not explicitly set ciphers. Ensure that client defaults to
83
- // sane ciphers. Even though server gives top priority to DES-CBC-SHA
84
- // it should not be negotiated because it's not in default client ciphers.
85
- test ( true , null , 'AES256-SHA' , test6 ) ;
87
+ // Client did not explicitly set ciphers and client offers
88
+ // tls.DEFAULT_CIPHERS. All ciphers of the server are included in the
89
+ // default list so the negotiated cipher is selected according to the
90
+ // server's top preference of AES256-SHA256.
91
+ test ( true , null , 'AES256-SHA256' , test6 ) ;
86
92
}
87
93
88
94
function test6 ( ) {
89
95
// Ensure that `tls.DEFAULT_CIPHERS` is used
90
- SSL_Method = 'TLSv1_2_method' ;
91
- tls . DEFAULT_CIPHERS = 'ECDHE-RSA-AES256-SHA' ;
92
- test ( true , null , 'ECDHE-RSA-AES256-SHA' ) ;
96
+ tls . DEFAULT_CIPHERS = 'ECDHE-RSA-AES128-GCM-SHA256' ;
97
+ test ( true , null , 'ECDHE-RSA-AES128-GCM-SHA256' ) ;
93
98
}
0 commit comments