@@ -10,9 +10,10 @@ var tls = require('tls');
1010
1111var fs = require ( 'fs' ) ;
1212var 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' ;
1617var localhost = '127.0.0.1' ;
1718
1819process . on ( 'exit' , function ( ) {
@@ -24,7 +25,8 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) {
2425 secureProtocol : SSL_Method ,
2526 key : fs . readFileSync ( common . fixturesDir + '/keys/agent2-key.pem' ) ,
2627 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' ,
2830 honorCipherOrder : ! ! honorCipherOrder
2931 } ;
3032
@@ -57,37 +59,40 @@ test1();
5759
5860function test1 ( ) {
5961 // 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 ) ;
6164}
6265
6366function 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 ) ;
6771}
6872
6973function 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+
7378}
7479
7580function 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
7782 // of honorCipherOrder.
78- test ( true , 'RC4-SHA ' , 'RC4-SHA ' , test5 ) ;
83+ test ( true , 'AES128-SHA256 ' , 'AES128-SHA256 ' , test5 ) ;
7984}
8085
8186function 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 ) ;
8692}
8793
8894function test6 ( ) {
8995 // 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' ) ;
9398}
0 commit comments