Skip to content

Instantly share code, notes, and snippets.

@theosp
Last active December 21, 2015 17:39
Show Gist options
  • Save theosp/6342189 to your computer and use it in GitHub Desktop.
Save theosp/6342189 to your computer and use it in GitHub Desktop.
var tls = require('tls');
var fs = require('fs');
var options = {
key: fs.readFileSync('test-key.pem'),
cert: fs.readFileSync('test-cert.pem'),
// This is necessary only if using the client certificate authentication.
requestCert: true,
// This is necessary only if the client uses the self-signed certificate.
//ca: [ fs.readFileSync('client-cert.pem') ]
};
var server = tls.createServer(options, function(cleartextStream) {
cleartextStream.on('data', function(data) {
console.log(data.toString("utf-8"));
});
});
server.listen(8000, function() {
console.log('server bound');
});
// $ node %
//
// openssl s_client -connect 127.0.0.1:8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment