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

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

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

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


当前回答

我从.key和.pem文件创建了.pfx文件。

比如这个openssl pkcs12 -inkey rootCA。输入rootCA。-export -out rootCA.pfx . pem

其他回答

我有你要求的链接。使用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格式导出证书,您需要在请求证书的同一台机器上执行以下步骤。 导入的文件可以上传到服务器。

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

希望这能有所帮助!

如果您正在寻找Windows图形用户界面,请查看DigiCert。我只用了这个,非常简单。

在SSL选项卡下,我首先导入了证书。然后,一旦我选择了证书,我就可以将其导出为PFX,包括带或不带密钥文件。

https://www.digicert.com/util

需要使用makecert工具。

以管理员身份打开命令提示符,输入以下命令:

makecert -sky exchange -r -n "CN=<CertificateName>" -pe -a sha1 -len 2048 -ss My "<CertificateName>.cer"

其中<CertifcateName> =要创建的证书的名称。

然后,您可以通过键入certmgr打开管理控制台的证书管理器管理单元。在开始菜单中,单击个人>证书>,您的证书应该可用。

这是一篇文章。

https://azure.microsoft.com/documentation/articles/cloud-services-certs-create/

当您说证书在MMC中可用时,它是在“当前用户”或“本地计算机”下可用吗?我发现只有在本地计算机下才能导出私钥。

您可以将证书管理单元添加到MMC,并选择它应该为哪个帐户管理证书。选择本地计算机。如果您的证书不在那里,请通过右键单击存储区并选择All Tasks > import来导入它。

现在,在证书管理单元的本地计算机版本下导航到导入的证书。右键单击证书,选择“All Tasks > Export”。导出向导的第二页应该询问您是否要导出私钥。选择Yes。PFX选项现在将是唯一可用的选项(如果选择no,则显示灰色,并且当前用户帐户下无法导出私钥)。

系统将要求您为PFX文件设置密码,然后设置证书名称。