我有一個Node.js服務器,域上有一個活動的SSL證書。 我已經閱讀了一些關於這個網站的回覆,但即使當我涉及這些已經解決的問題時,我也會得到一個錯誤。使用Node.js將http重定向到https
var express = require('express');
var https = require('https');
var http = require('http');
var path = require('path');
var fs = require('fs');
var mysql = require('mysql');
var queue = {};
var qc = {};
var app = express();
var options = {
key: fs.readFileSync('sslcert/domain-name.key', 'utf8'),
cert: fs.readFileSync('sslcert/domain-name.csr', 'utf8')
};
var httpServer = http.createServer(app);
var httpsServer = https.createServer(options, app);
/* various stuff to display my website */
httpServer.listen(process.env.PORT);
httpsServer.listen(process.env.PORT);
我在我的控制檯中出現以下錯誤。
_tls_common.js:67
c.context.setCert(options.cert);
^
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Object.createSecureContext (_tls_common.js:67:17)
at Server (_tls_wrap.js:754:25)
at new Server (https.js:17:14)
at Object.exports.createServer (https.js:37:10)
at Object.<anonymous> (/srv/data/web/vhosts/default/server.js:35:25)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
預先感謝您的回答!
Noël。
[OpenSSL:PEM例程:PEM \ _read \ _bio:no start line:pem \ _lib.c:703:Expectcting:TRUSTED CERTIFICATE](http://stackoverflow.com/questions/20837161/openssl- PEM-routinespem - 讀biono-啓動linepem-LIB-c703expecting,TRUSTe的) –