如何在 node.js 服务器上设置 EV 证书 [英] How to setup an EV Certificate a node.js server

查看:25
本文介绍了如何在 node.js 服务器上设置 EV 证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 Comodo 收到了四个文件:

I've received four files from Comodo:

AddTrustExternalCARoot.crt
COMODORSAAddTrustCA.crt
COMODORSAExtendedValidationSecureServerCA.crt
mydomain.crt

这是我第一次设置 https 服务器.

This is my first time setting up a https server.

我知道我必须设置传递给 https.createServer 的参数,但我的问题是我不知道哪个是正确的属性.

I know that I have to put on parameters that is passed to https.createServer but my problem is I don't know which one is the correct property.

推荐答案

服务器证书设置为cert,而你的CA证书设置在ca下:p>

The server certificate is set as cert, whereas your CA certificates are set under ca:

var fs = require('fs'),
    https = require('https');

var cfg = {
  key: fs.readFileSync('/path/to/privatekey.pem'),
  cert: fs.readFileSync('/path/to/mydomain.crt'), // PEM format
  ca: [
    fs.readFileSync('/path/to/AddTrustExternalCARoot.crt'), // PEM format
    fs.readFileSync('/path/to/COMODORSAAddTrustCA.crt'), // PEM format
    fs.readFileSync('/path/to/COMODORSAExtendedValidationSecureServerCA.crt') // PEM format
  ]
};

https.createServer(cfg, function(req, res) {
  // ...
}).listen(443);

或者,如果您将 keycertca 文件全部捆绑在一起,您也可以只使用 pfx到单个 PFX/PKCS12 格式的文件中.

Or you can use just pfx if you have your key, cert, and ca files all bundled into a single PFX/PKCS12-formatted file.

这篇关于如何在 node.js 服务器上设置 EV 证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆