Openssl Generate Certificate From Existing Key
If you want to convert your website from HTTP to HTTPS, you need to get a SSL certificate from a valid organization like Verisign or Thawte. You can also generate self signed SSL certificate for testing purpose.
In this article, let us review how to generate private key file (server.key), certificate signing request file (server.csr) and webserver certificate file (server.crt) that can be used on Apache server with mod_ssl.
Key, CSR and CRT File Naming Convention
- Reasons for importing keys include wanting to make a backup of a private key (generated keys are non-exportable, for security reasons), or if the private key is provided by an external source. This document will guide you through using the OpenSSL command line tool to generate a key pair which you can then import into a YubiKey.
- How to Generate a Self-Signed Certificate and Private Key using OpenSSL Generating a private key and self-signed certificate can be accomplished in a few simple steps using OpenSSL. We provide here detailed instructions on how to create a private key and self-signed certificate valid for 365 days.
Jul 30, 2018 Generate a Self-Signed Certificate from an Existing Private Key. Use this method if you already have a private key that you would like to generate a self-signed certificate with it. This command creates a self-signed certificate (domain.crt) from an existing private key (domain.key): openssl req -key domain.key -new. Generate a CSR from an Existing Certificate and Private Key. Use this method if you want to renew an existing certificate but you or your CA do not have the original CSR for some reason. It basically saves you the trouble of re-entering the CSR information, as it extracts that information from the existing certificate.
I typically like to name the files with the domain name of the HTTPS URL that will be using this certificate. This makes it easier to identify and maintain.
- Instead of server.key, I use www.thegeekstuff.com.key
- Instead of server.csr, I use www.thegeekstuff.com.csr
- Instead of server.crt, I use www.thegeekstuff.com.crt
1. Generate Private Key on the Server Running Apache + mod_ssl
First, generate a private key on the Linux server that runs Apache webserver using openssl command as shown below.
The generated private key looks like the following.
2. Generate a Certificate Signing Request (CSR)
Using the key generate above, you should generate a certificate request file (csr) using openssl as shown below.
3. Generate a Self-Signed SSL Certificate
For testing purpose, you can generate a self-signed SSL certificate that is valid for 1 year using openssl command as shown below.
You can use this method to generate Apache SSL Key, CSR and CRT file in most of the Linux, Unix systems including Ubuntu, Debian, CentOS, Fedora and Red Hat.
4. Get a Valid Trial SSL Certificate (Optional)
Openssl Generate Key From Csr
Instead of signing it youself, you can also generate a valid trial SSL certificate from thawte. i.e Before spending the money on purchasing a certificate, you can also get a valid fully functional 21 day trial SSL certificates from Thawte. Once this valid certificate works, you can either decide to purchase it from Thawte or any other SSL signing organization.
This step is optional and not really required. For testing purpose, you can always use the self-signed certificate that was generated from the above step.
Go to Thwate trial certificate request page and do the following:
- Select “SSL Web Server Certificate (All servers)” under the “select your trial certificate”.
- Do not check the PKCS #7 check-box under the “configure certificate”
- Copy/Paste the *.csr file that you generate above in the textbox under “certificate signing request (CSR)”
- Click on next at the bottom, which will give you a 21-day free trial certificate.
Copy/Paste the trial certificate to the www.thegeekstuff.com.crt file as shown below.
If you enjoyed this article, you might also like.
Next post: Google Chrome OS – Beginning of End of Microsoft?
Previous post: Blog Makeover: New Thesis Theme In Action
One of the most versatile SSL tools is OpenSSL which is an open source implementation of the SSL protocol. There are versions of OpenSSL for nearly every platform, including Windows, Linux, and Mac OS X. OpenSSL is commonly used to create the CSR and private key for many different platforms, including Apache. However, it also has hundreds of different functions that allow you to view the details of a CSR or certificate, compare an MD5 hash of the certificate and private key (to make sure they match), verify that a certificate is installed properly on any website, and convert the certificate to a different format. A compiled version of OpenSSL for Windows can be found here.
If you don't want to bother with OpenSSL, you can do many of the same things with our SSL Certificate Tools. Below, we have listed the most common OpenSSL commands and their usage:
General OpenSSL Commands
These commands allow you to generate CSRs, Certificates, Private Keys and do other miscellaneous tasks.
- Generate a new private key and Certificate Signing Request
- Generate a self-signed certificate (see How to Create and Install an Apache Self Signed Certificate for more info)
- Generate a certificate signing request (CSR) for an existing private key
- Generate a certificate signing request based on an existing certificate
- Remove a passphrase from a private key
Checking Using OpenSSL
If you need to check the information within a Certificate, CSR or Private Key, use these commands. Gta iv key generator download. You can also check CSRs and check certificates using our online tools.
- Check a Certificate Signing Request (CSR)
- Check a private key
- Check a certificate
- Check a PKCS#12 file (.pfx or .p12)
Debugging Using OpenSSL
If you are receiving an error that the private doesn't match the certificate or that a certificate that you installed to a site is not trusted, try one of these commands. If you are trying to verify that an SSL certificate is installed correctly, be sure to check out the SSL Checker.
- Check an MD5 hash of the public key to ensure that it matches with what is in a CSR or private key
- Check an SSL connection. All the certificates (including Intermediates) should be displayed
Converting Using OpenSSL
These commands allow you to convert certificates and keys to different formats to make them compatible with specific types of servers or software. For example, you can convert a normal PEM file that would work with Apache to a PFX (PKCS#12) file and use it with Tomcat or IIS. Use our SSL Converter to convert certificates without messing with OpenSSL.
- Convert a DER file (.crt .cer .der) to PEM
- Convert a PEM file to DER
- Convert a PKCS#12 file (.pfx .p12) containing a private key and certificates to PEM
You can add -nocerts to only output the private key or add -nokeys to only output the certificates.
- Convert a PEM certificate file and a private key to PKCS#12 (.pfx .p12)
Openssl Generate Certificate From Existing Key Pdf
Originally posted on Sun Jan 13, 2008