web-dev-qa-db-fra.com

Comment faire et installer un certificat auto-signé dans Apache Ubuntu 16.04?

Je souhaite installer étape par étape un certificat SSL auto-signé sur le serveur Web Apache.

3
Kartik Agarwal

Suivez la commande ci-dessous pour SSL dans Ubuntu 16.04

Sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/Apache-selfsigned.key -out /etc/ssl/certs/Apache-selfsigned.crt

Sortie:

Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:New York
Locality Name (eg, city) []:New York City
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Bouncy Castles, Inc.
Organizational Unit Name (eg, section) []:Ministry of Water Slides
Common Name (e.g. server FQDN or YOUR name) []:server_IP_address
Email Address []:admin@your_domain.com
Sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

Modifiez le fichier d'hôte virtuel SSL Apache par défaut:

Sudo cp /etc/Apache2/sites-available/default-ssl.conf /etc/Apache2/sites-available/default-ssl.conf.bak
$ cat /etc/Apache2/sites-available/default-ssl.conf

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin webmaster@localhost

                DocumentRoot /var/www/html

                ErrorLog ${Apache_LOG_DIR}/error.log
                CustomLog ${Apache_LOG_DIR}/access.log combined

                SSLEngine on

                SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
                SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>

                # BrowserMatch "MSIE [2-6]" \
                #               nokeepalive ssl-unclean-shutdown \
                #               downgrade-1.0 force-response-1.0

        </VirtualHost>
</IfModule>
2
shivraj singh