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

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

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

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


当前回答

在大多数情况下,如果您无法将证书导出为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!

希望这能有所帮助!

其他回答

我也有同样的问题。我的问题是,在扩展ssl验证过程完成之前,生成初始证书请求的计算机已经崩溃。我需要生成一个新的私钥,然后从证书提供者导入更新后的证书。如果您的计算机上不存在私钥,则不能将证书导出为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!

希望这能有所帮助!

https://msdn.microsoft.com/en-us/library/ff699202.aspx

(文章相关引语如下))

Next, you have to create the .pfx file that you will use to sign your deployments. Open a Command Prompt window, and type the following command: PVK2PFX –pvk yourprivatekeyfile.pvk –spc yourcertfile.cer –pfx yourpfxfile.pfx –po yourpfxpassword where: pvk - yourprivatekeyfile.pvk is the private key file that you created in step 4. spc - yourcertfile.cer is the certificate file you created in step 4. pfx - yourpfxfile.pfx is the name of the .pfx file that will be creating. po - yourpfxpassword is the password that you want to assign to the .pfx file. You will be prompted for this password when you add the .pfx file to a project in Visual Studio for the first time.

(可选的(不是为OP,而是为以后的读者),你可以从头开始创建.cer和.pvk文件)(你会在上面之前这样做)。注意,mm/dd/yyyy是开始日期和结束日期的占位符。请参阅MSDN文章以获得完整的文档。

makecert -sv yourprivatekeyfile.pvk -n "CN=My Certificate Name" yourcertfile.cer -b mm/dd/yyyy -e mm/dd/yyyy -r

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

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

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

我想推广“X证书和密钥管理器”或xca.exe,它就像OpenSSL的GUI版本。你可以通过以下步骤生成pfx文件:

在“private Keys”页签导入私钥; 在“Certificates”页签中导入证书; 生成pfx文件,选择证书,然后“导出”,格式选择PKCS #12。

就是这样。