ADSLで常時接続 - ホームサーバを作ろう

戻る

Apache+SSL

1. mod_sslのインストール

mod_sslパッケージは、ハードディスクの3番目のパーティションに用意されて います。 以下の手順でインストールできます。

# mount /dev/hda3 /mnt/rpms
# rpm -ivh /mnt/rpms/HOLON/RPMS.all/mod_ssl-2.8.5-1h2.4.ppc.rpm

2. サーバ証明書を生成

# cd /etc/httpd/conf
# make server.key
/usr/bin/openssl genrsa -des3 1024 > server.key
Generating RSA private key, 1024 bit long modulus
.++++++
..................++++++
is 65537 (0x10001)

Enter PEM pass phrase:<適当なパスフェーズを入力>
Verifying password - Enter PEM pass phrase:<確認のため、もう一度入力>

# make server.crt
umask 77 ; \
/usr/bin/openssl req -new -key server.key -x509 -days 365 -out server.crt
Using configuration from /usr/share/ssl/openssl.cnf

Enter PEM pass phrase:<キーを生成するのに使ったパスフェーズを入力>

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]:Miyagi <州、県名などを入力>
Locality Name (eg, city) []:Sendai <都市の名前を入力>
Organization Name (eg, company) [Internet Widgits Pty Ltd]:HOLON Inc. <組織の名前を入力>
Organizational Unit Name (eg, section) []:Linux Support <部署名を入力>
Common Name (eg, your name or your server's hostname) []:test.mydomain.dom <サーバー名を入力>
Email Address []:webmaster@mydomain.dom <管理者のメールアドレスを入力>

ちなみにここで作った証明書は「自己署名証明書」と呼ばれ、Verisignのようなブラウザにroot証明書がインストールされている、第三者機関によって署名された証明書ではないため、ユーザーアクセス時に注意を促すダイアログボックスが表示されます。

3. httpd.conf を修正

SSLを使うように/etc/httpd.confを修正します。 直接該当ファイルを編集しても構いませんが、サンプルの設定ファイルが以下のURLに用意してありますから、これをインクルードして使うこともできます。

ftp://ftp.holonlinux.com/pub/HOLON_Linux/OBSS/misc/httpd.conf.ssl

このファイルを /etc/httpd/conf ディレクトリにコピーして、/etc/httpd/conf/httpd.conf の最後に以下の行を追加します。

Include conf/httpd.conf.ssl

4. httpd を再起動

# /etc/rc.d/init.d/httpd restart
Shutting down http: httpd
Starting httpd: httpd
Apache/1.3.22 mod_ssl/2.8.5 (Pass Phrase Dialog)
Some of your private key files are encrypted for security reasons.
In order to read them you have to provide us with the pass phrases.
Server linuxserver.localdomain.co.jp:443 (RSA)
Enter pass phrase:<キーの生成につかったパスフェーズを入力>

以上で、 https://<サーバーのホスト名またはIP>/ でSSLを使った通信ができるはずです。もし、httpサーバーの起動の度にパスフェーズを入力するのが面倒な場合には、以下の手順でこれを解除できます(/etc/httpd/confディレクトリで実行)。

# cp server.key server.key.bak
# openssl rsa -in server.key.bak -out server.key
read RSA key
Enter PEM pass phrase: <キーの生成につかったパスフェーズを入力>
writing RSA key

Copyright (C) 2000-2005 俺 All Right Reserved