mirror of https://github.com/lukechilds/node.git
Rhys Jones
15 years ago
committed by
Ryan Dahl
4 changed files with 119 additions and 0 deletions
@ -0,0 +1,35 @@ |
|||
require('../common'); |
|||
var sys=require('sys'); |
|||
var net=require('net'); |
|||
var fs=require('fs'); |
|||
|
|||
//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(fixturesDir+"/msca.pem"); |
|||
//var caPem = fs.readFileSync("ca.pem");
|
|||
|
|||
var credentials = net.createCredentials({ca:caPem}); |
|||
|
|||
client.setEncoding("UTF8"); |
|||
client.addListener("connect", function () { |
|||
sys.puts("client connected."); |
|||
client.setSecure(credentials); |
|||
}); |
|||
|
|||
client.addListener("secure", function () { |
|||
sys.puts("client secure : "+JSON.stringify(client.getCipher())); |
|||
sys.puts(JSON.stringify(client.getPeerCertificate())); |
|||
sys.puts("verifyPeer : "+client.verifyPeer()); |
|||
client.write("GET / HTTP/1.0\r\n\r\n"); |
|||
}); |
|||
|
|||
client.addListener("data", function (chunk) { |
|||
sys.error(chunk); |
|||
}); |
|||
|
|||
client.addListener("end", function () { |
|||
sys.puts("client disconnected."); |
|||
}); |
|||
|
@ -0,0 +1,34 @@ |
|||
require('../common'); |
|||
|
|||
var sys=require('sys'); |
|||
var net=require('net'); |
|||
var fs=require('fs'); |
|||
|
|||
var keyPem = fs.readFileSync(fixturesDir + "/test_key.pem"); |
|||
var certPem = fs.readFileSync(fixturesDir + "/cert.pem"); |
|||
|
|||
var credentials = net.createCredentials({key:keyPem, cert:certPem}); |
|||
var i = 0; |
|||
var server = net.createServer(function (connection) { |
|||
connection.setSecure(credentials); |
|||
connection.setEncoding("binary"); |
|||
|
|||
connection.addListener("secure", function () { |
|||
//sys.puts("Secure");
|
|||
}); |
|||
|
|||
connection.addListener("data", function (chunk) { |
|||
sys.puts("recved: " + JSON.stringify(chunk)); |
|||
connection.write("HTTP/1.0 200 OK\r\nContent-type: text/plain\r\nContent-length: 9\r\n\r\nOK : "+i+"\r\n\r\n"); |
|||
i=i+1; |
|||
connection.close(); |
|||
}); |
|||
|
|||
connection.addListener("end", function () { |
|||
connection.close(); |
|||
}); |
|||
|
|||
}); |
|||
server.listen(4443); |
|||
|
|||
|
@ -0,0 +1,35 @@ |
|||
-----BEGIN CERTIFICATE----- |
|||
MIIDNDCCAp2gAwIBAgIJAJvXLQpGPpm7MA0GCSqGSIb3DQEBBQUAMHAxCzAJBgNV |
|||
BAYTAkdCMRAwDgYDVQQIEwdHd3luZWRkMREwDwYDVQQHEwhXYXVuZmF3cjEUMBIG |
|||
A1UEChMLQWNrbmFjayBMdGQxEjAQBgNVBAsTCVRlc3QgQ2VydDESMBAGA1UEAxMJ |
|||
bG9jYWxob3N0MB4XDTA5MTEwMjE5MzMwNVoXDTEwMTEwMjE5MzMwNVowcDELMAkG |
|||
A1UEBhMCR0IxEDAOBgNVBAgTB0d3eW5lZGQxETAPBgNVBAcTCFdhdW5mYXdyMRQw |
|||
EgYDVQQKEwtBY2tuYWNrIEx0ZDESMBAGA1UECxMJVGVzdCBDZXJ0MRIwEAYDVQQD |
|||
Ewlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANdym7nGe2yw |
|||
6LlJfJrQtC5TmKOGrSXiyolYCbGOy4xZI4KD31d3097jhlQFJyF+10gwkE62DuJe |
|||
fLvBZDUsvLe1R8bzlVhZnBVn+3QJyUIWQAL+DsRj8P3KoD7k363QN5dIaA1GOAg2 |
|||
vZcPy1HCUsvOgvDXGRUCZqNLAyt+h/cpAgMBAAGjgdUwgdIwHQYDVR0OBBYEFK4s |
|||
VBV4shKUj3UX/fvSJnFaaPBjMIGiBgNVHSMEgZowgZeAFK4sVBV4shKUj3UX/fvS |
|||
JnFaaPBjoXSkcjBwMQswCQYDVQQGEwJHQjEQMA4GA1UECBMHR3d5bmVkZDERMA8G |
|||
A1UEBxMIV2F1bmZ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rnAlU66+tXifPVoYb+O7AWXX1uw16OFNMQkpw0P |
|||
lZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/ |
|||
-----END CERTIFICATE----- |
Loading…
Reference in new issue