SSL暗号化通信 Apache2 mod_ssl インストール

この章を始める前に下記の設定が必要です
「暗号化通信 OpenSSL インストール」 「Apache2 インストール」
自己証明書作成
[root@freebsd ~]# cd /etc/ssl/
[root@freebsd certs]# openssl req -new -x509 -days 3650 -key server.key -out server.crt
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:JP ←国名
State or Province Name (full name) [Some-State]:Tokyo ←都道府県名
Locality Name (eg, city) []:Shibuya ←市区町村名
Organization Name (eg, company) [Internet Widgits Pty Ltd]:freebsd.orz ←ホスト名(または会社名)
Organizational Unit Name (eg, section) []: ←空エンター
Common Name (eg, YOUR name) []:www.freebsd.orz ←ホスト名(または管理者名)
Email Address []:postmaster@freebsd.orz ←管理者メールアドレス
[root@freebsd certs]# chmod 400 server.crt
ブラウザインポート用バイナリDER作成
[root@freebsd certs]# openssl x509 -in server.crt -out /usr/local/www/apache22/data/server.der -outform DER
[root@freebsd certs]# cd
httpd.conf編集
[root@freebsd ~]# vi /usr/local/etc/apache22/httpd.conf
# Secure (SSL/TLS) connections
#Include etc/apache22/extra/httpd-ssl.conf
↓
Include etc/apache22/extra/httpd-ssl.conf ←コメント解除
httpd-ssl.conf編集
[root@freebsd ~]# vi /usr/local/etc/apache22/extra/httpd-ssl.conf
ServerName www.example.com:443
↓
ServerName www.freebsd.orz:443 ←変更(サーバー名を記入)

ServerAdmin you@example.com
↓
ServerAdmin postmaster@freebsd.orz ←変更(管理者のメールアドレスを記入)

ErrorLog "/var/log/httpd-error.log"
↓
ErrorLog "/var/log/httpd/ssl_error.log" ←変更(ログ)

TransferLog "/var/log/httpd-access.log"
↓
TransferLog "/var/log/httpd/ssl_access.log" ←変更(ログ)

SSLCertificateFile "/usr/local/etc/apache22/server.crt"
↓
SSLCertificateFile "/etc/ssl/server.crt" ←変更(証明書へのパスを指定)

SSLCertificateKeyFile "/usr/local/etc/apache22/server.key"
↓
SSLCertificateKeyFile "/etc/ssl/server.key" ←変更(秘密鍵へのパスを指定)

CustomLog "/var/log/httpd-ssl_request.log"
↓
CustomLog "/var/log/httpd/ssl_request.log" ←変更(ログ)
Apache再起動
[root@freebsd ~]# /usr/local/etc/rc.d/apache22 restart
ブラウザで自己証明書インポート (http://www.ドメイン名/server.der)

1.「開く」をクリック。

2.「証明書のインストール」をクリック。

3.「次へ」をクリック

4.「証明書をすべて次のストアに配置する」にチェックを入れて「参照」をクリック。

5.「信頼されたルート証明機関」を選択して「OK」をクリック。

6.「次へ」をクリック

7.「完了」をクリック

8.「はい」をクリック

9.「OK」をクリック

10.「OK」をクリック
ブラウザで確認 (https://www.ドメイン名/ にアクセス)

外部に公開する場合
プロトコル(TCP)ポート443番(HTTPS)を開放。
Home PageTop