# Step 1: Generate a Private Key
openssl genrsa -out myprivate.key 2048
# Step 2: Create a Certificate Signing Request (CSR)
openssl req -new -key myprivate.key -out myrequest.csr
# Step 3: Generate a Self-Signed Certificate
openssl x509 -req -days 365 -in myrequest.csr -signkey myprivate.key -out mycertificate.crt
# Step 4: View the Self-Signed Certificate
openssl x509 -in mycertificate.crt -text -noout
Explanation:
- Generate a Private Key: Creates a 2048-bit RSA private key.
- Create a Certificate Signing Request (CSR): Prompts for information such as Country, State, Organization, etc.
- Generate a Self-Signed Certificate: Signs the certificate using the private key and sets its validity for 365 days.
- View the Self-Signed Certificate: Displays the certificate details in a readable format.