首页 文章

将.pfx转换为.cer

提问于
浏览
120

是否可以将.pfx(个人信息交换)文件转换为.cer(安全证书)文件?除非我弄错了,不是一个.cer以某种方式嵌入.pfx中?如果可能的话,我想要一些方法来提取它 .

5 回答

  • 0

    如果您在PowerShell中工作,可以使用以下内容(给定pfx文件 InputBundle.pfx )来生成DER编码(二进制)证书文件 OutputCert.der

    Get-PfxCertificate -FilePath InputBundle.pfx | 
    Export-Certificate -FilePath OutputCert.der -Type CERT
    

    为了清晰起见,添加了换行符,但您当然可以将这一切都放在一行上 .

    如果您需要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.
    
  • 73

    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格式输出证书 . “.crt”文件扩展名由macOS和Window处理 .

    您在常规用于DER编码文件的问题中提到“.cer”扩展名 . binart编码 . 首先尝试“.crt”文件,如果不接受,可以轻松地从PEM转换为DER:

    openssl x509 -inform pem -in mycerts.crt -outform der -out mycerts.cer
    
  • 20

    我相信的简单方法是导入它,然后使用Windows管理控制台中的证书管理器将其导出 .

  • 165
    openssl rsa -in f.pem -inform PEM -out f.der -outform DER
    
  • 24

    我想添加一个我认为最简单的方法 .

    • 只需右键单击pfx文件,单击“安装”按照向导,将其添加到商店(我添加到个人商店) .

    • 在开始菜单中键入certmgr.msc并转到CertManager程序 .

    • 找到您的pfx证书(顶部的标签是各个商店),单击导出按钮并按照向导(有一个选项导出为.CER)

    基本上它与安德鲁的答案完全相同,但它避免使用Windows管理控制台(直接进入导出/导出) .

相关问题