概要:SSLとはサーバ⇔クライアント間の通信を暗号化し安全に送受信できるプロトコルである。ApacheをSSL対応にするために、mod_sslをインストールする。
前提:

1. mod_sslインストール

# yum -y install mod_ssl ← mod_sslインストール

2. WebサーバーSSL設定

  1. ) サーバー用秘密鍵・証明書作成
    # cd /etc/pki/tls/certs/ ← ディレクトリ移動
    # sed -i 's/365/3650/g' Makefile ← サーバー用証明書有効期限を1年から10年に変更
    # make server.crt ← サーバー用秘密鍵・証明書作成
    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: ← rootのパスワードを入力
    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) [GB]:JP ← JP(日本)を入力
    State or Province Name (full name) [Berkshire]:都道府県名 ← 都道府県名を入力
    Locality Name (eg, city) [Newbury]:市区町村名 ← 市区町村名を入力
    Organization Name (eg, company) [My Company Ltd]:組織名 ← 組織名(なんでもいい)
    Organizational Unit Name (eg, section) []: ← 空ENTER
    Common Name (eg, your name or your server's hostname) []:ホスト名 ← サーバーのホスト名を入力
    Email Address []:centos@xxxxx.com ← メールアドレスを入力
    
  2. ) サーバー用秘密鍵のパスワード削除 Webサーバー起動時にパスワードを要求されないようにするため、サーバー用秘密鍵からパスワード削除する。
    # openssl rsa -in server.key -out server.key
    Enter pass phrase for server.key: ← サーバー用秘密鍵入力
    writing RSA key
    
  3. ) SSL設定
    # vi /etc/httpd/conf.d/ssl.conf ← ApacheSSL設定ファイル編集
    ※CentOS5の場合
    SSLCertificateFile /etc/pki/tls/certs/server.crt ← サーバー用証明書を指定
    
    SSLCertificateKeyFile /etc/pki/tls/certs/server.key ← サーバー用秘密鍵を指定
    
    #  General setup for the virtual host, inherited from global configuration
    #DocumentRoot "/var/www/html" ← #を削除(コメント解除)
      
    DocumentRoot "/var/www/html"
    

3. Apache設定反映

# /etc/rc.d/init.d/httpd reload ← 設定再読込み
httpd を再読み込み中:                                      [  OK  ]

または、

# /etc/rc.d/init.d/httpd restart ← Apache再起動
httpd を停止中:                                            [  OK  ]
httpd を起動中:                                            [  OK  ]

4. ポート443番のOPEN
ネットワーク上でTCP/IPの443番ポートが開いていること。(サーバー、クライアント、ルーターなどのファイヤーウォールやセキュリティー設定で OPENされていること。)

5. WebサーバーSSL確認
https://サーバーIPアドレス/にアクセスして「セキュリティの警告」ウィンドウが表示され、"はい"ボタン押下でWebページが表示されればOK
なお、https://サーバーIPアドレス/にアクセスして「セキュリティの警告」ウィンドウが 表示されたら、"証明書の表示"⇒"証明書のインストール"を行えば、以降、「セキュリティの警告」ウィンドウは表示されなくなる。


最終更新のRSS
Last-modified: 2014-03-11 (火) 01:59:57 (3697d)