簡體   English   中英

如何使用 type.pfx 證書修復 nodejs 中缺少中間/鏈證書

[英]How to fix missing an Intermediate/chain certificate in nodejs with certificate of type .pfx

我有一個 in.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();
    }

請讓我知道如何使用它。 我已經看過一些帖子,例如示例

但是找不到可以幫助您安裝 type.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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM