将Godaddy证书转换为.pfx文件

13
我从GoDaddy获得了SSL证书,并下载了证书和两个文本文件。 我需要为Azure Web Service应用程序生成pfx文件。 Godaddy向我发送了两个.crt文件和两个文本文件,其中一个文本文件名为“generate-private-key.txt”。 问题1:私钥文本文件是否是OpenSSL pfx文件转换实用程序的有效输入密钥文件? 问题2:.crt文件名称中是否有任何指示以确定哪个文件用作OpenSSL实用程序的输入?
2个回答

7
首先,通常你会使用私钥生成证书请求,然后将请求交给CA(在这种情况下是Go Daddy)。这样,CA就不会接触到你的私钥。
如果你只是要求颁发证书而没有提供证书请求,则CA必须为你生成私钥(这不是一个好主意,因为这是使用证书的关键,现在CA可以访问它……)。如果你这样做了,那么CA必须向你提供私钥以及设置在上面的任何密码(如果有)。
还建议你获取从生成的证书到CA根证书之间的中间证书。这些证书很有用,因为一些客户端如果没有提供它们就无法连接到你的服务器,例如Firefox浏览器。
因此,你需要将私钥、CA提供的公共证书和CA中间证书合并成PFX文件,以供Web服务器使用。
私钥可以采用以下一至两种主要格式:
DER - 这是二进制格式 PEM - 这是文本格式 - 它是DER格式的base64版本,并带有头部和尾部。
证书密钥可以采用多种格式,但最常见的是: - DER - 这是一种二进制格式 - PEM - 这是一种文本格式 - 它是DER格式的base64版本,并带有头部和尾部。
文件扩展名并不总是最好的指示格式的方法。尝试在文本编辑器中查看它们,以查看它们是否像带有头部和尾部的二进制或base64文本。
openssl生成PFX文件的基本命令是pkcs12命令。
通常您会执行以下操作: openssl pkcs12 -export -out name.pfx xxx
其中"xxx"取决于您需要提供什么。例如,如果您有: - key.pem - pem格式的私钥 - cert.pem - pem格式的公钥 - inter.pem - pem格式的CA中间证书
那么整个命令将是:
openssl pkcs12 -export -out name.pfx -inkey key.pem -in cert.pem -certfile inter.pem
如果不想包含inter.pem,只需省略"-certfile inter.pem"参数即可。
如果您的任何文件都是DER格式,则需要先将它们转换为PEM格式。
对于证书,您可以使用openssl x509命令,如下所示:
openssl x509 -in cert.der -inform der -out cert.pem
转换私钥将取决于使用的私钥类型,使用openssl rsaec命令。 转换密钥和证书的命令格式基本相同,但是您要使用rsa或ec而不是x509。

你的命令为什么有三个pem文件?GoDaddy只有一个pem文件(以及一个crt文件和一个p7b文件)。 - Richard Barraclough
命令 openssl pkcs12 -export -out pfx.pfx pem.pem 不起作用。 - Richard Barraclough
PEM和PFX(PKCS)都是证书信息的容器。区别在于PEM是文本格式,而PFX是二进制格式。我假设GoDaddy提供的PEM包含多个证书(私钥、证书,可能还有中间证书)。您应该能够在文本编辑器(如记事本)中打开pem文件。如果您的PEM文件包含公钥和私钥,则可以在openssl命令的多个部分中使用同一个pem文件。例如:openssl pkcs12 -export -out out.pfx -inkey in.pem -in in.pem - Shane Powell
这些 openssl 命令在哪里输入?这似乎不是一个有效的命令行命令或程序。 - Jonathan Wood
你需要更具体地说明哪个命令行不起作用。命令“openssl pkcs12 -export -out pfx.pfx pem.pem”无法工作,因为最后一部分是无效的(pem.pem)。一个可行的示例是:“openssl pkcs12 -export -out name.pfx -inkey key.pem -in cert.pem -certfile inter.pem”,假设key.pem、cert.pem和inter.pem是“正确”的pem文件。即key.pem具有私钥,cert.pem具有证书,inter.pem中包含一个或多个中间证书。 - Shane Powell
显示剩余7条评论

3

我发现这个很复杂。对我来说,拼凑这13个步骤相当于一个五扳手级别的Haynes手册。希望这可以帮到你,当然如果有哪些步骤可以简化,请提供反馈。
作为参考,我将我的应用程序托管在Azure上,并从Godaddy购买了通配符证书。

1. Create CSR (Certificate Signing Request):
    a. Open IIS (start, type IIS, should get Internet Information Services, if not you may need to install IIS first) on your development machine locally, 
    b. Service Certificates, Create Certificate Request. Fill out your company details, these appear to be simple free text fields although I suspect the company name and address should match with what you've submitted to godaddy.  Choose 2048 bit encryption.  
    c. Save CSR file on c: drive
2. Login to godaddy and rekey the certificate:  
    a. Login to godaddy, choose myproducts, certificates.   Click your certificate then manage
    b. Manage certificate section, paste in the text from your CSR file (open in notepad first locally) then 'add change'.   Then 'Submit all changes'.    It seemed to suggest then that I had to go all through domain verification now but this cleared when I refreshed after 5 minutes
3. Now in the 'Download Certificate' section, choose Server Type IIS then download zip file
4. Convert the crt file to a cer file:
    a. Extract the files from the zip file
    b. Double click the crt file, 
    c. Choose open, details tab, copy to file button then save the .cer file
5. Go back into IIS and choose 'Complete Certificate Request'.   Feed it the .cer file you downloaded.  
6. Chose a friendly name, I think this is only for your reference on your machine.   Then ok.  This should set your certificate up on your IIS locally.
7. Right click on the new certificate within IIS 'Server Certificates' section and choose export.  Add a secure password (you'll need it later). You can now export the hallowed .pfx file
8. Login to azure, go to your appservice that you wish to secure, and choose the 'TLS/SSL settings' blade.   Click the 'Private Key Certificates(.pfx) word at the top of the page (this is a tab).  
9. Choose the plus button to the left of 'Upload Certificate'.   Feed in your pfx file and your password from earlier.
10. Go back to bindings for your app. There is a small section marke 'Add TLS/SSL Binding' with a plus to the left of it, it looks like a heading but is in fact a button.   
11. Your custom domain should be selectable (if not add a custom domain in the Custom Domains blade), choose your certificate that you uploaded in step 9, and choose SNI SSL.    Add Binding button at the bottom.
12. Ensure the HTTPS Only slider is set to 'On'
13. Repeat for all your appservices.

这个解决方案也适用于Windows服务器...从第1步到第7步... - Ifeoluwa Osungade
完美的一步一步! - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接