Here are some common OpenSSL commands used for various cryptographic tasks:
1. Generate a Private Key
openssl genrsa -out private.key 2048
2. Generate a Public Key from a Private Key
openssl rsa -in private.key -pubout -out public.key
3. Create a Certificate Signing Request (CSR)
openssl req -new -key private.key -out request.csr
4. Generate a Self-Signed Certificate
openssl req -x509 -new -nodes -key private.key -sha256 -days 365 -out certificate.crt
5. View Certificate Details
openssl x509 -in certificate.crt -text -noout
6. Convert Certificate Formats
- PEM to DER:
openssl x509 -in certificate.crt -outform DER -out certificate.der - DER to PEM:
openssl x509 -in certificate.der -inform DER -outform PEM -out certificate.pem
7. Check a Certificate's Validity
openssl verify -CAfile ca.crt certificate.crt
8. Encrypt a File
openssl enc -aes-256-cbc -salt -in plaintext.txt -out encrypted.txt
9. Decrypt a File
openssl enc -d -aes-256-cbc -in encrypted.txt -out decrypted.txt
10. Create a Certificate Authority (CA) Certificate
openssl req -x509 -new -nodes -key private.key -sha256 -days 365 -out ca.crt
Summary:
These commands cover a range of common tasks in OpenSSL, including key generation, certificate management, encryption, and format conversion. If you have further questions or need specific examples, feel free to ask!
