是否有可能将.pfx (个人信息交换) 文件转换为.cer (安全证书) 文件?除非我错了,否则.cer 不是以某种方式嵌入在.pfx 中吗?如果可能,我想一些方法来提取它。
PFX 文件是PKCS#12 Personal Information Exchange Syntax Standardbundle。它们可以包含任意数量的私钥以及附带的 X.509 证书和证书颁发机构链(设置证书)。
如果要提取客户端证书,可以使用OpenSSL's PKCS12 tool。
openssl pkcs12 -in input.pfx -out mycerts.crt -nokeys -clcerts
上面的命令将输出 PEM 格式的证书。“.crt”文件扩展名由 macOS 和 Window 处理。
您在问题中提到了“.cer”扩展名,该扩展名通常用于 DER 编码的文件。二进制编码。首先尝试“.crt”文件,如果它不被接受,很容易从 PEM 转换为 DER:
openssl x509 -inform pem -in mycerts.crt -outform der -out mycerts.cer
我相信的简单方法是导入它,然后导出它,使用 Windows 管理控制台中的证书管理器。
如果您在 PowerShell 中工作,则可以使用类似以下内容的内容(给定 pfx 文件InputBundle.pfx)来生成 DER 编码的(二进制)证书文件OutputCert.der:
Get-PfxCertificate -FilePath InputBundle.pfx |
Export-Certificate -FilePath OutputCert.der -Type CERT
为了清楚起见,添加了 Newline,但是您当然可以将所有这些都放在一行上。
如果您需要 ASCII / Base64 编码 PEM 格式的证书,您可以采取额外的步骤来执行此操作,如其他地方所述,如这里:https://superuser.com/questions/351548/windows-integrated-utility-to-convert-der-to-pem
如果需要导出为与 DER 编码格式不同的格式,可以将 Export-Certificate 的-Type
参数更改为使用.NET 支持的类型,如help Export-Certificate -Detailed
所示:
-Type <CertType>
Specifies the type of output file for the certificate export as follows.
-- SST: A Microsoft serialized certificate store (.sst) file format which can contain one or more certificates. This is the default value for multiple certificates.
-- CERT: A .cer file format which contains a single DER-encoded certificate. This is the default value for one certificate.
-- P7B: A PKCS#7 file format which can contain one or more certificates.
我想添加一个我认为最简单的方法。
只需右键单击 pfx 文件,单击“安装”按照向导,并将其添加到商店(我添加到个人商店)。
在开始菜单中键入 certmgr.msc,然后转到 CertManager 程序。
找到您的 pfx 证书(顶部的选项卡是各种商店),单击导出按钮并按照向导(有一个导出为.CER 的选项)
从本质上讲,它与 Andrew 的答案相同,但它避免使用 Windows 管理控制台(直接进入导入 / 导出)。
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(22条)