Question: I need SSL for local development. How do I generate a certificate quickly?
Try: openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes -subj '/CN=localhost'
Info: Generates a 4096-bit RSA self-signed certificate valid for 1 year. The -x509 option creates a self-signed certificate, while -subj supplies the certificate subject without interactive prompts.
Examples:
- $
openssl req -x509 -newkey ec:<(openssl ecparam -name prime256v1) -keyout key.pem -out cert.pem -nodes -days 365# Generate an ECDSA certificate - $
openssl s_client -connect example.com:443 -showcerts# View a remote server's certificate chain - $
certbot certonly --standalone -d example.com# Request a Let's Encrypt certificate
Note: Self-signed certificates are suitable for local development and testing but normally trigger browser trust warnings. For public production websites, use a certificate issued by a trusted certificate authority such as Let's Encrypt. The -nodes option creates the private key without encryption, so protect key.pem carefully.
Leave a Reply