简体   繁体   English

在Node Express应用程序中安装Entrust SSL证书

[英]Install Entrust SSL certificate in Node express application

I'm not sure how to pass in the given certificates to start the https server. 我不确定如何传递给定的证书来启动https服务器。 Entrust provided the following files: Entrust提供了以下文件:
1. Root certificate. 1.根证书。 (.txt) (。文本)
2. Chain root cert file. 2.链接根证书文件。 (.txt) (。文本)
3. Chain certificate. 3.连锁证书。 (.txt) (。文本)
4. Server certificate. 4.服务器证书。 (.crt) (.CRT)

My express app currently takes: 我的Express应用目前需要:

exports.key1 = {
    key:'./server/config/keys/server.key', // ?
    cert:'./server/config/keys/server.crt', // ?
    ca:'./server/config/keys/ca.csr' //given to entrust to generate their cert
};

I'm not sure how to modify the key to match the new files. 我不确定如何修改密钥以匹配新文件。

Once you've concatenated your certificates, instructions for this are provided by your issuer, you'll need to read them from the file system and provide them to http.createServer() to create a SSL server object. 串联证书后,颁发者将提供有关此证书的说明,您需要从文件系统中读取它们,并将其提供给http.createServer()来创建SSL服务器对象。 From the documentation: 从文档中:

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

var options = {
  key: fs.readFileSync('path/to/agent-key.pem'),
  cert: fs.readFileSync('path/to/agent-cert.pem')
};

https.createServer(options, function (req, res) {
  res.writeHead(200);
  res.end("hello world\n");
}).listen(8000);

Usually, you'll wrap the options block in a flag to check whether you are in production or development. 通常,您会将options块包装在标记中,以检查您是在生产还是开发中。 For production, you'll read the certificates from a secure, pre-defined path, whilst for development you can generate these and provide them in a root project folder fixtures/ , which you can also distribute with the project repository if it's more convenient. 对于生产,您将从安全的预定义路径中读取证书,而对于开发,则可以生成这些证书并将其提供到根项目文件夹fixtures/ ,如果方便的话,也可以将其与项目存储库一起分发。 Use the following to create a self-issued certificate for development: 使用以下内容创建自发证书进行开发:

openssl req -batch \
    -new -x509 -sha256 -newkey rsa:2048 -nodes -days 365 \
        -keyout fixtures/dev.key \
        -out fixtures/dev.crt;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM