2010-12-05 00:20:34 +01:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');;
|
2010-10-11 23:04:09 +02:00
|
|
|
var util=require('util');
|
2010-04-03 02:10:32 +02:00
|
|
|
var net=require('net');
|
|
|
|
var fs=require('fs');
|
2010-04-15 21:03:55 +02:00
|
|
|
var crypto=require('crypto');
|
2010-04-03 02:10:32 +02:00
|
|
|
|
|
|
|
//var client = net.createConnection(4443, "localhost");
|
|
|
|
var client = net.createConnection(443, "www.microsoft.com");
|
|
|
|
//var client = net.createConnection(443, "www.google.com");
|
|
|
|
|
2010-07-15 20:47:25 +02:00
|
|
|
var caPem = fs.readFileSync(common.fixturesDir+"/msca.pem");
|
2010-04-03 02:10:32 +02:00
|
|
|
//var caPem = fs.readFileSync("ca.pem");
|
|
|
|
|
2010-09-11 09:44:29 +02:00
|
|
|
try{
|
|
|
|
var credentials = crypto.createCredentials({ca:caPem});
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Not compiled with OPENSSL support.");
|
|
|
|
process.exit();
|
|
|
|
}
|
2010-04-03 02:10:32 +02:00
|
|
|
|
|
|
|
client.setEncoding("UTF8");
|
|
|
|
client.addListener("connect", function () {
|
2010-06-24 02:40:51 +02:00
|
|
|
console.log("client connected.");
|
2010-04-03 02:10:32 +02:00
|
|
|
client.setSecure(credentials);
|
|
|
|
});
|
|
|
|
|
|
|
|
client.addListener("secure", function () {
|
2010-06-24 02:40:51 +02:00
|
|
|
console.log("client secure : "+JSON.stringify(client.getCipher()));
|
|
|
|
console.log(JSON.stringify(client.getPeerCertificate()));
|
|
|
|
console.log("verifyPeer : "+client.verifyPeer());
|
2010-04-03 02:10:32 +02:00
|
|
|
client.write("GET / HTTP/1.0\r\n\r\n");
|
|
|
|
});
|
|
|
|
|
|
|
|
client.addListener("data", function (chunk) {
|
2010-08-17 12:59:36 +02:00
|
|
|
common.error(chunk);
|
2010-04-03 02:10:32 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
client.addListener("end", function () {
|
2010-06-24 02:40:51 +02:00
|
|
|
console.log("client disconnected.");
|
2010-04-03 02:10:32 +02:00
|
|
|
});
|
|
|
|
|