簡體   English   中英

在Node Express應用程序中安裝Entrust SSL證書

[英]Install Entrust SSL certificate in Node express application

我不確定如何傳遞給定的證書來啟動https服務器。 Entrust提供了以下文件:
1.根證書。 (。文本)
2.鏈接根證書文件。 (。文本)
3.連鎖證書。 (。文本)
4.服務器證書。 (.CRT)

我的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
};

我不確定如何修改密鑰以匹配新文件。

串聯證書后,頒發者將提供有關此證書的說明,您需要從文件系統中讀取它們,並將其提供給http.createServer()來創建SSL服務器對象。 從文檔中:

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);

通常,您會將options塊包裝在標記中,以檢查您是在生產還是開發中。 對於生產,您將從安全的預定義路徑中讀取證書,而對於開發,則可以生成這些證書並將其提供到根項目文件夾fixtures/ ,如果方便的話,也可以將其與項目存儲庫一起分發。 使用以下內容創建自發證書進行開發:

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