简体   繁体   English

如何在NodeJS中安装GoDaddy SSL证书?

[英]How do I install GoDaddy SSL certificate in NodeJS?

I'm using NodeJS 0.10.x 我正在使用NodeJS 0.10.x

I purchased an SSL from GoDaddy, and downloaded two .crt files. 我从GoDaddy购买了SSL,并下载了两个.crt文件。 One .crt file appears to be the certificate, and the other one appears to be a bundle of certificates. 一个.crt文件似乎是证书,另一个似乎是一捆证书。

In my NodeJS application, I need to provide it a key and cert file like below: 在我的NodeJS应用程序中,我需要为其提供一个keycert文件,如下所示:

var server = useHttps ? https.Server({
  key: fs.readFileSync(__dirname + '/certs/server.key'),
  cert: fs.readFileSync(__dirname + '/certs/server.crt'),
}, app) : http.Server(app);

Do I need to convert one of the GoDaddy SSL files to .key ? 我需要将GoDaddy SSL文件之一转换为.key吗?

Can I use the files GoDaddy provided as-is? 我可以按原样使用GoDaddy提供的文件吗? If so, which one is the key? 如果是这样,关键是哪一个?

EDIT: 编辑:

I'm having the same problem as this question: 我有与此问题相同的问题:

Generating an SSL Key to work with node.js 生成SSL密钥以与node.js一起使用

However, the answer brushes over how to obtain a .key file. 但是,答案涉及如何获取.key文件。 I looked into the NodeJS documentation and it doesn't say anything about this. 我查看了NodeJS文档,但没有对此发表任何评论。

You already have the key: if is used to generate the CSR (certificate signing request) you sent to godaddy. 您已经有了密钥:if用于生成发送给godaddy的CSR(证书签名请求)。

The key is either an input to the openssl req -new command or you can ask it to generate a key for you (In which case the -keyout option controls where it is saved). 密钥可以是openssl req -new命令的输入,也可以要求它为您生成密钥(在这种情况下,-keyout选项控制密钥的保存位置)。

No one other than you should have access to the private key, so if you no longer have the key, you can't use the certificate. 除了您应该没有其他人可以访问私钥,因此,如果您再也没有私钥,则不能使用证书。 It looks like godaddy will let you rekey the certificate. 它看起来像GoDaddy的将让你重设密钥证书。 Effectively this is just a repeat of the process you originally went through to get the certificate. 实际上,这只是您最初获取证书所经过的过程的重复。

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

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