Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed ssl client and server examples

  • Loading branch information...
commit 3510669db23d0600d2a31f66838cc28d270e6ee9 1 parent 8efab85
wave.to waveto authored
Showing with 7 additions and 5 deletions.
  1. +2 −1  test/disabled/tls_client.js
  2. +5 −4 test/disabled/tls_server.js
3  test/disabled/tls_client.js
View
@@ -2,6 +2,7 @@ require('../common');
var sys=require('sys');
var net=require('net');
var fs=require('fs');
+var crypto=require('crypto');
//var client = net.createConnection(4443, "localhost");
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("ca.pem");
-var credentials = net.createCredentials({ca:caPem});
+var credentials = crypto.createCredentials({ca:caPem});
client.setEncoding("UTF8");
client.addListener("connect", function () {
9 test/disabled/tls_server.js
View
@@ -3,11 +3,12 @@ require('../common');
var sys=require('sys');
var net=require('net');
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 credentials = net.createCredentials({key:keyPem, cert:certPem});
+var credentials = crypto.createCredentials({key:keyPem, cert:certPem});
var i = 0;
var server = net.createServer(function (connection) {
connection.setSecure(credentials);
@@ -21,11 +22,11 @@ var server = net.createServer(function (connection) {
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.end();
});
connection.addListener("end", function () {
- connection.close();
+ connection.end();
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.