我尝试将我的节点服务器配置为SSL,我的节点服务器和php都在同一个实例上工作。节点启动没有错误,但是当我通过套接字或网址发送请求时,它将崩溃。只显示 细分错误
我的节点版本是6.9.4
这里是我的Node js脚本
var https = require('https');
var http = require('http');
var fs = require('fs');
var app = require('express')();
var f_root = 'path_to_ssl';
var options = {
key: fs.readFileSync(f_root+'ssl.myserver.key'),
cert: fs.readFileSync(f_root+'ssl.myserver.pem')
};
app.get("/", function(request, response){
console.log(" Hello World");
});
var httpsserver = https.createServer(options, app);
httpsserver.listen(3001);
答案 0 :(得分:1)
终于找到了问题
问题是.pem文件。我使用.crt而不是.pem文件
此处更新
var https = require('https');
var http = require('http');
var fs = require('fs');
var app = require('express')();
var f_root = 'path_to_ssl';
var options = {
key: fs.readFileSync(f_root+'ssl.myserver.key'),
// this is the issue
cert: fs.readFileSync(f_root+'ssl.myserver.crt')
};
app.get("/", function(request, response){
console.log(" Hello World");
});
var httpsserver = https.createServer(options, app);
httpsserver.listen(3001);