Webサーバー通信暗号化(Apache2 + mod_SSL) |
Vine標準のApache1.3系をアインストールした際にmod_sslもアインストールされます。
ここでは、新にApache2用のmod_sslを導入していきます。
# apt-get install mod_ssl-apache2 ← mod_sslインストール パッケージリストを読みこんでいます... 完了 依存情報ツリーを作成しています... 完了 以下のパッケージが新たにインストールされます: mod_ssl-apache2 アップグレード: 0 個, 新規インストール: 1 個, 削除: 0 個, 保留: 1 個 80.5kB のアーカイブを取得する必要があります。 展開後に 167kB のディスク容量が追加消費されます。 取得:1 http://updates.vinelinux.org 3.2/i386/plus mod_ssl-apache2 1:2.0.55-0vl1.1 [80.5kB] 80.5kB を 0s 秒で取得しました (486kB/s) 変更を適用しています... 準備中... ########################################### [100%] 1:mod_ssl-apache2 ########################################### [100%] 完了 # 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.comt/CN=xxxxx.com/emailAddress=info@xxxxx.com Getting Private key # chmod 400 server.* ← rootのみ参照できるようにパーミッション変更 |
Apacheの設定 |
# vi /etc/apache2/conf.d/ssl.conf ← 設定ファイル編集 <VirtualHost _default_:443> # General setup for the virtual host DocumentRoot "/home/httpd/html" ← 変更 SSLCertificateFile /usr/share/ssl/certs/server.pem ← サーバー用証明書を指定 SSLCertificateKeyFile /usr/share/ssl/certs/server.key ← サーバー用秘密鍵を指定 ログの場所を変更 CustomLog /var/log/apache2/ssl_request_log \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" # /etc/rc.d/init.d/apache2 restart ← 再起動 httpdを停止中: [ OK ] httpdを起動中: [ OK ] |
動作確認 |
まず、ルーターの設定でポート443番を空けます。
次にここのサイトで443番ポートがきちんと空いているかチェックします。
ポートが開いているのを確認できたら
https://IPアドレス(またはドメイン名)にてアクセスします。
httpの後の「s」を忘れずに!!
アクセスしたらこのような警告ウィンドウが表示されますので、
「はい」をクリックするとサイトが表示されると思います。
また、証明書のインストールを行えば、次回から警告ウィンドウは表示されなくなります。
Copyright c Vine Linuxで自宅サーバー. 2004 All Rights Reserved.