OpenSSL Cheatsheet
OpenSSL command cheatsheet covering certificate inspection, generation, format conversion, key operations, SSL/TLS connection testing, hashing, signing, and encryption organized by category
70 commands
x509 -textView certificate details
openssl x509 -in cert.pem -text -nooutx509 -enddateCheck certificate expiry date
openssl x509 -in cert.pem -enddate -nooutx509 -startdateCheck certificate start date
openssl x509 -in cert.pem -startdate -nooutx509 -ext SANExtract Subject Alternative Names
openssl x509 -in cert.pem -noout -ext subjectAltNamex509 -subjectShow certificate subject
openssl x509 -in cert.pem -subject -nooutx509 -issuerShow certificate issuer
openssl x509 -in cert.pem -issuer -nooutx509 -serialShow certificate serial number
openssl x509 -in cert.pem -serial -nooutx509 -fingerprint SHA256Get SHA256 fingerprint
openssl x509 -in cert.pem -fingerprint -sha256 -nooutx509 -fingerprint SHA1Get SHA1 fingerprint
openssl x509 -in cert.pem -fingerprint -sha1 -nooutverifyVerify certificate chain
openssl verify -CAfile ca.pem cert.pemx509 -purposeCheck certificate purpose
openssl x509 -in cert.pem -purpose -nooutreq -x509 (self-signed)Generate self-signed certificate
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodesreq -new (CSR)Generate Certificate Signing Request
openssl req -new -key key.pem -out request.csrx509 -x509toreqCreate CSR from existing certificate
openssl x509 -x509toreq -in cert.pem -signkey key.pem -out request.csrreq -new -newkeyGenerate CSR with new key
openssl req -new -newkey rsa:4096 -nodes -keyout key.pem -out request.csrx509 -req (CA sign)Sign CSR with CA certificate
openssl x509 -req -in request.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -days 365req -x509 -addext SANGenerate self-signed certificate with SAN
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -addext "subjectAltName=DNS:example.com,DNS:*.example.com"req -x509 ECGenerate EC certificate
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -keyout key.pem -out cert.pem -days 365 -nodespkcs12 -exportCreate PKCS12 file
openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pem -certfile ca.pemx509 PEM→DERConvert PEM to DER format
openssl x509 -in cert.pem -outform DER -out cert.derx509 DER→PEMConvert DER to PEM format
openssl x509 -in cert.der -inform DER -outform PEM -out cert.pempkcs12 PEM→PKCS12Convert PEM to PKCS12 format
openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pempkcs12 PKCS12→PEMConvert PKCS12 to PEM format
openssl pkcs12 -in cert.pfx -out cert.pem -nodespkcs12 extract keyExtract private key from PKCS12
openssl pkcs12 -in cert.pfx -nocerts -out key.pem -nodespkcs12 extract certExtract certificate from PKCS12
openssl pkcs12 -in cert.pfx -clcerts -nokeys -out cert.pempkcs7 PKCS7→PEMConvert PKCS7 to PEM format
openssl pkcs7 -in cert.p7b -print_certs -out cert.pemcrl2pkcs7 PEM→PKCS7Convert PEM to PKCS7 format
openssl crl2pkcs7 -nocrl -certfile cert.pem -out cert.p7bgenrsaGenerate RSA private key
openssl genrsa -out key.pem 4096ecparam P-256Generate EC key (P-256)
openssl ecparam -genkey -name prime256v1 -noout -out key.pemecparam P-384Generate EC key (P-384)
openssl ecparam -genkey -name secp384r1 -noout -out key.pemgenpkey Ed25519Generate Ed25519 key
openssl genpkey -algorithm Ed25519 -out key.pemrsa -textView RSA key details
openssl rsa -in key.pem -text -nooutec -textView EC key details
openssl ec -in key.pem -text -nooutrsa -puboutExtract public key
openssl rsa -in key.pem -pubout -out pub.pemrsa (remove passphrase)Remove passphrase from key
openssl rsa -in encrypted.pem -out decrypted.pemrsa -aes256Add passphrase to key
openssl rsa -in key.pem -aes256 -out encrypted.pemkey-cert matchCheck if key matches certificate
openssl x509 -in cert.pem -noout -modulus | openssl md5 && openssl rsa -in key.pem -noout -modulus | openssl md5req -text (CSR)Check CSR details
openssl req -in request.csr -text -noouts_clientTest SSL/TLS connection
openssl s_client -connect host:443s_client -showcertsShow certificate chain
openssl s_client -connect host:443 -showcertss_client -tls1_2Test connection with TLS 1.2
openssl s_client -connect host:443 -tls1_2s_client -tls1_3Test connection with TLS 1.3
openssl s_client -connect host:443 -tls1_3s_client -cipherConnect with specific cipher suite
openssl s_client -connect host:443 -cipher ECDHE-RSA-AES256-GCM-SHA384s_client -servernameConnect with SNI
openssl s_client -connect host:443 -servername example.coms_client STARTTLS SMTPConnect with STARTTLS (SMTP)
openssl s_client -connect mail:25 -starttls smtps_client STARTTLS IMAPConnect with STARTTLS (IMAP)
openssl s_client -connect mail:143 -starttls imaps_client STARTTLS FTPConnect with STARTTLS (FTP)
openssl s_client -connect ftp:21 -starttls ftps_client → x509Get and display server certificate only
openssl s_client -connect host:443 2>/dev/null | openssl x509 -text -noouts_client -statusCheck OCSP stapling
openssl s_client -connect host:443 -statusdgst -sha256Calculate SHA256 digest
openssl dgst -sha256 file.txtdgst -sha512Calculate SHA512 digest
openssl dgst -sha512 file.txtdgst -md5Calculate MD5 digest
openssl dgst -md5 file.txtdgst -signSign a file
openssl dgst -sha256 -sign key.pem -out sig.bin file.txtdgst -verifyVerify a signature
openssl dgst -sha256 -verify pub.pem -signature sig.bin file.txtdgst -hmacCalculate HMAC-SHA256
openssl dgst -sha256 -hmac "secret" file.txtlist -digest-algorithmsList available digest algorithms
openssl list -digest-algorithmsbase64Base64 encode a file
openssl base64 -in file.bin -out file.b64enc -aes-256-cbcEncrypt file with AES-256-CBC
openssl enc -aes-256-cbc -salt -pbkdf2 -in plain.txt -out encrypted.binenc -d (decrypt)Decrypt an encrypted file
openssl enc -d -aes-256-cbc -pbkdf2 -in encrypted.bin -out plain.txtenc -a (Base64)Encrypt with Base64 output
openssl enc -aes-256-cbc -salt -pbkdf2 -a -in plain.txt -out encrypted.txtrand -hexGenerate random hex bytes
openssl rand -hex 32rand -base64Generate random Base64 bytes
openssl rand -base64 32rand (password)Generate random password
openssl rand -base64 24list -cipher-algorithmsList available cipher algorithms
openssl list -cipher-algorithmsverify (chain)Verify certificate with intermediate
openssl verify -CAfile ca.pem -untrusted intermediate.pem cert.pemcrl -textCheck Certificate Revocation List
openssl crl -in crl.pem -text -nooutspeedBenchmark cryptographic operations
openssl speed rsa2048speed -multiMulti-threaded benchmark
openssl speed -multi 4 aes-256-cbcversion -aShow OpenSSL version information
openssl version -aciphers -vList available cipher suites
openssl ciphers -v