是否可以将.pfx (个人信息交换)文件转换为.cer (安全证书)文件?除非我弄错了,否则.cer不是以某种方式嵌入到了.pfx中吗?如果可能的话,我想要一些方法来提取它。
发布于 2008-12-31 15:22:55
我相信最简单的方法是使用Windows管理控制台中的证书管理器导入然后导出。
发布于 2009-01-01 22:09:56
PFX文件是PKCS#12 Personal Information Exchange Syntax Standard包。它们可以包括任意数量的私钥以及附带的X.509证书和证书颁发机构链(设置证书)。
如果要提取客户端证书,可以使用OpenSSL's PKCS12 tool。
openssl pkcs12 -in input.pfx -out mycerts.crt -nokeys -clcerts上面的命令将以PEM格式输出证书。macOS和Window都处理".crt“文件扩展名。
您在问题中提到了".cer“扩展名,它通常用于DER编码文件。二进制编码。首先尝试".crt“文件,如果它不被接受,很容易从PEM转换为DER:
openssl x509 -inform pem -in mycerts.crt -outform der -out mycerts.cer发布于 2015-03-11 07:25:03
给定pfx文件InputBundle.pfx,以生成DER编码(二进制)证书文件OutputCert.der,如果您在PowerShell中工作,则可以使用类似以下内容
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编码的格式,可以更改导出证书的-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.https://stackoverflow.com/questions/403174
复制相似问题