Node.js/Express.js Chain Certificate Not working

前端 未结 2 1644
离开以前
离开以前 2020-12-14 01:25

I have an SSL server in Express, which is not working on all browsers (unless the user manually trusts the website) since some browsers require the chain certificate (we hav

2条回答
  •  [愿得一人]
    2020-12-14 01:33

    Does your intermediate certificate file contains multiple certificate blocks?

    If that's the case you should split them into different files and read them one by one. You can pass them as an array to the ca parameter.

    I've got it working with the code below:

    var https = require('https'),
        read = require('fs').readFileSync,
        httpsOptions = {
            key: read('ssl/mycertificate.key', 'utf8'),
            cert: read('ssl/mycertificate.crt', 'utf8'),
            ca: [
                read('ssl/rapidssl_1.pem', 'utf8'),
                read('ssl/rapidssl_2.pem', 'utf8')
            ]
        };
    
    https.createServer(httpsOptions, function (req, res) {
        // ...
    });
    

提交回复
热议问题