web-dev-qa-db-ja.com

Apache ubuntu 16.04で自己署名証明書を作成およびインストールする方法

Apache Webサーバーに自己署名SSL証明書を段階的にインストールしたい。

3
Kartik Agarwal

Ubuntu 16.04でのSSLの以下のコマンドに従ってください

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

出力:

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

デフォルトのApache SSL仮想ホストファイルを変更します。

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