我幾乎下面這個教程(所有其他教程,我發現看起來是一樣的)無法在express.js安裝HTTPS
http://www.hacksparrow.com/express-js-https.html
我的代碼如下:
// dependencies
var express = require('express')
, https = require('https')
, fs = require('fs');
var privateKey = fs.readFileSync('./ssl/rp-key.pem').toString();
var certificate = fs.readFileSync('./ssl/rp-cert.pem').toString();
var app = express.createServer({
key : privateKey
, cert : certificate
});
...
// start server
https.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
的應用程序啓動sudo的節點應用程序後,細現在
Express server listening on port 443
當我蜷縮
curl https://localhost/
我得到
curl: (35) Unknown SSL protocol error in connection to localhost:443
任何想法?
如果您刪除對key和cert的'toString'調用,是否會得到相同的錯誤? – 2012-07-19 19:17:43
雅,我刪除toString後得到相同的錯誤 – Max 2012-07-19 19:23:39
這裏簡潔地回答了這裏:http://stackoverflow.com/a/23894573/1882064 – arcseldon 2014-10-09 15:29:15