mirror of https://github.com/nodejs/node.git
Add some verification code to tls.connect()
parent
a473b8dafb
commit
5138992f3c
14
lib/tls.js
14
lib/tls.js
|
@ -608,14 +608,16 @@ exports.connect = function(port /* host, options, cb */) {
|
|||
socket.connect(port, host);
|
||||
|
||||
pair.on('secure', function() {
|
||||
console.log('client cleartext.getPeerCertificate(): %j',
|
||||
cleartext.getPeerCertificate());
|
||||
console.log('client cleartext.getCipher(): %j',
|
||||
cleartext.getCipher());
|
||||
var verifyError = pair._ssl.verifyError();
|
||||
|
||||
if (cb) {
|
||||
cb(cleartext);
|
||||
if (verifyError) {
|
||||
cleartext.authorized = false;
|
||||
cleartext.authorizationError = verifyError;
|
||||
} else {
|
||||
cleartext.authorized = true;
|
||||
}
|
||||
|
||||
if (cb) cb();
|
||||
});
|
||||
|
||||
return cleartext;
|
||||
|
|
|
@ -10,8 +10,12 @@ var options = {
|
|||
};
|
||||
|
||||
|
||||
var s = tls.connect(443, "google.com", options, function() {
|
||||
console.error("CONNECTED");
|
||||
var s = tls.connect(443, "joyent.com", options, function() {
|
||||
if (!s.authorized) {
|
||||
console.error("CONNECTED: " + s.authorizationError);
|
||||
s.destroy();
|
||||
return;
|
||||
}
|
||||
s.pipe(process.stdout);
|
||||
process.openStdin().pipe(s);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue