Convert .pfx to .cer

前端 未结 5 774
灰色年华
灰色年华 2020-11-27 10:15

Is it possible to convert a .pfx (Personal Information Exchange) file to a .cer (Security Certificate) file? Unless I\'m mistaken, isn\'t a .cer somehow embedded inside a .p

5条回答
  •  醉话见心
    2020-11-27 10:40

    If you're working in PowerShell you can use something like the following, given a pfx file InputBundle.pfx, to produce a DER encoded (binary) certificate file OutputCert.der:

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

    Newline added for clarity, but you can of course have this all on a single line.

    If you need the certificate in ASCII/Base64 encoded PEM format, you can take extra steps to do so as documented elsewhere, such as here: https://superuser.com/questions/351548/windows-integrated-utility-to-convert-der-to-pem

    If you need to export to a different format than DER encoded, you can change the -Type parameter for Export-Certificate to use the types supported by .NET, as seen in help Export-Certificate -Detailed:

    -Type 
        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.
    

提交回复
热议问题