OpenSSL
OpenSSL is two things: a widely used cryptography and TLS library linked into web servers, language runtimes, and operating systems, and the openssl command-line tool that developers and operators reach for whenever certificates or TLS connections misbehave. Generating a key, creating a certificate signing request, checking which certificate a server actually presents, finding out why a chain fails to verify, or converting a certificate into the format a Java or Windows system wants — all are one openssl command away.
This page focuses on the practical commands, organized by task, and the habits that keep them safe. Automated certificate issuance — cert-manager, ACME clients, managed load balancers — should handle production certificates; OpenSSL is how you inspect, debug, and handle the cases automation does not cover.
TL;DR
- Generate keys with
openssl genpkey(EC P-256 or Ed25519 for most uses; RSA 3072+ where required). - Create CSRs with
openssl req -new, always including subjectAltName — browsers ignore the Common Name. - Inspect certificates with
openssl x509 -noout -text, and live servers withopenssl s_client. - Verify chains with
openssl verify; most "untrusted certificate" errors are missing intermediates. - Convert between PEM, DER, and PKCS#12 with
x509,pkey, andpkcs12. - Use a supported OpenSSL 3.x release (3.5 is the current LTS), and never commit private keys.
Quick Example
Check what a server presents, when it expires, and whether the chain verifies — the three questions behind most TLS incidents:
-servername sends SNI; without it, servers hosting several sites may return a default certificate and send you chasing the wrong problem.
Core Concepts
Formats and Files
Extensions are conventions, not guarantees — inspect files rather than trusting their names.
Keys, CSRs, and Certificates
A private key stays secret. A certificate signing request (CSR) contains the public key and requested names, signed with the private key to prove possession. A certificate authority returns a certificate binding those names to the public key, usually alongside intermediate certificates that link it to a trusted root. Servers must send the leaf certificate and intermediates.
OpenSSL 3 and Providers
OpenSSL 3 introduced providers, pluggable implementations of algorithms: default, fips for validated cryptography, and legacy for old algorithms such as MD4 or RC4 that are disabled by default. Release lines matter: 3.0 LTS reached end of life in 2026, and 3.5 is the current long-term support release, adding post-quantum algorithms such as ML-KEM and ML-DSA. Alternatives with similar APIs include BoringSSL, AWS-LC, and LibreSSL.
Common Tasks
Generate Keys and a CSR
Create a Short-Lived Self-Signed Certificate for Local Use
For development across many projects, a local development CA tool such as mkcert is more convenient; never use self-signed certificates in production.
Inspect and Verify
Confirm a Key Matches a Certificate
Convert Formats
Test Protocols and Features
Best Practices
Protect Private Keys
Generate keys where they will be used, restrict file permissions, store them in a secrets manager or HSM where possible, and never commit them to repositories or paste them into tickets. See Secrets Management.
Always Include Subject Alternative Names
Modern clients validate hostnames against the SAN extension only. Certificates with just a Common Name fail in browsers and many libraries.
Automate Issuance and Monitor Expiry
Use ACME-based automation for public certificates and cert-manager in Kubernetes, and monitor expiry with checks such as -checkend as a safety net.
Prefer Modern Algorithms
Use EC P-256 or Ed25519 keys (or RSA 3072+ for compatibility), TLS 1.2 and 1.3 only, and SHA-256 or stronger signatures. See Cryptographic Failures.
Common Mistakes
Serving Without the Intermediate Chain
Forgetting SNI When Debugging
Using openssl enc for Real Data Protection
FAQ
What is OpenSSL used for?
As a library, it provides TLS and cryptography for servers, clients, and runtimes. As a command-line tool, it generates keys and CSRs, inspects and converts certificates, verifies chains, and debugs TLS connections.
How do I check a certificate's expiry date?
For a file, run openssl x509 -in cert.pem -noout -enddate. For a live server, pipe openssl s_client -connect host:443 -servername host into the same command, or use -checkend to test against a time window.
Why does my certificate chain fail to verify?
Usually the server is not sending intermediate certificates, the client lacks the root, or the certificate has expired or does not match the hostname. openssl s_client -showcerts and openssl verify show which link is missing.
What is the difference between PEM and PKCS#12?
PEM is a text encoding that can hold keys and certificates as separate objects. PKCS#12 is a password-protected binary bundle containing a private key, certificate, and chain together, commonly used by Java and Windows.
Which OpenSSL version should I use?
A supported 3.x release from your operating system or distribution, preferably the current long-term support line. OpenSSL 1.1.1 is end of life and should be replaced.
Related Topics
- HTTPS and TLS — How TLS protects connections
- Encryption — Cryptographic building blocks
- cert-manager — Automated certificates in Kubernetes
- Nginx TLS — Configuring TLS on a web server
- Cryptographic Failures — Common cryptography mistakes
- Secrets Management — Storing private keys safely