creating a nodejs express https server
I searched for a while and found a lot of out dated articles and stack overflow suggestions until I found a post that gave me the solution:
var express = require('express')
, fs = require('fs')
, https = require('https')
var httpsOptions = {
key: fs.readFileSync('path/to/key')
, cert: fs.readFileSync('path/to/cert')
}
var app = express.createServer()
, appSecure = express.createServer(httpsOptions)
app.listen(80)
appSecure.listen(443)
Written by Miles Matthias
Related protips
1 Response
Thank you. I implemented the equivalent of this, and for a still-undiagnosed reason it fails to complete a connection. The certificate-key configuration works with Nginx, but not with Node/Express. Running
openssl s_client -connect jpdev.pro:3000 -showcerts -prexit -state -debug -msg
on a client, I get a lot of output, of which the piece that seems most informative is:
SSL_connect:failed in SSLv3 read finished A
51684:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-64.50.6/src/ssl/s23_lib.c:185:
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Express
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#