|
@ -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. |
|
|
* 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
|
|
|
// TODO: support anonymous (nocert) and PSK
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -606,11 +608,10 @@ exports.connect = function(port /* host, options, cb */) { |
|
|
socket.connect(port, host); |
|
|
socket.connect(port, host); |
|
|
|
|
|
|
|
|
pair.on('secure', function() { |
|
|
pair.on('secure', function() { |
|
|
console.log('client: connected+secure!'); |
|
|
console.log('client cleartext.getPeerCertificate(): %j', |
|
|
console.log('client pair.getPeerCertificate(): %j', |
|
|
cleartext.getPeerCertificate()); |
|
|
pair.getPeerCertificate()); |
|
|
console.log('client cleartext.getCipher(): %j', |
|
|
console.log('client pair.getCipher(): %j', |
|
|
cleartext.getCipher()); |
|
|
pair.getCipher()); |
|
|
|
|
|
|
|
|
|
|
|
if (cb) { |
|
|
if (cb) { |
|
|
cb(cleartext); |
|
|
cb(cleartext); |
|
|