Skip to content

Instantly share code, notes, and snippets.

@collinsrj
Created July 22, 2015 05:10
Show Gist options
  • Save collinsrj/e7faf14bb4f1d0a190a0 to your computer and use it in GitHub Desktop.
Save collinsrj/e7faf14bb4f1d0a190a0 to your computer and use it in GitHub Desktop.
TLS 1.2 Node.js Server
// A super simple HTTPS service which allows you to GET a collection of names from https://<hostname>/names
var express = require('express');
var https = require('https');
var app = express();
var fs = require('fs');
app.get('/names', function (req, res) {
res.json(["Simon", "Bob"])
});
// You can generate the certs using the instructions given here:
// https://vanjakom.wordpress.com/2011/08/11/client-and-server-side-ssl-with-nodejs/
var server = https.createServer({
key: fs.readFileSync('ssl/server.key'),
cert: fs.readFileSync('ssl/server.crt'),
ca: fs.readFileSync('ssl/ca.crt'),
ciphers: [
'ECDHE-RSA-AES128-GCM-SHA256',
'ECDHE-ECDSA-AES128-GCM-SHA256',
'ECDHE-RSA-AES256-GCM-SHA384',
'ECDHE-ECDSA-AES256-GCM-SHA384',
'DHE-RSA-AES128-GCM-SHA256',
'ECDHE-RSA-AES128-SHA256',
'DHE-RSA-AES128-SHA256',
'ECDHE-RSA-AES256-SHA384',
'DHE-RSA-AES256-SHA384',
'ECDHE-RSA-AES256-SHA256',
'DHE-RSA-AES256-SHA256',
'HIGH',
'!aNULL',
'!eNULL',
'!EXPORT',
'!DES',
'!RC4',
'!MD5',
'!PSK',
'!SRP',
'!CAMELLIA'
].join(':'),
honorCipherOrder: true
}, app).listen(443);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment