我需要pfx文件来安装IIS网站上的https。
我有两个单独的文件:证书(。cer或pem)和私钥(.crt),但IIS只接受.pfx文件。
我显然安装了证书,它在证书管理器(mmc)中可用,但当我选择证书导出向导时,我无法选择PFX格式(它是灰色的)
有什么工具可以做到这一点吗?或者c#中有编程的例子吗?
我需要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!
希望这能有所帮助!
其他回答
我有你要求的链接。使用OpenSSL将CRT和KEY文件合并为PFX
以上连结摘录:
First we need to extract the root CA certificate from the existing .crt file, because we need this later. So open up the .crt and click on the Certification Path tab. Click the topmost certificate (In this case VeriSign) and hit View Certificate. Select the Details tab and hit Copy to File… Select Base-64 encoded X.509 (.CER) certificate Save it as rootca.cer or something similar. Place it in the same folder as the other files. Rename it from rootca.cer to rootca.crt Now we should have 3 files in our folder from which we can create a PFX file. Here is where we need OpenSSL. We can either download and install it on Windows, or simply open terminal on OSX.
编辑:
有一个支持链接,提供了关于如何安装证书的分步信息。 安装成功后,导出证书,选择.pfx格式,包含私钥。 重要提示:要以.pfx格式导出证书,您需要在请求证书的同一台机器上执行以下步骤。 导入的文件可以上传到服务器。
您需要使用openssl。
openssl pkcs12 -export -out domain.name.pfx -inkey domain.name.key -in domain.name.crt
密钥文件只是一个文本文件,其中包含您的私钥。
如果您有根CA和中间cert,那么也可以使用多个in参数将它们包括在内
openssl pkcs12 -export -out domain.name.pfx -inkey domain.name.key -in domain.name.crt -in intermediate.crt -in rootca.crt
如果你有一个捆绑的crt文件,你可以在nginx中使用,你可以把它和cert一起传入:
cat domain.name.crt | tee -a domain.name.bundled.crt
cat intermediate.crt | tee -a domain.name.bundled.crt
cat rootca.crt | tee -a domain.name.bundled.crt
openssl pkcs12 -export -out domain.name.pfx \
-inkey domain.name.key \
-in domain.name.bundled.crt
您可以从这里安装openssl: openssl
我想推广“X证书和密钥管理器”或xca.exe,它就像OpenSSL的GUI版本。你可以通过以下步骤生成pfx文件:
在“private Keys”页签导入私钥; 在“Certificates”页签中导入证书; 生成pfx文件,选择证书,然后“导出”,格式选择PKCS #12。
就是这样。
我也有同样的问题。我的问题是,在扩展ssl验证过程完成之前,生成初始证书请求的计算机已经崩溃。我需要生成一个新的私钥,然后从证书提供者导入更新后的证书。如果您的计算机上不存在私钥,则不能将证书导出为pfx。这个选项是灰色的。
我写了一个小控制台应用程序,它可以将PEM证书文件和私钥文件转换为一个.pfx PKCS12证书文件。 它使用BouncyCastle库。
我的Github回购:https://github.com/nklkli/PEM-to-PKCS12
请随意修改代码以创建密码保护的*.pfx。