如何在nodejs中使用HTTPS的外部证书

时间:2015-11-11 17:32:38

标签: node.js ssl https

我的nodejs服务器当前使用自签名证书,如下所示:

var sslOptions = {
                key: fs.readFileSync('./self-ssl/server.key'),
                cert: fs.readFileSync('./self-ssl/server.crt'),
                ca: fs.readFileSync('./self-ssl/ca.crt'),
                requestCert: true,
                rejectUnauthorized: false
        };
        https = require('https').createServer(sslOptions, app);

我想将此更改为使用第三方证书,我已收到我的域名的RapidSSL证书,该证书已复制到./ssl/mactester_com_ee.crt

我的问题是如何编辑旧的自签名代码以使用新的第三方证书?

谢谢,

1 个答案:

答案 0 :(得分:0)

找到答案:

var sslOptions = {
                key: fs.readFileSync('./ssl/server_private.key'),
                cert: fs.readFileSync('./ssl/3rdparty.crt'),
        };
https = require('https').createServer(sslOptions, app);