@@ -63,6 +63,26 @@ CryptoStream.prototype.end = function(err) {
6363} ;
6464
6565
66+ CryptoStream . prototype . getPeerCertificate = function ( ) {
67+ if ( this . pair . _ssl ) {
68+ return this . pair . _ssl . getPeerCertificate ( ) ;
69+ } else {
70+ return null ;
71+ }
72+ } ;
73+
74+
75+ CryptoStream . prototype . getCipher = function ( err ) {
76+ if ( this . pair . _ssl ) {
77+ return this . pair . _ssl . getCurrentCipher ( ) ;
78+ } else {
79+ return null ;
80+ }
81+ } ;
82+
83+
84+
85+
6686/**
6787 * Provides a pair of streams to do encrypted communication.
6888 */
@@ -357,24 +377,6 @@ SecurePair.prototype._error = function(err) {
357377 }
358378} ;
359379
360-
361- SecurePair . prototype . getPeerCertificate = function ( err ) {
362- if ( this . _ssl ) {
363- return this . _ssl . getPeerCertificate ( ) ;
364- } else {
365- return null ;
366- }
367- } ;
368-
369-
370- SecurePair . prototype . getCipher = function ( err ) {
371- if ( this . _ssl ) {
372- return this . _ssl . getCurrentCipher ( ) ;
373- } else {
374- return null ;
375- }
376- } ;
377-
378380// TODO: support anonymous (nocert) and PSK
379381
380382
@@ -606,11 +608,10 @@ exports.connect = function(port /* host, options, cb */) {
606608 socket . connect ( port , host ) ;
607609
608610 pair . on ( 'secure' , function ( ) {
609- console . log ( 'client: connected+secure!' ) ;
610- console . log ( 'client pair.getPeerCertificate(): %j' ,
611- pair . getPeerCertificate ( ) ) ;
612- console . log ( 'client pair.getCipher(): %j' ,
613- pair . getCipher ( ) ) ;
611+ console . log ( 'client cleartext.getPeerCertificate(): %j' ,
612+ cleartext . getPeerCertificate ( ) ) ;
613+ console . log ( 'client cleartext.getCipher(): %j' ,
614+ cleartext . getCipher ( ) ) ;
614615
615616 if ( cb ) {
616617 cb ( cleartext ) ;
0 commit comments