1.PEM and DER Conversion(格式转换)
convert a certificate from PEM to DER format:
$ openssl x509 -inform PEM -in fd.pem -outform DER -out fd.der
To convert a certificate from DER to PEM format:
$ openssl x509 -inform DER -in fd.der -outform PEM -out fd.pem
2.PKCS#12 (PFX) Conversion
$ openssl pkcs12 -export -name “My Certificate” -out fd.p12 -inkey fd.key -in fd.crt -certfile fd-chain.crt
命令:
$ openssl pkcs12 -in fd.p12 -nocerts -out fd.key -nodes
$ openssl pkcs12 -in fd.p12 -nokeys -clcerts -out fd.crt
$ openssl pkcs12 -in fd.p12 -nokeys -cacerts -out fd-chain.crt
3.PKCS#7 Conversion
To convert from PEM to PKCS#7, use the crl2pkcs7 command:
$ openssl crl2pkcs7 -nocrl -out fd.p7b -certfile fd.crt -certfile fd-chain.crt
To convert from PKCS#7 to PEM, use the pkcs7 command with the -print_certs switch:
openssl pkcs7 -in fd.p7b -print_certs -out fd.pem