Most likely format used by Certificate Authorities. Comes usually with extentions like .pem, .crt, .cer, and .key. PEM files are Base64 encoded ASCII files. File contains “—–BEGIN CERTIFICATE—–” and “—–END CERTIFICATE—–” statements. Contains certificates and private key.
DER uses binary format for a certificate. It usually comes with .der or .cer extension. Look for BEGIN/END statements in the file to see which format the file really is. Contains certificates and private key.
PKCS#7 or P7B format is usually in Base64 ASCII format and has a file extention of .p7b or .p7c. Contain “—–BEGIN PKCS7—–” and “—–END PKCS7—–” statements. Contains certificates but not private key.
PKCS#12 or PFX format uses binary format and is encryptable. Comes usually with extensions like .pfx and .p12.
$ openssl x509 -in certificate.crt -text -noout
$ openssl x509 -in certificate.crt -inform der -text -noout
$ openssl req -new -newkey rsa:2048 -nodes -keyout customer.com.key.txt -out customer.com.csr.txt
$ openssl pkcs12 -in bundle.customer.com.pfx -out package.pem -nodes
$ openssl pkcs12 -in bundle.customer.com.pfx -clcerts -nokeys -out domain.cer
$ openssl pkcs12 -in bundle.customer.com.pfx -nocerts -nodes -out domain.key
$ openssl pkcs12 -in domain.pfx -out domain-ca.crt -nodes -nokeys -cacerts
openssl pkcs12 -info -in bundle.p12
openssl s_client -servername NAME -connect HOST:PORT 2>/dev/null | openssl x509 -noout -dates
$ openssl pkcs12 -in bundle.customer.com.pfx -out package.pem -nodes
$ cp package.pem mykey.txt
$ cp package.pem mycert.txt
Then edit in vi, leaving private key to mykey.txt and certificate to mycert.txt
$ openssl x509 -in mycert.txt -text -noout
Download intermediate CA file from the web, based on step 3, then copy it to a file, for example geotrust_ssl_ca_g3.txt
Decode intermediate certificate to obtain root certificate type (See Issuer -> CN)
$ openssl x509 -in geotrust_ssl_ca_g3.txt -text -noout
Download root CA file from the web, based on step 5, then copy it to a file, for example geotrust_global_ca.txt
Concatenate intermediate and root certificates to a single text file
$ cat geotrust_ssl_ca_g3.txt geotrust_global_ca.txt > ca_bundle.txt
$ openssl pkcs12 -export -out bundle.customer.com.p12 -inkey mykey.txt -in mycert.txt -certfile ca_bundle.txt
$ openssl pkcs12 -info -in bundle.customer.com.p12