Add some verification code to tls.connect()

pull/22966/head
Ryan Dahl 2010-12-09 02:35:16 -08:00
parent a473b8dafb
commit 5138992f3c
2 changed files with 14 additions and 8 deletions

View File

@ -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;

View File

@ -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);
});