1 views
実現する機能
ユーザ名やパスワード等の機密情報をWebブラウザから入力する場合、盗聴される恐れがあるため、Webサーバー間の通信内容を暗号化するのが一般的です。ここでは、Webサーバーにmod_sslを導入して、URLをhttp://〜ではなく、https://〜でアクセスすることによって、Webサーバー間の通信内容を暗号化できるようにします。自サイトでもメールサーバーやサーバーの管理ツールは暗号化された情報でやりとりをしなくてはなりませんので、導入の必要に迫られ実施しました。
mod_sslの導入手順
(1)mod_sslインストール
[root@ufuso ~]# yum -y install mod_ssl ← mod_sslインストール Installed: mod_ssl.x86_64 1:2.2.15-15.el6.centos.1 Complete! [root@ufuso ~]# yum -y install make ← 秘密鍵作成ソフトのインストール Setting up Install Process Package 1:make-3.81-20.el6.x86_64 already installed and latest version Nothing to do ← すでにインストール済み |
(2)サーバー用秘密鍵・証明書作成
[root@ufuso ~]# cd /etc/pki/tls/certs/ ← ディレクトリ移動 [root@ufuso certs]# sed -i 's/365/3650/g' Makefile ← サーバー用証明書有効期限を1年から 10年に変更 [root@ufuso certs]# make server.crt ← サーバー用秘密鍵の作成 umask 77 ; /usr/bin/openssl genrsa -aes128 2048 > server.key Generating RSA private key, 2048 bit long modulus ...........+++ .................................+++ e is 65537 (0x10001) Enter pass phrase: ← パスワードの作成入力※表示はされない Verifying - Enter pass phrase: ← 作成したパスワードを再入力※表示はされない umask 77 ; /usr/bin/openssl genrsa -aes128 2048 > server.key Generating RSA private key, 2048 bit long modulus ..........................................+++ ..........................+++ e is 65537 (0x10001) Enter pass phrase: Verifying - Enter pass phrase: umask 77 ; /usr/bin/openssl req -utf8 -new -key server.key -x509 -days 3650 -out server.crt -set_serial 0 Enter pass phrase for server.key: ← 作成したパスワードを再入力※表示はされない 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) [XX]:JP ← 国名応答 State or Province Name (full name) []:Okinawa ← 都道府県名応答 Locality Name (eg, city) [Default City]:Naha ← 市区町村名応答 Organization Name (eg, company) [Default Company Ltd]:ShikakiraCS ← 組織名が無ければドメイン名でも入力 Organizational Unit Name (eg, section) []: ← 空のままエンター・キーを押す Common Name (eg, your name or your server's hostname) []:ufuso.dip.jp ← ホストネーム=ドメイン名 Email Address []:webmaster@ufuso.dip.jp ← 管理者のメルアド [root@ufuso certs]# openssl rsa -in server.key -out server.key ← サーバー用秘密鍵からパスワード削除 Enter pass phrase for server.key: ← 上記で応答したパスワードを応答※表示はされない writing RSA key [root@ufuso certs]# chmod 400 server.* ← アクセス不可設定 |
※パスワードを削除するのは、Webサーバー起動時にパスワードを要求されないようにするため
(3)SSL設定
[root@ufuso certs]# vi /etc/httpd/conf.d/ssl.conf ← ApacheSSL設定ファイル編集 # General setup for the virtual host, inherited from global configuration DocumentRoot "/var/www/html" ← #を削除(コメント解除) ServerName ufuso.dip.jp:443 ← #を削除(コメント解除)してホスト名を入力 # Server Certificate: # Point SSLCertificateFile at a PEM encoded certificate. If # the certificate is encrypted, then you will be prompted for a # pass phrase. Note that a kill -HUP will prompt again. A new # certificate can be generated using the genkey(1) command. #SSLCertificateFile /etc/pki/tls/certs/localhost.crt ← #を付けて SSLCertificateFile /etc/pki/tls/certs/server.crt← サーバー用証明書を指定 # Server Private Key: # If the key is not combined with the certificate, use this # directive to point at the key file. Keep in mind that if # you've both a RSA and a DSA private key you can configure # both in parallel (to also allow the use of DSA ciphers, etc.) #SSLCertificateKeyFile /etc/pki/tls/private/localhost.key ← #を付けて SSLCertificateKeyFile /etc/pki/tls/certs/server.key ← サーバー用秘密鍵を指定 |
(4)Apache設定反映
[root@ufuso certs]# /etc/rc.d/init.d/httpd restart ← Apache再起動 httpd を停止中: [ OK ] httpd を起動中: [ OK ] |
(5)ポート443番のOPEN
ルーター側の設定でポート443番をOPENする。
※ルーターの設定は各ルーターのマニュアルまたはメーカー別ルーターポート開放手順を参照
ポートチェック【外部からポート開放確認】で「host名」にサーバー名(例:ufuso.dip.jp)、「port番号」に443と入力して「ポートチェック」ボタン押下し、「ホスト=ufuso.dip.jp ポート=443 にアクセスできました。」と表示されることを確認。
(6)WebサーバーSSL確認
自サイト(例示ではhttps://ufuso.dip.jp/)にアクセスして「セキュリティの警告」ウィンドウが表示されるので、赤枠をクリックしてWebページが表示されればOK(画面はWindowsXPの場合)
コメントを残す