diff --git a/lib/tls.js b/lib/tls.js index d15f98818d..45c0cde39d 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -63,6 +63,26 @@ CryptoStream.prototype.end = function(err) { }; +CryptoStream.prototype.getPeerCertificate = function() { + if (this.pair._ssl) { + return this.pair._ssl.getPeerCertificate(); + } else { + return null; + } +}; + + +CryptoStream.prototype.getCipher = function(err) { + if (this.pair._ssl) { + return this.pair._ssl.getCurrentCipher(); + } else { + return null; + } +}; + + + + /** * Provides a pair of streams to do encrypted communication. */ @@ -357,24 +377,6 @@ SecurePair.prototype._error = function(err) { } }; - -SecurePair.prototype.getPeerCertificate = function(err) { - if (this._ssl) { - return this._ssl.getPeerCertificate(); - } else { - return null; - } -}; - - -SecurePair.prototype.getCipher = function(err) { - if (this._ssl) { - return this._ssl.getCurrentCipher(); - } else { - return null; - } -}; - // TODO: support anonymous (nocert) and PSK @@ -606,11 +608,10 @@ exports.connect = function(port /* host, options, cb */) { socket.connect(port, host); pair.on('secure', function() { - console.log('client: connected+secure!'); - console.log('client pair.getPeerCertificate(): %j', - pair.getPeerCertificate()); - console.log('client pair.getCipher(): %j', - pair.getCipher()); + console.log('client cleartext.getPeerCertificate(): %j', + cleartext.getPeerCertificate()); + console.log('client cleartext.getCipher(): %j', + cleartext.getCipher()); if (cb) { cb(cleartext); diff --git a/test/simple/test-securepair-client.js b/test/simple/test-securepair-client.js index 0a8518fd7c..9452fb20f3 100644 --- a/test/simple/test-securepair-client.js +++ b/test/simple/test-securepair-client.js @@ -89,10 +89,10 @@ function startClient() { pair.on('secure', function() { console.log('client: connected+secure!'); - console.log('client pair.getPeerCertificate(): %j', - pair.getPeerCertificate()); - console.log('client pair.getCipher(): %j', - pair.getCipher()); + console.log('client pair.cleartext.getPeerCertificate(): %j', + pair.cleartext.getPeerCertificate()); + console.log('client pair.cleartext.getCipher(): %j', + pair.cleartext.getCipher()); setTimeout(function() { pair.cleartext.write('hello\r\n'); }, 500); diff --git a/test/simple/test-securepair-server.js b/test/simple/test-securepair-server.js index 00798acf67..b172b11001 100644 --- a/test/simple/test-securepair-server.js +++ b/test/simple/test-securepair-server.js @@ -35,8 +35,8 @@ var server = net.createServer(function(socket) { pair.on('secure', function() { log('connected+secure!'); pair.cleartext.write('hello\r\n'); - log(pair.getPeerCertificate()); - log(pair.getCipher()); + log(pair.cleartext.getPeerCertificate()); + log(pair.cleartext.getCipher()); }); pair.cleartext.on('data', function(data) {