This article explains how to generate a CSR (Certificate Signing Request) file using OpenSSL to request an SSL certificate on a Linux dedicated server running Apache.
Servers with cPanel/WHM: You can also generate the CSR from WHM → SSL/TLS → Generate an SSL Certificate and Signing Request, without using the command line. This article describes the manual method with OpenSSL.
Prerequisites
- SSH access with the
rootuser to the dedicated server. - OpenSSL installed (it comes pre-installed on most Linux servers).
- The exact domain for which you are requesting the certificate (Common Name).
Step 1 — Verify OpenSSL
If OpenSSL is not installed, install it according to your distribution. On cPanel servers, it is usually located at /usr/bin/openssl.
openssl version
Step 2 — Generate the RSA Private Key
Navigate to the directory where you store your SSL keys. In Apache, the typical path is:
cd /APACHESERVERROOT/conf/ssl.key/
If your server uses a different path, adjust it accordingly (refer to your Apache configuration or your service manual).
Private key with passphrase (more secure at rest):
openssl genrsa -des3 -out DomainName.key 2048
Unencrypted private key (Apache will not prompt for a passphrase on restart):
openssl genrsa -out DomainName.key 2048
Recommendation: Use keys of at least 2048 bits. 1024-bit keys are no longer accepted by most Certificate Authorities.
Step 3 — Generate the CSR
Run this command using the private key from the previous step:
openssl req -new -key DomainName.key -out DomainName.csr
The .csr file is what you submit to the Certificate Authority (CA) to issue the certificate.
Information Requested by OpenSSL
Complete the fields according to the following criteria. Do not use unpermitted special characters: < > ~ ! @ # $ % ^ / \ ( ) ? . , &
| Field | What to Enter |
|---|---|
| Common Name (CN) | Full domain name of the site (e.g., www.mydomain.com). It must match exactly the certificate you are ordering. |
| Organization | Legal name of the company, unabbreviated. |
| Organizational Unit | Department or unit (optional). |
| City / Locality | City where the organization is located. |
| State / Province | Province or state. |
| Country | 2-letter ISO code (e.g., US for the United States). |
For the extra attributes (challenge password, optional company name), leave them blank and press Enter.
Step 4 — Verify the CSR
openssl req -noout -text -in DomainName.csr
Check that the Common Name is the correct domain before submitting the CSR to the CA.
Step 5 — Back Up the Private Key
Make a backup of the .key file generated in step 2 and store it in a secure location.
Critical: If you lose the private key, you will not be able to install the issued certificate and you will have to generate a new CSR and repurchase or reissue the certificate.
To view the contents of the private key:
openssl rsa -noout -text -in DomainName.key
The file starts with -----BEGIN RSA PRIVATE KEY----- and ends with -----END RSA PRIVATE KEY-----.
Installing the Certificate in Apache
Once the CA delivers the certificate (.crt) and, if applicable, the intermediate chain (ca-bundle):
- Copy the certificate and chain into the Apache SSL directory (e.g.,
/APACHESERVERROOT/conf/ssl.crt/). - Replace or place the private key (
.key) in/APACHESERVERROOT/conf/ssl.key/, using the exact key used to generate the CSR. - Ensure the Apache virtual host configuration points to the correct files (
SSLCertificateFile,SSLCertificateKeyFile,SSLCertificateChainFile). - Restart Apache to apply the changes:
service httpd restart
On servers with cPanel, you can also use WHM → Restart Services → HTTP Server (Apache).
Note: Do not overwrite the private key with the certificate. They are distinct files: the CA provides the .crt; the .key is the one you generated and must be preserved.
Troubleshooting Common Issues
- CA rejects the CSR: verify Common Name, key size (2048+), and check for disallowed special characters in the submitted details.
- Certificate installed but the site does not load over HTTPS: verify that Apache points to the correct
.crtand.keyfiles and that the service was restarted. - "key does not match" error: the certificate does not match the private key used when generating the CSR; reinstall the matching key pair.
- Different path on your server: on cPanel paths may differ; use WHM → SSL/TLS → Install an SSL Certificate on a Domain if you prefer a graphical interface.
If you need assistance generating the CSR, installing the certificate, or checking the SSL configuration on your dedicated server, open a ticket from the client area or reach out via the website's online chat.
