OpenSSL cookbook

Twelve pages of task-based OpenSSL 3.x recipes. Each task gives the command, real sample output and a short note on flags, version differences and pitfalls.

The cookbook is a set of working OpenSSL commands organized by task. Find the task you need, copy the command, compare your output with the sample, and read the note for the flags that matter. For the background behind a command, follow the links to the Learn articles.

How to use these pages

Each page has 8 to 15 tasks with the same layout: a ## heading that names the task, a one-line answer, the command in a bash block, sample output in a text block and a note on options and pitfalls. File names are consistent across pages: example.com.key for a private key, example.com.crt for the certificate, chain.pem for intermediates and fullchain.pem for certificate plus chain.

Check which OpenSSL you are running before you start:

openssl version
OpenSSL 3.6.1 27 Jan 2026 (Library: OpenSSL 3.6.1 27 Jan 2026)

Version differences that change results

Change Since What it affects
PKCS#12 export defaults to AES-256-CBC, PBKDF2 and an HMAC-SHA256 MAC; RC2/3DES/SHA-1 need -legacy 3.0 PKCS#12, format conversion
-noenc replaces the deprecated -nodes 3.0 Keys, CSRs, self-signed
TLS 1.0/1.1 blocked at the default security level; testing them needs @SECLEVEL=0 3.0 Ciphers and protocols
-copy_extensions for x509 and req 3.0 Private CA
ML-KEM, ML-DSA and SLH-DSA built in; default TLS key shares include X25519MLKEM768 3.5 Keys, test connections

Safety

Run key-generation commands on a machine you control and keep private keys out of version control. Never paste a production private key into a website. Tools on ssl.sh that handle keys run in the browser, but the safest key is one that never leaves the server it belongs to.

Keys, CSRs and certificates

Formats and PKCS#12

Verification and testing

Private CA and troubleshooting

FAQ

Which OpenSSL version do these commands need?

OpenSSL 3.0 or newer. Commands that need a later release are marked, for example ML-KEM and ML-DSA keys, which need 3.5 or newer. Sample output was captured with OpenSSL 3.6.1.

Why does a command fail on my Mac?

macOS ships LibreSSL as /usr/bin/openssl, which lacks several OpenSSL 3.x options. Install OpenSSL 3 (for example with Homebrew) and call it by its full path, or put it first on your PATH.

Is there a tool that builds these commands for me?

Yes. The OpenSSL command generator builds the common commands from a form, and the SSL converter converts formats in your browser.