@@ -51,21 +51,19 @@ server.listen(0, common.mustCall(function(){
5151tls . connect ( {
5252port : this . address ( ) . port ,
5353key : rawKey ,
54- passphrase : 'passphrase' , // Ignored.
54+ passphrase : 'ignored' ,
5555cert : cert ,
5656rejectUnauthorized : false
5757} , common . mustCall ( function ( ) { } ) ) ;
5858
5959// Buffer[]
60- /* XXX(sam) Should work, but its unimplemented ATM.
6160tls . connect ( {
6261port : this . address ( ) . port ,
6362key : [ passKey ] ,
6463passphrase : 'passphrase' ,
6564cert : [ cert ] ,
6665rejectUnauthorized : false
6766} , common . mustCall ( function ( ) { } ) ) ;
68- */
6967
7068tls . connect ( {
7169port : this . address ( ) . port ,
@@ -77,7 +75,7 @@ server.listen(0, common.mustCall(function(){
7775tls . connect ( {
7876port : this . address ( ) . port ,
7977key : [ rawKey ] ,
80- passphrase : 'passphrase' , // Ignored.
78+ passphrase : 'ignored' ,
8179cert : [ cert ] ,
8280rejectUnauthorized : false
8381} , common . mustCall ( function ( ) { } ) ) ;
@@ -101,21 +99,19 @@ server.listen(0, common.mustCall(function(){
10199tls . connect ( {
102100port : this . address ( ) . port ,
103101key : rawKey . toString ( ) ,
104- passphrase : 'passphrase' , // Ignored.
102+ passphrase : 'ignored' ,
105103cert : cert . toString ( ) ,
106104rejectUnauthorized : false
107105} , common . mustCall ( function ( ) { } ) ) ;
108106
109107// String[]
110- /* XXX(sam) Should work, but its unimplemented ATM.
111108tls . connect ( {
112109port : this . address ( ) . port ,
113110key : [ passKey . toString ( ) ] ,
114111passphrase : 'passphrase' ,
115112cert : [ cert . toString ( ) ] ,
116113rejectUnauthorized : false
117114} , common . mustCall ( function ( ) { } ) ) ;
118- */
119115
120116tls . connect ( {
121117port : this . address ( ) . port ,
@@ -127,7 +123,7 @@ server.listen(0, common.mustCall(function(){
127123tls . connect ( {
128124port : this . address ( ) . port ,
129125key : [ rawKey . toString ( ) ] ,
130- passphrase : 'passphrase' , // Ignored.
126+ passphrase : 'ignored' ,
131127cert : [ cert . toString ( ) ] ,
132128rejectUnauthorized : false
133129} , common . mustCall ( function ( ) { } ) ) ;
@@ -140,6 +136,22 @@ server.listen(0, common.mustCall(function(){
140136rejectUnauthorized : false
141137} , common . mustCall ( function ( ) { } ) ) ;
142138
139+ tls . connect ( {
140+ port : this . address ( ) . port ,
141+ key : [ { pem : passKey , passphrase : 'passphrase' } ] ,
142+ passphrase : 'ignored' ,
143+ cert : cert ,
144+ rejectUnauthorized : false
145+ } , common . mustCall ( function ( ) { } ) ) ;
146+
147+ tls . connect ( {
148+ port : this . address ( ) . port ,
149+ key : [ { pem : passKey } ] ,
150+ passphrase : 'passphrase' ,
151+ cert : cert ,
152+ rejectUnauthorized : false
153+ } , common . mustCall ( function ( ) { } ) ) ;
154+
143155tls . connect ( {
144156port : this . address ( ) . port ,
145157key : [ { pem : passKey . toString ( ) , passphrase : 'passphrase' } ] ,
@@ -149,31 +161,30 @@ server.listen(0, common.mustCall(function(){
149161
150162tls . connect ( {
151163port : this . address ( ) . port ,
152- key : [ { pem : rawKey , passphrase : 'passphrase ' } ] ,
164+ key : [ { pem : rawKey , passphrase : 'ignored ' } ] ,
153165cert : cert ,
154166rejectUnauthorized : false
155167} , common . mustCall ( function ( ) { } ) ) ;
156168
157169tls . connect ( {
158170port : this . address ( ) . port ,
159- key : [ { pem : rawKey . toString ( ) , passphrase : 'passphrase ' } ] ,
171+ key : [ { pem : rawKey . toString ( ) , passphrase : 'ignored ' } ] ,
160172cert : cert ,
161173rejectUnauthorized : false
162174} , common . mustCall ( function ( ) { } ) ) ;
163175
164- /* XXX(sam) Should work, but unimplemented ATM
165176tls . connect ( {
166177port : this . address ( ) . port ,
167178key : [ { pem : rawKey } ] ,
168- passphrase: 'passphrase ',
179+ passphrase : 'ignored ' ,
169180cert : cert ,
170181rejectUnauthorized : false
171182} , common . mustCall ( function ( ) { } ) ) ;
172183
173184tls . connect ( {
174185port : this . address ( ) . port ,
175186key : [ { pem : rawKey . toString ( ) } ] ,
176- passphrase: 'passphrase ',
187+ passphrase : 'ignored ' ,
177188cert : cert ,
178189rejectUnauthorized : false
179190} , common . mustCall ( function ( ) { } ) ) ;
@@ -191,9 +202,37 @@ server.listen(0, common.mustCall(function(){
191202cert : cert ,
192203rejectUnauthorized : false
193204} , common . mustCall ( function ( ) { } ) ) ;
194- */
195205} ) ) . unref ( ) ;
196206
207+ // Missing passphrase
208+ assert . throws ( function ( ) {
209+ tls . connect ( {
210+ port : server . address ( ) . port ,
211+ key : passKey ,
212+ cert : cert ,
213+ rejectUnauthorized : false
214+ } ) ;
215+ } , / b a d p a s s w o r d r e a d / ) ;
216+
217+ assert . throws ( function ( ) {
218+ tls . connect ( {
219+ port : server . address ( ) . port ,
220+ key : [ passKey ] ,
221+ cert : cert ,
222+ rejectUnauthorized : false
223+ } ) ;
224+ } , / b a d p a s s w o r d r e a d / ) ;
225+
226+ assert . throws ( function ( ) {
227+ tls . connect ( {
228+ port : server . address ( ) . port ,
229+ key : [ { pem : passKey } ] ,
230+ cert : cert ,
231+ rejectUnauthorized : false
232+ } ) ;
233+ } , / b a d p a s s w o r d r e a d / ) ;
234+
235+ // Invalid passphrase
197236assert . throws ( function ( ) {
198237tls . connect ( {
199238port : server . address ( ) . port ,
@@ -203,3 +242,33 @@ assert.throws(function(){
203242rejectUnauthorized : false
204243} ) ;
205244} , / b a d d e c r y p t / ) ;
245+
246+ assert . throws ( function ( ) {
247+ tls . connect ( {
248+ port : server . address ( ) . port ,
249+ key : [ passKey ] ,
250+ passphrase : 'invalid' ,
251+ cert : cert ,
252+ rejectUnauthorized : false
253+ } ) ;
254+ } , / b a d d e c r y p t / ) ;
255+
256+ assert . throws ( function ( ) {
257+ tls . connect ( {
258+ port : server . address ( ) . port ,
259+ key : [ { pem : passKey } ] ,
260+ passphrase : 'invalid' ,
261+ cert : cert ,
262+ rejectUnauthorized : false
263+ } ) ;
264+ } , / b a d d e c r y p t / ) ;
265+
266+ assert . throws ( function ( ) {
267+ tls . connect ( {
268+ port : server . address ( ) . port ,
269+ key : [ { pem : passKey , passphrase : 'invalid' } ] ,
270+ passphrase : 'passphrase' , // Valid but unused
271+ cert : cert ,
272+ rejectUnauthorized : false
273+ } ) ;
274+ } , / b a d d e c r y p t / ) ;
0 commit comments