Created
July 22, 2015 05:10
-
-
Save collinsrj/e7faf14bb4f1d0a190a0 to your computer and use it in GitHub Desktop.
TLS 1.2 Node.js Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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