Reputation: 50328
I have a certificate and key, and I'm looking to serve my pages over https. How do I configure nodejs/expressjs to do so?
I'm explicitly looking to do this through the expressjs library.
Upvotes: 1
Views: 1211
Reputation: 58
if you use 0.2.4. you can use
var express = require('express');
var fs = require("fs");
var crypto = require('crypto');
var app = express.createServer();
var privateKey = fs.readFileSync('privatekey.pem').toString();
var certificate = fs.readFileSync('certificate.pem').toString();
var credentials = crypto.createCredentials({key: privateKey, cert: certificate});
app.setSecure(credentials);
but this not possible if you use node 0.4, as you can't call setSecure() to convert a server as SSL. One must create an instance of https.Server.
i don't know if there are any future plan to support this
Upvotes: 3