certlook.tr · SSL / TLS
OpenSSL commands
The commands you need most when working with SSL certificates: viewing, testing, converting and verifying. Each one ready to copy.
Viewing
View a certificate
Domain names, dates, issuer and extensions.
openssl x509 -in cert.pem -noout -textStart and expiry dates
openssl x509 -in cert.pem -noout -datesDomain names in the certificate (SAN)
openssl x509 -in cert.pem -noout -ext subjectAltNameView a CSR and verify its signature
openssl req -in request.csr -noout -text -verifySHA-256 fingerprint
openssl x509 -in cert.pem -noout -fingerprint -sha256Testing a live server
Certificate and chain sent by the server
-servername is needed to get the right certificate when several sites share an IP.
openssl s_client -connect example.com:443 -servername example.com -showcerts </dev/nullExpiry date of a remote certificate
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
| openssl x509 -noout -subject -issuer -datesMail server (STARTTLS)
Use imap, pop3 or ftp instead of smtp as needed.
openssl s_client -connect mail.example.com:587 -starttls smtp -servername mail.example.com </dev/nullTry a specific TLS version
If the connection fails, the server does not support that version.
openssl s_client -connect example.com:443 -servername example.com -tls1_3 </dev/nullCheck OCSP stapling
openssl s_client -connect example.com:443 -servername example.com -status </dev/null | grep -A3 'OCSP'Keys and matching
Do the certificate, CSR and private key match?
All three outputs must be identical.
openssl x509 -in cert.pem -noout -pubkey | openssl sha256
openssl req -in request.csr -noout -pubkey | openssl sha256
openssl pkey -in private.key -pubout | openssl sha256New RSA key and CSR
Use the CSR generator to fill the details with a form.
openssl req -new -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csr \
-subj "/CN=example.com" -addext "subjectAltName=DNS:example.com,DNS:www.example.com"New CSR from an existing key (renewal)
openssl req -new -key example.com.key -out new.csr -subj "/CN=example.com" \
-addext "subjectAltName=DNS:example.com,DNS:www.example.com"Remove the passphrase from a private key
So the web server does not ask for it on every start.
openssl pkey -in encrypted.key -out private.keyConverting formats
Create a PFX / P12 (IIS, Windows, Plesk)
Add -legacy for older Windows Server versions.
openssl pkcs12 -export -out site.pfx -inkey private.key -in cert.pem -certfile chain.pemExtract key, certificate and chain from a PFX
openssl pkcs12 -in site.pfx -nocerts -nodes -out private.key
openssl pkcs12 -in site.pfx -clcerts -nokeys -out cert.pem
openssl pkcs12 -in site.pfx -cacerts -nokeys -out chain.pemPEM → DER and DER → PEM
openssl x509 -in cert.pem -outform der -out cert.der
openssl x509 -in cert.der -inform der -out cert.pemP7B → PEM
openssl pkcs7 -in cert.p7b -print_certs -out chain.pemBuild a fullchain file (nginx)
Order matters: server certificate first, then intermediates.
cat cert.pem chain.pem > fullchain.pemVerifying
Verify a chain
"OK" means the chain leads to a trusted root on the system.
openssl verify -untrusted chain.pem cert.pemSelf-signed certificate for testing
For development only; browsers do not trust it.
openssl req -x509 -newkey rsa:2048 -nodes -days 30 -keyout test.key -out test.pem -subj "/CN=localhost"Frequently asked questions
How do I check a certificate's expiry date from the command line?
For a file: openssl x509 -enddate -noout -in cert.pem. For a live server: echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -enddate.
How do I create a PFX file?
openssl pkcs12 -export -out site.pfx -inkey private.key -in cert.pem -certfile chain.pem. If an older Windows Server cannot open it, add -legacy.
Which file should nginx and Apache use?
nginx's ssl_certificate takes the fullchain file (certificate + intermediates). Apache 2.4.8+ also accepts the fullchain in SSLCertificateFile; older versions take intermediates separately via SSLCertificateChainFile.
SSL certificates
Get your certificate from ixirhost
Sectigo, DigiCert, GeoTrust, RapidSSL and Certum certificates, with installation support and renewal tracking.