Updated on 2022-09-27 GMT+08:00

HTTPS Certificate Format Conversion

The HTTPS configuration only supports certificates or private keys in PEM format. It is recommended that OpenSSL be used to convert certificates in other formats into the PEM format. The following examples illustrate some popular converting methods.

In the following examples, the name of certificates before conversion is old_certificate by default, and that of private keys before conversion is old_key by default. The new certificate and private key names are new_certificate and new_key respectively.

  • Converting DER to PEM
    openssl x509 -inform der -in old_certificate.cer -out new_certificate.pem
    openssl rsa -inform DER -outform pem -in old_key.der -out new_key.key
  • Converting P7B to PEM
    openssl pkcs7 -print_certs -in old_certificate.p7b -out new_certificate.cer
  • Converting PFX to PEM
    openssl pkcs12 -in old_certificate.pfx -nokeys -out new_certificate.pem
    openssl pkcs12 -in old_certificate.pfx -nocerts -out new_key.key

You can also use an online third-party certificate conversion tool to convert certificates into different formats.