Browse Source

Fixed ssl client and server examples

v0.7.4-release
Rhys Jones 15 years ago
parent
commit
3510669db2
  1. 3
      test/disabled/tls_client.js
  2. 9
      test/disabled/tls_server.js

3
test/disabled/tls_client.js

@ -2,6 +2,7 @@ require('../common');
var sys=require('sys'); var sys=require('sys');
var net=require('net'); var net=require('net');
var fs=require('fs'); var fs=require('fs');
var crypto=require('crypto');
//var client = net.createConnection(4443, "localhost"); //var client = net.createConnection(4443, "localhost");
var client = net.createConnection(443, "www.microsoft.com"); var client = net.createConnection(443, "www.microsoft.com");
@ -10,7 +11,7 @@ var client = net.createConnection(443, "www.microsoft.com");
var caPem = fs.readFileSync(fixturesDir+"/msca.pem"); var caPem = fs.readFileSync(fixturesDir+"/msca.pem");
//var caPem = fs.readFileSync("ca.pem"); //var caPem = fs.readFileSync("ca.pem");
var credentials = net.createCredentials({ca:caPem}); var credentials = crypto.createCredentials({ca:caPem});
client.setEncoding("UTF8"); client.setEncoding("UTF8");
client.addListener("connect", function () { client.addListener("connect", function () {

9
test/disabled/tls_server.js

@ -3,11 +3,12 @@ require('../common');
var sys=require('sys'); var sys=require('sys');
var net=require('net'); var net=require('net');
var fs=require('fs'); var fs=require('fs');
var crypto=require('crypto');
var keyPem = fs.readFileSync(fixturesDir + "/test_key.pem"); var keyPem = fs.readFileSync(fixturesDir + "/cert.pem");
var certPem = fs.readFileSync(fixturesDir + "/cert.pem"); var certPem = fs.readFileSync(fixturesDir + "/cert.pem");
var credentials = net.createCredentials({key:keyPem, cert:certPem}); var credentials = crypto.createCredentials({key:keyPem, cert:certPem});
var i = 0; var i = 0;
var server = net.createServer(function (connection) { var server = net.createServer(function (connection) {
connection.setSecure(credentials); connection.setSecure(credentials);
@ -21,11 +22,11 @@ var server = net.createServer(function (connection) {
sys.puts("recved: " + JSON.stringify(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"); 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; i=i+1;
connection.close(); connection.end();
}); });
connection.addListener("end", function () { connection.addListener("end", function () {
connection.close(); connection.end();
}); });
}); });

Loading…
Cancel
Save