OpenSSL command reference

Complete reference for OpenSSL subcommands including s_client, x509, req, verify, pkcs12, and rsa with flags and examples.

Complete reference for OpenSSL command-line subcommands covering certificate inspection, key generation, format conversion, and TLS connection testing.

OpenSSL Certificate Inspection Subcommands

SubcommandOpenSSL operationCommon flagsExample
x509OpenSSL displays, converts, and signs X.509 certificates-in, -noout, -text, -dates, -subject, -issuer, -modulus, -outformopenssl x509 -in cert.pem -noout -dates
s_clientOpenSSL establishes a TLS connection and displays handshake details, certificate chain, and verification result-connect host:port, -servername, -showcerts, -starttls, -CAfileopenssl s_client -connect example.com:443 -servername example.com
verifyOpenSSL verifies a certificate against a CA bundle and intermediate chain-CAfile, -untrusted, -partial_chainopenssl verify -CAfile ca.crt -untrusted intermediate.crt server.crt

OpenSSL Key and CSR Generation Subcommands

SubcommandOpenSSL operationCommon flagsExample
reqOpenSSL generates Certificate Signing Requests (CSRs) and self-signed certificates-new, -x509, -newkey rsa:2048, -keyout, -out, -nodes, -subj, -days, -addextopenssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes
genrsaOpenSSL generates an RSA private key-out, key size (2048, 4096)openssl genrsa -out server.key 2048
rsaOpenSSL processes RSA private keys — displays, converts, removes passphrase-in, -out, -noout, -modulus, -inform, -outformopenssl rsa -in server.key -noout -modulus
ecOpenSSL processes Elliptic Curve (EC) private keys-in, -out, -noout, -param_enc named_curveopenssl ec -in ec.key -noout -text
ecparamOpenSSL generates EC parameters and keys-genkey, -name prime256v1, -outopenssl ecparam -genkey -name prime256v1 -out ec.key

OpenSSL Format Conversion Subcommands

SubcommandOpenSSL operationCommon flagsExample
pkcs12OpenSSL creates or extracts PKCS12/PFX bundles containing certificate + key-export, -in, -inkey, -out, -certfile, -nodes, -clcertsopenssl pkcs12 -export -out bundle.pfx -inkey key.pem -in cert.pem
x509 -outformOpenSSL converts certificates between PEM and DER formats-inform PEM/DER, -outform PEM/DERopenssl x509 -in cert.pem -outform DER -out cert.der

OpenSSL Connection Testing Flags for s_client

FlagOpenSSL s_client behaviorDefaultExample
-connect host:portOpenSSL connects to the specified hostname and TCP port for TLS handshakeRequired-connect example.com:443
-servername hostOpenSSL sends the Server Name Indication (SNI) extension for virtual hostingNone-servername example.com
-showcertsOpenSSL displays all certificates in the chain, not just the leafLeaf only-showcerts
-starttls protoOpenSSL performs STARTTLS upgrade for plaintext protocols before TLS handshakeDirect TLS-starttls smtp (also: imap, pop3, ftp)
-CAfile pathOpenSSL uses the specified CA bundle file for chain verification instead of system defaultSystem bundle-CAfile /path/to/ca-bundle.crt
-verify_return_errorOpenSSL exits with error on verification failure instead of continuingContinue-verify_return_error