To create a self-signed SSL/TLS certificate using OpenSSL, follow these steps:
-
Install OpenSSL on your system, if it's not already installed.
-
Open a terminal or command prompt and navigate to the directory where you want to create the certificate.
-
Generate a private key using the following command:
openssl genrsa -des3 -out server.key 2048
This will generate a private key with 2048 bits, protected by a passphrase.
-
Generate a certificate signing request (CSR) using the following command:
openssl req -new -key server.key -out server.csr
This will generate a CSR file, which you will need to sign with your private key.
-
Remove the passphrase from the private key using the following command:
openssl rsa -in server.key -out server.key
This will remove the passphrase from the private key, so you won't need to enter it every time you use the certificate.
-
Generate a self-signed certificate using the following command:
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
This will create a self-signed SSL/TLS certificate that is valid for 365 days.
-
Verify that the certificate was created successfully using the following command:
openssl x509 -in server.crt -text
This will display the details of the certificate, including the subject, issuer, and expiration date.
That's it! You should now have a self-signed SSL/TLS certificate that you can use for testing or development purposes. Note that self-signed certificates are not trusted by default, so you may need to add the certificate to your trusted certificate store or configure your application to accept self-signed certificates.
If you are looking for consultation, fill the Contact Form below.
The present is theirs; the future, for which I really worked, is mine.
Haluk YAMANER
Founder @ Future Software UAE
Founder @ Future Linux
Click here for more about me »