我需要pfx文件来安装IIS网站上的https。

我有两个单独的文件:证书(。cer或pem)和私钥(.crt),但IIS只接受.pfx文件。

我显然安装了证书,它在证书管理器(mmc)中可用,但当我选择证书导出向导时,我无法选择PFX格式(它是灰色的)

有什么工具可以做到这一点吗?或者c#中有编程的例子吗?


当前回答

你不需要openssl或makecert或任何。你也不需要CA给你的个人密钥。我几乎可以保证,问题是你希望能够使用CA提供的密钥和cer文件,但它们不是基于“IIS方式”。

SSL证书IIS与PFX一劳永逸- SSL和IIS解释- http://rainabba.blogspot.com/2014/03/ssl-certs-for-iis-with-pfx-once-and-for.html

Use IIS "Server Certificates" UI to "Generate Certificate Request" (the details of this request are out of the scope of this article but those details are critical). This will give you a CSR prepped for IIS. You then give that CSR to your CA and ask for a certificate. Then you take the CER/CRT file they give you, go back to IIS, "Complete Certificate Request" in the same place you generated the request. It may ask for a .CER and you might have a .CRT. They are the same thing. Just change the extension or use the . extension drop-down to select your .CRT. Now provide a proper "friendly name" (*.yourdomain.example, yourdomain.example, foo.yourdomain.example, etc..) THIS IS IMPORTANT! This MUST match what you setup the CSR for and what your CA provided you. If you asked for a wildcard, your CA must have approved and generated a wildcard and you must use the same. If your CSR was generated for foo.yourdomain.example, you MUST provide the same at this step.

其他回答

我正在使用libreSSL v2.8.3在macbook上尝试openssl,并得到错误“没有证书匹配私钥”。我有一个域证书,2个中间证书和1个根证书。所以我使用以下命令成功地工作:

openssl pkcs12 -export -clcerts -inkey private.csr.key -in domain.name.crt -certfile intermediate1.crt -certfile intermediate2.crt -certfile root.crt -out domain.name.p12 -name "Your Name"

它将要求在导入过程中使用的密码。该命令将生成一个.p12文件,该文件可以重命名为.pfx,因为两者是相同的。

你不需要openssl或makecert或任何。你也不需要CA给你的个人密钥。我几乎可以保证,问题是你希望能够使用CA提供的密钥和cer文件,但它们不是基于“IIS方式”。

SSL证书IIS与PFX一劳永逸- SSL和IIS解释- http://rainabba.blogspot.com/2014/03/ssl-certs-for-iis-with-pfx-once-and-for.html

Use IIS "Server Certificates" UI to "Generate Certificate Request" (the details of this request are out of the scope of this article but those details are critical). This will give you a CSR prepped for IIS. You then give that CSR to your CA and ask for a certificate. Then you take the CER/CRT file they give you, go back to IIS, "Complete Certificate Request" in the same place you generated the request. It may ask for a .CER and you might have a .CRT. They are the same thing. Just change the extension or use the . extension drop-down to select your .CRT. Now provide a proper "friendly name" (*.yourdomain.example, yourdomain.example, foo.yourdomain.example, etc..) THIS IS IMPORTANT! This MUST match what you setup the CSR for and what your CA provided you. If you asked for a wildcard, your CA must have approved and generated a wildcard and you must use the same. If your CSR was generated for foo.yourdomain.example, you MUST provide the same at this step.

Windows不需要安装OpenSSL的解决方案

我最近试图解决同样的问题——我只有一台windows笔记本电脑,没有安装openssl(也没有足够的管理权限来安装它)。原来windows有一个内置的实用程序,叫做certutil,它能够将。crt和。key文件组合成。pfx。医生来了。

您需要创建一个新文件夹,并将.crt和关键文件放在其中。重命名两个文件,使其具有相同的名称(但扩展名不同):

{{sitename}}.crt
{{siteName}}.key

如果你的密钥文件是一个普通的txt -只是改变扩展名。key。

之后,在该文件夹中打开cmd并运行certutil -mergepfx [INPUTFILE] [OUTPUTFILE]

例子:

证书文件:“mySite.crt”

密钥文件:mySite.key

certutil命令:certutil -mergepfx mySite。crt mySite.pfx

注意:您将被要求为新创建的.pfx文件提供密码-不要忘记记忆/存储它-因为在目标系统上导入证书时将需要它。

在大多数情况下,如果您无法将证书导出为PFX(包括私钥),是因为MMC/IIS无法找到/没有访问私钥(用于生成CSR)的权限。以下是我解决这个问题的步骤:

Run MMC as Admin Generate the CSR using MMC. Follow this instructions to make the certificate exportable. Once you get the certificate from the CA (crt + p7b), import them (Personal\Certificates, and Intermediate Certification Authority\Certificates) IMPORTANT: Right-click your new certificate (Personal\Certificates) All Tasks..Manage Private Key, and assign permissions to your account or Everyone (risky!). You can go back to previous permissions once you have finished. Now, right-click the certificate and select All Tasks..Export, and you should be able to export the certificate including the private key as a PFX file, and you can upload it to Azure!

希望这能有所帮助!

这是迄今为止最简单的转换方法。Cer到*。可以文件:

只需从DigiCert下载便携式证书转换器: https://www.digicert.com/util/pfx-certificate-management-utility-import-export-instructions.htm

执行它,选择一个文件,并得到你的*.pfx!!