我有一个 .pfx 格式的证书,当我使用下面的代码并使用 ssl checked 检查 ssl 时,我得到了中间证书丢失错误。
if(process.env.NODE_ENV === "production") {
var credentials = {
pfx: fs.readFileSync('C:/self/certificate/testname.com.pfx'),
passphrase: "ffffff!"
};
this.app.server = https.createServer(credentials, this.app);
this.app.server.timeout = 600000;
this.init();
const httpServer = http.createServer((req, res) => {
res.writeHead(301, {Location: `https://${req.headers.host}${req.url}`});
res.end();
});
httpServer.listen(80);
} else {
this.app.server = http.createServer(this.app);
this.init();
}
请告诉我如何使用它。我已经看过一些帖子,例如 sample
但是找不到可以帮助您安装 .pfx 类型证书的东西。 帮助赞赏。 -AJ
最佳答案
在所有研究和样本发布之后 Sample ,
我使用 openSSL 从 pfx 文件生成了 .crt、.ca-bundle 和 .pem 文件,然后将 .ca-bundle 中的所有行附加到 .crt 文件,然后使用下面的代码。
var credentials = {
key: fs.readFileSync('C:/testApp/certificate/private-key.pem'),
cert: fs.readFileSync('C:/testApp/certificate/certificate.crt'),
};
this.app.server = https.createServer(credentials, this.app);
然后重新运行服务器。一切都很好,我能够成功地看到中间证书链。 谢谢 -AJ
关于node.js - 如何使用 .pfx 类型的证书修复 nodejs 中缺少的中间/链证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58177462/