Webサーバー通信暗号化(Apache + mod_SSL) |
# rpm -aq | grep mod_ssl ← mod_sslがインストールされているか確認 mod_ssl-2.8.22-0vl2 無い場合は # apt-get install mod_ssl ← インストール # cd /usr/share/ssl/certs ← 移動 # make server.key ← サーバー用秘密鍵作成 umask 77 ; \ /usr/bin/openssl genrsa -des3 1024 > server.key Generating RSA private key, 1024 bit long modulus .....................................................................................++++++ .......++++++ e is 65537 (0x10001) Enter pass phrase: ← 任意のパスワードを入力(表示はされません) Verifying - Enter pass phrase: ← 再度パスワード確認 Webサーバー起動時にパスワードを要求されないようにするため サーバー用秘密鍵からパスワードを削除します。 # openssl rsa -in server.key -out server.key ← サーバー用秘密鍵からパスワード削除 Enter pass phrase for server.key: ← 秘密鍵作成時のパスワードを入力 writing RSA key # make server.csr ← サーバー用公開鍵作成 umask 77 ; \ /usr/bin/openssl req -new -key server.key -out server.csr 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]:Nara ←都道府県を入力 Locality Name (eg, city) []:Katuragi ← 市区町村を入力 Organization Name (eg, company) [Internet Widgits Pty Ltd]:xxxxx.com ← サーバー名を入力(何でもOK) Organizational Unit Name (eg, section) []: ← 部署(空EnterでもOK) Common Name (eg, YOUR name) []:xxxxxx.com ← ホスト名を入力 Email Address []:info@xxxxxx.com ← 管理者メールアドレス Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ← 空EnterでOK An optional company name []: ← 空EnterでOK # openssl x509 -in server.csr -out server.pem -req -signkey server.key -days 365 ← サーバー用証明書作成 Signature ok subject=/C=JP/ST=Nara/L=Katuragi/O=xxxxx.com/CN=xxxxxx.com/emailAddress=info@xxxxxx.com Getting Private key # chmod 400 server.* ← rootのみ参照できるようにパーミッション変更 # mv server.* /etc/httpd/conf ← サーバー用鍵ペア、証明書をApache設定ファイル収容ディレクトリへ移動 |
Apacheの設定 |
# vi /etc/httpd/conf/httpd.conf ← 編集 i キー(入力モード) 〜1100行目付近〜 SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt ↓ SSLCertificateFile /etc/httpd/conf/server.pem ← サーバー用証明書に変更 SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key ↓ SSLCertificateKeyFile /etc/httpd/conf/server.key ← サーバー用秘密鍵に変更 編集したら Esc キー(コマンドモード):wqで保存 # /etc/init.d/httpd restart ← 再起動 httpdを停止中: [ OK ] httpdを起動中: [ OK ] |
動作確認 |
まず、ルーターの設定でポート443番を空けます。
次にここのサイトで443番ポートがきちんと空いているかチェックします。
ポートが開いているのを確認できたら
https://IPアドレス(またはドメイン名)にてアクセスします。
httpの後の「s」を忘れずに!!
アクセスしたらこのような警告ウィンドウが表示されますので、
「はい」をクリックするとサイトが表示されると思います。
また、証明書のインストールを行えば、次回から警告ウィンドウは表示されなくなります。
Copyright c Vine Linuxで自宅サーバー. 2004 All Rights Reserved.