File tree Expand file tree Collapse file tree 2 files changed +30
-17
lines changed
Expand file tree Collapse file tree 2 files changed +30
-17
lines changed Original file line number Diff line number Diff line change 3636}
3737
3838
39- function Credentials ( secureProtocol ) {
39+ function Credentials ( secureProtocol , context ) {
4040 if ( ! ( this instanceof Credentials ) ) {
4141 return new Credentials ( secureProtocol ) ;
4242 }
@@ -45,22 +45,28 @@ function Credentials(secureProtocol) {
4545 throw new Error ( 'node.js not compiled with openssl crypto support.' ) ;
4646 }
4747
48- this . context = new SecureContext ( ) ;
49-
50- if ( secureProtocol ) {
51- this . context . init ( secureProtocol ) ;
48+ if ( context ) {
49+ this . context = context ;
50+ this . reuseContext = true ;
5251 } else {
53- this . context . init ( ) ;
54- }
52+ this . context = new SecureContext ( ) ;
5553
54+ if ( secureProtocol ) {
55+ this . context . init ( secureProtocol ) ;
56+ } else {
57+ this . context . init ( ) ;
58+ }
59+ }
5660}
5761
5862exports . Credentials = Credentials ;
5963
6064
61- exports . createCredentials = function ( options ) {
65+ exports . createCredentials = function ( options , context ) {
6266 if ( ! options ) options = { } ;
63- var c = new Credentials ( options . secureProtocol ) ;
67+ var c = new Credentials ( options . secureProtocol , context ) ;
68+
69+ if ( context ) return c ;
6470
6571 if ( options . key ) c . context . setKey ( options . key ) ;
6672
Original file line number Diff line number Diff line change @@ -713,16 +713,23 @@ function Server(/* [options], listener */) {
713713
714714 var self = this ;
715715
716+ // Handle option defaults:
717+ this . setOptions ( options ) ;
718+
719+ var sharedCreds = crypto . createCredentials ( {
720+ key : self . key ,
721+ cert : self . cert ,
722+ ca : self . ca ,
723+ ciphers : self . ciphers ,
724+ secureProtocol : self . secureProtocol ,
725+ crl : self . crl
726+ } ) ;
727+
728+ sharedCreds . context . setCiphers ( 'RC4-SHA:AES128-SHA:AES256-SHA' ) ;
729+
716730 // constructor call
717731 net . Server . call ( this , function ( socket ) {
718- var creds = crypto . createCredentials ( {
719- key : self . key ,
720- cert : self . cert ,
721- ca : self . ca ,
722- secureProtocol : self . secureProtocol ,
723- crl : self . crl
724- } ) ;
725- creds . context . setCiphers ( 'RC4-SHA:AES128-SHA:AES256-SHA' ) ;
732+ var creds = crypto . createCredentials ( null , sharedCreds . context ) ;
726733
727734 var pair = new SecurePair ( creds ,
728735 true ,
You can’t perform that action at this time.
0 commit comments