OpenSSL — HTTPS & Certificates from CLI
Manage SSL certificates, inspect TLS connections, and generate cryptographic keys:
Local HTTPS Setup for Next.js:
```cmd
REM Generate self-signed cert
openssl req -x509 -newkey rsa:2048 ^
-keyout localhost-key.pem ^
-out localhost-cert.pem ^
-days 365 -nodes ^
-subj "/CN=localhost"
`
In Next.js dev server:
```javascript
// next.config.js
const https = require('https')
const fs = require('fs')
module.exports = {
server: {
https: {
key: fs.readFileSync('localhost-key.pem'),
cert: fs.readFileSync('localhost-cert.pem')
}
}
}
`
Check Certificate Expiry:
```cmd
openssl s_client -connect your-site.com:443 2>/dev/null | openssl x509 -noout -enddate
`
Generate Random Secret Key:
```cmd
openssl rand -base64 32
`
Use this for JWT_SECRET, API keys, and session secrets in your .env! 🔐
