Vous êtes sur la page 1sur 5

4/25/2019 Apache: CSR & SSL Installation (OpenSSL)


Apache: Create CSR & Install SSL Certicate (OpenSSL)

Create a CSR using OpenSSL & install your SSL certicate on your Apache server
Use the instructions on this page to use OpenSSL to create your certicate signing request (CSR) and then to install your
SSL certicate on your Apache server.
Restart Note: After you've installed your SSL/TLS certicate and congured the server to use it, you must restart your Apache instance.

For Ubuntu instructions, see Ubuntu Server with Apache2: Create CSR & Install SSL Certicate (OpenSSL) (/csr-ssl-installation/ubuntu-server-with-
apache2-openssl.htm). For other OS/platform instructions, see Create a CSR (Certicate Signing Request) (/csr-creation.htm).

You can use these instructions to create OpenSSL CSRs and install all types of DigiCert SSL certicates on your Apache server: Standard SSL, EV SSL,
Multi-Domain SSL, EV Multi-Domain SSL, and Wildcard SSL.

I. To create your certicate signing request (CSR), see Apache: Creating Your CSR with OpenSSL.

Para un tutorial en español visite la página Apache Crear CSR (/es/creacion-de-sfc-apache.htm).

II. To install your SSL certicate, see Apache: Installing & Conguring Your SSL Certicate.

Visite nuestras instrucciones en español para Apache Instalar Certicado SSL (/es/instalar-certicado-ssl-apache.htm).

I. Apache: Creating Your CSR with OpenSSL

Use the instructions in this section to create your own shell commands to generate your Apache CSR with OpenSSL.

Recommended:  Save yourself some time. Use the DigiCert OpenSSL CSR Wizard (/easy-csr/openssl.htm) to generate an OpenSSL command to
create your Apache CSR. Just ll out the form, click Generate, and then paste your customized OpenSSL command into your terminal.


How to Generate a CSR for Apache Using OpenSSL

If you prefer to build your own shell commands to generate your Apache CSR, follow the instructions below.

1. Log in to your server via your terminal client (ssh).

2. Run Command

At the prompt, type the following command:

Note: Make sure to replace server with the name of your server.

openssl req –new –newkey rsa:2048 –nodes –keyout server.key –out server.csr

https://www.digicert.com/csr-ssl-installation/apache-openssl.htm 1/5
4/25/2019 Apache: CSR & SSL Installation (OpenSSL)

3. Generate Files

a. You've now started the process for generating the following two les:

Private-Key File: Used to generate the CSR and later to secure and verify connections using the certi cate.

Certi cate Signing Request (CSR) le: Used to order your SSL certi cate and later to encrypt messages that only its
corresponding private key can decrypt.

b. When prompted for the Common Name (domain name), type the fully qualied domain (FQDN) for the site that you are going
to secure.

Note: If you're generating an Apache CSR for a Wildcard certicate (/wildcard-ssl-certicates/), make sure your common
name starts with an asterisk (e.g., *.example.com).

c. When prompted, type your organizational information, beginning with your geographic information.

Note: You may have already set up default information.

d. Now, your OpenSSL .csr le is created.

4. Order Your SSL/TLS Certicate

a. Open the .csr le you created with a text editor.

b. Copy the text, including the -----BEGIN NEW CERTIFICATE REQUEST----- and -----END NEW CERTIFICATE REQUEST----- tags, and
paste it in to the DigiCert order form (/order/order-1.php?prod=1).

5. Save Private Key

Save (back up) the generated .key le. You need it later to install your SSL certicate.

6. Install Certicate

After you've received your SSL certicate from DigiCert, you can install it on your server.

II. Apache: Installing & Conguring Your SSL Certicate

If you still need to create a certicate signing request (CSR) and order your certicate, see Apache: Creating Your CSR with OpenSSL.

After we've validated and issued your SSL certicate, you can install it on your Apache server (where the CSR was generated) and congure the
server to use the certicate.

How to Install and Con gure Your SSL Certi cate on Your Apache Server
1. Copy the certicate les to your server.

a. Log in to your DigiCert account (/account/) and download the intermediate (DigiCertCA.crt) and your primary certicate
(your_domain_name.crt) les.

b. Copy these les, along with the .key le you generated when creating the CSR, to the directory on the server where you keep
your certicate and key les.

Note: Make them readable by root only to increase security.

2. Find the Apache conguration le (httpd.conf) you need to edit.

The location and name of the conguration le can vary from server to server—especially if you're using a special interface to manage
your server conguration.

Apache's main conguration le is typically named httpd.conf or apache2.conf. Possible locations for this le include
/etc/httpd/ or /etc/apache2/. For a comprehensive listing of default installation layouts for Apache HTTPD on various
operating systems and distributions, see Httpd Wiki - DistrosDefaultLayout (http://wiki.apache.org/httpd/DistrosDefaultLayout).

https://www.digicert.com/csr-ssl-installation/apache-openssl.htm 2/5
4/25/2019 Apache: CSR & SSL Installation (OpenSSL)
Often, theSSLPKIIoTSolutionsAboutSupport
SSL certicate conguration is located in a <VirtualHost> block in a different conguration le. The conguration
(/) may be under a directory like /etc/httpd/vhosts.d/, /etc/httpd/sites/, or in a le called httpd-ssl.conf.

One way to locate the SSL Conguration on Linux distributions is to search using grep, as shown in the example below.

Run the following command:

grep -i -r "SSLCertificateFile" /etc/httpd/

Note: Make sure to replace /etc/httpd/ with the base directory for your Apache installation.

3. Identify the SSL <VirtualHost> block you need to congure.

If your site needs to be accessible through both secure (https) and non-secure (http) connections, you need a virtual host for each type of
connection. Make a copy of the existing non-secure virtual host and congure it for SSL as described in step 4.

If your site only needs to be accessed securely, congure the existing virtual host for SSL as described in step 4.

4. Congure the <VirtualHost> block for the SSL-enabled site

a. Below is a very simple example of a virtual host congured for SSL. The parts listed in blue are the parts you must add for SSL

DocumentRoot /var/www/html2
ServerName www.yourdomain.com
SSLEngine on
SSLCertificateFile /path/to/your_domain_name.crt
SSLCertificateKeyFile /path/to/your_private.key
SSLCertificateChainFile /path/to/DigiCertCA.crt

b. Make sure to adjust the le names to match your certicate les.

SSLCerticateFile is your DigiCert certicate le (e.g., your_domain_name.crt).

SSLCerticateKeyFile is the .key le generated when you created the CSR (e.g., your_private.key).

SSLCerticateChainFile is the DigiCert intermediate certicate le (e.g., DigiCertCA.crt)

Note: If the SSLCerticateChainFile directive does not work, try using the SSLCACerticateFile directive instead.

5. Test your Apache conguration le before restarting.

As a best practice, check your Apache conguration le for any errors before restarting Apache.

Caution: Apache won't start again if your conguration les have syntax errors.

Run the following command to test your conguration le (on some systems, it's apache2ctl):

apachectl configtest

6. Restart Apache.

You can use apachectl commands to stop and start Apache with SSL support.

apachectl stop
apachectl start

Restart Notes:
If Apache doesn't restart with SSL support, try using apachectl startssl instead of apachectl start. If SSL support only loads with
apachectl startssl, we recommend you adjust the apache startup conguration to include SSL support in the regular apachectl start
command. Otherwise, your server may require to manually restart Apache using apachectl startssl in the event of a server reboot. This
usually involves removing the <IfDene SSL> and </IfDene> tags that enclose your SSL conguration.

https://www.digicert.com/csr-ssl-installation/apache-openssl.htm 3/5
4/25/2019 Apache: CSR & SSL Installation (OpenSSL)
7. Congratulations! You've successfully installed your SSL certicate.
Testing Your SSL/TLS Certicate Installation
1. Browser Test

a. For best results, make sure to close your web browser rst and then re-launch it.

b. Visit your site with the secure https URL (i.e., go to https://www.example.com not http://www.example.com).

c. Be sure to test your site with more than just Internet Explorer. IE downloads missing intermediate certicates; whereas, other
browsers give an error if all the certicates in the certicate chain aren't installed properly.

2. DigiCert® SSL Installation Diagnostic Tool

If your site's publicly accessible, use our Server Certicate Tester (/help/) to test your SSL/TLS certicate installation; it detects common
installation problems.

1. If your web site's publicly accessible, our SSL Certicate Tester (/help/) tool can help you diagnose common problems.

2. If you receive a "not trusted" warning, view the certicate details to see if it's the certicate you expect. Check the Subject, Issuer, and
Valid To elds.

a. If it's the certicate you expect and the SSL certicate (/ssl-certicate/) is issued by DigiCert, then your SSLCerticateChainFile is
not congured correctly.

b. If you don't see the certicate you expect, then you may have another SSL <VirtualHost> block before the one you recently

Name based virtual hosts aren't possible with https unless you use the same certicate for all virtual hosts (e.g., a Wildcard or a
Multi-Domain SSL certicate).

This is not an Apache limitation, but an SSL protocol limitation. Apache must send a certicate during the SSL handshake before
it receives the HTTP request that contains the Host header. Therefore, Apache always sends the SSLCerticateFile from the
rst <VirtualHost> block that matches the IP and port of the request.

3. For help moving your certicates to additional servers or across server platforms, see our OpenSSL export instructions (/ssl-

4. If you need to disable SSL version 2 compatibility in order to meet PCI Compliance requirements (/news/DigiCert_PCI_White_Paper.pdf),
add the following directive to your Apache conguration le:


If the directive already exists, you may need to modify it to disable SSL version 2.

5. For instructions on how to x common errors and for additional tips, see Troubleshooting Apache SSL Certicate Errors (/ssl-

Apache Server Conguration

For information about Apache server congurations that can strengthen your SSL environment, see the following resources:

For Instructions on disabling the SSL v3 protocol, see Apache: Disabling the SSL v3 Protocol (/ssl-support/apache-disabling-ssl-v3.htm).

For information about enabling perfect forward secrecy, see Enabling Perfect Forward Secrecy (/ssl-support/ssl-enabling-perfect-

https://www.digicert.com/csr-ssl-installation/apache-openssl.htm 4/5
4/25/2019 Apache: CSR & SSL Installation (OpenSSL)
SSLPKIIoTSolutionsAboutSupport SSL SUPPORT
Generate CSR Creation (/csr-creation.htm) Standard SSL (/standard-ssl-certi cates/) Secure Sockets Layer (/ssl/)
Apache SSL Installation (/csr-ssl- Standard SSL Comparison (/welcome/ssl-plus- openssl csr (/easy-csr/openssl.htm)
installation/apache- compared.htm)
exchange certi cate signing request (/easy-
openssl.htm#ssl_certi cate_install)
Wildcard SSL (/wildcard-ssl-certi cates/) csr/exchange2007.htm)
OpenSSL CSR Wizard (/easy-csr/openssl.htm)
EV Certi cates (/ev-ssl-certi cation/) Apache SSL (/apache-ssl-authentication.htm)

Certi cado Wildcard SSL (/es/certi cados- Certi cado SSL Para Apache (/es/certi cado-
wildcard-ssl.htm) ssl-para-apache.htm)

(https://www.digicert.com/) © 2003-2019 DigiCert® Inc • SSL Certi cate Authority • All Rights Reserved | All trademarks displayed on this web site are the exclusive property of the respective holder


(https://cert.webtrust.org/ViewSeal? (https://cert.webtrust.org/ViewSeal? (https://cert.webtrust.org/ViewSeal?
id=2230) id=2229) id=2228) (//privacy.truste.com/privacy-
Terms of Use (https://www.digicert.com/security-terms/) Money Back Guarantee (/digital-certi cate-guarantee.htm) Privacy Policyb716-

policy/) Cookie Policy (https://www.digicert.com/digicert-cookie-policy/) ed0255cc58c1)

Legal Repository (https://www.digicert.com/legal-repository/) Newsroom

https://www.digicert.com/csr-ssl-installation/apache-openssl.htm 5/5