Skip to content

Instantly share code, notes, and snippets.

@jacky9813
Last active October 31, 2023 10:33
Show Gist options
  • Save jacky9813/b92096b6f3574daf2187e647be762939 to your computer and use it in GitHub Desktop.
Save jacky9813/b92096b6f3574daf2187e647be762939 to your computer and use it in GitHub Desktop.

Certificates

Related Documents

Format Convertion Cheat Sheet

[-out file]: An optional parameter for the command. {-clcerts|-chain}: Choose one parameter for the command.

Input \ Output X.509 PEM X.509 DER PKCS#7 PEM PKCS#7 DER PKCS#12
X.509 PEM -- openssl x509 -in cert.x509.pem -outform DER [-out cert.x509.der] openssl crl2pkcs7 -certfile certs.x509.pem -nocrl [-out certs.p7.pem] Convert to PKCS#7 PEM first. openssl pkcs12 -export -in chain.x509.pem [-inkey key.p8.pem] [-out bundle.pfx]
X.509 DER openssl x509 -in cert.x509.der -inform DER [-out cert.x509.pem] -- Convert to X.509 PEM first. Convert to X.509 PEM first. Convert to X.509 PEM first.
PKCS#7 PEM openssl pkcs7 -in cert.p7.pem -print_certs [-out certs.x509.pem] Convert to X.509 PEM first. -- openssl pkcs7 -in certs.p7.pem -outform DER [-out certs.p7.der] Convert to X.509 PEM first.
PKCS#7 DER openssl pkcs7 -in cert.p7.der -inform DER -print_certs [-out certs.x509.pem] Convert to X.509 PEM first. openssl pkcs7 -in cert.p7.der -inform DER [-out cert.p7.pem] -- Convert to X.509 PEM first.
PKCS#12 openssl pkcs12 -in bundle.pfx -nokeys {-clcerts|-chain} [-out cert.x509.pem] Convert to X.509 PEM first. Convert to X.509 PEM first. Convert to X.509 PEM first. --

Note

While other format supports multiple certificates in one file, X.509 DER supports only one certificate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment