我已经设置了我的server.js文件:
var sslOptions = {
key: fs.readFileSync('./server2.crt'),
pfx: fs.readFileSync('./csr.pem'),
};
var server = https.createServer(sslOptions, app).listen(port, function(){
console.log("Express server listening on port " + port);
});
证书和密钥使用以下方式进行自签名:
openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out server2.crt
openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem
不管我做什么都没关系,我不断收到这个错误:
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Object.createSecureContext (_tls_common.js:85:17)
at Server (_tls_wrap.js:776:25)
at new Server (https.js:27:14)
at Object.createServer (https.js:48:10)
我查看了其他没有效果的SO答案。