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

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

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

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


当前回答

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

其他回答

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

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

https://www.digicert.com/util

您需要使用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

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

微软Pvk2Pfx命令行实用程序似乎有你需要的功能:

Pvk2Pfx (Pvk2Pfx.exe)是一个命令行工具,它将。spc、。cer和。pvk文件中包含的公钥和私钥信息复制到个人信息交换(Personal information Exchange, pfx)文件中。 http://msdn.microsoft.com/en-us/library/windows/hardware/ff550672 (v = vs.85) . aspx

注意:如果你需要/想要/更喜欢c#解决方案,那么你可能会考虑使用http://www.bouncycastle.org/ api。

从这个链接:

https://serverfault.com/a/224127/569310 https://stackoverflow.com/a/49784278/7856894 https://stackoverflow.com/a/17284371/7856894

如果需要,可以在OpenSSL中使用这个简单的命令序列来生成filessl。key (SSL证书密钥文件)、filessl. key和filessl. key。SSL证书文件:

openssl genrsa 2048 > filessl.key
chmod 400 filessl.key
openssl req -new -x509 -nodes -sha256 -days 365 -key filessl.key -out filessl.crt

在此之前,您必须响应交互式表单(您可以从其他帖子中找到类似req.cnf的参考信息:https://stackoverflow.com/a/49784278/7856894)

然后,继续执行最后一个命令,它会要求您输入Export Password:

openssl pkcs12 -export -out filessl.pfx -inkey filessl.key -in filessl.crt

准备好了,它生成了.pfx(或. p12)格式的SSL证书文件: