【问题标题】:How to fix missing an Intermediate/chain certificate in nodejs with certificate of type .pfx如何使用 .pfx 类型的证书修复 nodejs 中缺少中间/链证书
【发布时间】:2023-03-03 23:32:02
【问题描述】:

我有一个 .pfx 格式的证书,当我使用以下代码并使用 ssl 检查检查 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

【问题讨论】:

    标签: node.js ssl


    【解决方案1】:

    经过所有研究和示例帖子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

    【讨论】:

      猜你喜欢
      • 2015-12-23
      • 1970-01-01
      • 2013-09-18
      • 2021-12-04
      • 2016-03-16
      • 1970-01-01
      • 2019-06-21
      • 1970-01-01
      • 2022-07-11
      相关资源
      最近更新 更多