You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB

common = require("../common");
assert = common.assert
15 years ago
var sys=require('sys');
var net=require('net');
var fs=require('fs');
var crypto=require('crypto');
15 years ago
//var client = net.createConnection(4443, "localhost");
var client = net.createConnection(443, "www.microsoft.com");
//var client = net.createConnection(443, "www.google.com");
var caPem = fs.readFileSync(common.fixturesDir+"/msca.pem");
15 years ago
//var caPem = fs.readFileSync("ca.pem");
var credentials = crypto.createCredentials({ca:caPem});
15 years ago
client.setEncoding("UTF8");
client.addListener("connect", function () {
console.log("client connected.");
15 years ago
client.setSecure(credentials);
});
client.addListener("secure", function () {
console.log("client secure : "+JSON.stringify(client.getCipher()));
console.log(JSON.stringify(client.getPeerCertificate()));
console.log("verifyPeer : "+client.verifyPeer());
15 years ago
client.write("GET / HTTP/1.0\r\n\r\n");
});
client.addListener("data", function (chunk) {
sys.common.error(chunk);
15 years ago
});
client.addListener("end", function () {
console.log("client disconnected.");
15 years ago
});