Convert .pfx to .cer

前端 未结 5 761
灰色年华
灰色年华 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:41

    PFX files are PKCS#12 Personal Information Exchange Syntax Standard bundles. They can include arbitrary number of private keys with accompanying X.509 certificates and a certificate authority chain (set certificates).

    If you want to extract client certificates, you can use OpenSSL's PKCS12 tool.

    openssl pkcs12 -in input.pfx -out mycerts.crt -nokeys -clcerts
    

    The command above will output certificate(s) in PEM format. The ".crt" file extension is handled by both macOS and Window.

    You mention ".cer" extension in the question which is conventionally used for the DER encoded files. A binary encoding. Try the ".crt" file first and if it's not accepted, easy to convert from PEM to DER:

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

提交回复
热议问题