Last active
January 19, 2018 14:26
-
-
Save No9/253e855d8cf70a580afbf6ff293e9446 to your computer and use it in GitHub Desktop.
strong tls
This file contains hidden or 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
var https = require('https'); | |
var cluster = require('cluster'); | |
var express = require('express'); | |
var fs = require('fs'); | |
var shareTlsSessions = require('strong-cluster-tls-store'); | |
if (cluster.isMaster) { | |
// Count the machine's CPUs | |
var cpuCount = require('os').cpus().length; | |
// Create a worker for each CPU | |
for (var i = 0; i < cpuCount; i += 1) { | |
cluster.fork(); | |
} | |
} else { | |
var app = express(); | |
// configure the app | |
app.get('/', function (req, res) { | |
res.send('Hello World!'); | |
}); | |
var httpsOpts = { | |
key : fs.readFileSync('key.pem'), | |
cert : fs.readFileSync('cert.pem'), | |
passphrase: '1290' | |
} | |
// Start the server and configure TLS sessions sharing | |
var server = https.createServer(httpsOpts, app); | |
shareTlsSessions(server); | |
server.listen(8080); | |
} | |
// openssl s_client -reconnect -port 8080 | grep -E 'New|Reused' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment