 |
 |
Apache-SSL
戻る
Apache-SSL の導入
必要なソースを準備する。
openssl-0.9.6.tar.gz --> OpenSSLのソース
http://www.infoscience.co.jp/technical/openssl/ <-- 日本語サイト
http://www.openssl.org/ <-- 本家 最新版はここ
apache_1.3.14.tar.gz --> Apacheのソース
http://www.apache.or.jp/ <-- 日本語サイト
http://japache.infoscience.co.jp/ <-- 日本語サイト
http://www.apache.org/ <-- 本家 最新版はここ
apache_1.3.14+ssl_1.42.tar.gz --> Apache-SSLのパッチ
http://japache.infoscience.co.jp/Apache-SSL/Apache-SSL.html <-- 日本語サイト
http://www.apache-ssl.org/ <-- 本家 最新版はここ
OpenSSLをインストールする。(導入済みの場合は次へ)
ex.) $ tar zxfv openssl-0.9.6.tar.gz
$ cd openssl-0.9.6
$ ./config shared
^^^^^^ <-- openssh等で共有lib を使用する場合に必要
$ make
$ make test
$ su
# make install <-- デフォルトでは /usr/local/ssl にインストールされる
注) rpmでインストールしている場合、開発環境(openssl-devel-0.9.6-1)がインストール
されているかを確認する。されていなければする。
Apacheのソースを展開する。
ex.) $ tar zxfv apache_1.3.14.tar.gz
展開後のApacheのディレクトリーで Apache-SSLのパッチを展開する。
ex.) $ cd apache_1.3.14
$ tar zxfv ../apache_1.3.14+ssl_1.42.tar.gz
Apache-SSLのパッチをあてる
ex.) $ ./FixPatch <-- 自動で OpenSSL のインストールディレクトリを設定してくれます。
上手くいかない時は
ex.) $ ./FixPatch /hoge/fuga/ssl
^^^^^^^^^^^^^^ <-- OpenSSLをインストールしたディレクトリ
Your version of patch is OK.
Searching for a usable OpenSSL installation or source directory
Looks like you are using OpenSSL, adjusting app name
OpenSSL installation found in: /usr
Using the installed version of OpenSSL found in /usr
If this is not what you want stop now and specify the path to OpenSSL
explicitly.
Do you want me to apply the fixed-up Apache-SSL patch for you? [n] y <-- パッチする "y"
後は普通に configure して make して install してほげほげする。
ex.) $ ./configure --enable-shared=max --enable-module=all --prefix=/usr/local/apache_ssl
$ make インストールするディレクトリー --> ^^^^^^^^^^^^^^^^^^^^^
$ su
# make install
# cp src/modules/ssl/libssl.so /usr/local/apache_ssl/libexec <--ほげほげ
# cd /usr/local/apache_ssl/libexec :
# ln -s libssl.so apache_ssl.so <-- symlink をはるかまたは httpsd.confを修正
# vi /usr/local/apache_ssl/conf/httpsd.conf
LoadModule apache_ssl_module libexec/libssl.so <-- 追加する
Apache-SSLの場合 httpd の deamon は'httpsd' となります。
設定ファイルは 'httpsd.conf'です。
'httpsd.conf' を 'httpd.conf' にリネームするか symlink を張ります。
Apache 1.3.12 + SSL 1.40 で DSO 対応になった?
サイト証明書の作成・発行、秘密鍵の作成
(ソースからインストールした場合 OpenSSLのディレクトリーは /usr/local/ssl です。
Turbo linux Server 6.1で rpmでインストールした場合は /var/ssl です。
以下、ソースからインストールした場合)
秘密keyの作成
# /usr/local/ssl/bin/openssl genrsa -des 1024 > key.pem
warning, not much extra random data, consider using the -rand option
Generating RSA private key, 1024 bit long modulus
....................++++++
........................++++++
e is 65537 (0x10001)
Enter PEM pass phrase: <--パスフレーズを入力
Verifying password - Enter PEM pass phrase: <--もう一度入力
作成した秘密keyからパスフレーズを削除。
(Apache-SSL起動時のパスフレーズ入力の回避)
# /usr/local/ssl/bin/openssl rsa -in key.pem -out new.key.pem
read RSA key
Enter PEM pass phrase: <-- パスフレーズを入力
writing RSA key
CSR(サイト証明書リクエスト)の生成
# /usr/local/ssl/bin/openssl req -new -days 365 -key new.key.pem -out csr.pem
Using configuration from /usr/local/ssl/openssl.cnf
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]:Aomori <-- 都道府県
Locality Name (eg, city) []:Hachinohe <-- 地域
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Hoge inc. <-- 組織 *1
Organizational Unit Name (eg, section) []:tec <-- 部門
Common Name (eg, YOUR name) []:www.hogehohe.com <-- サーバー名(FQDN) *2
Email Address []:webmaster@hogemoge.com <-- メールアドレス *3
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <-- チャレンジパスワード *4
An optional company name []:
*ベリサインで証明書の発行を行う場合は以下に注意
*1 ドメインのレジストラーに登録されている名称
*2 使用する Webサーバーの FQDN
*3 入力しない
*4 入力しない
生成されたCSRをベリサインに送るとサイト証明書が発行されます。
自分で署名を行う場合。
# /usr/local/ssl/bin/openssl x509 -in csr.pem -out cert.pem -req -signkey new.key.pem
作成した秘密key 'new.key.pem' とサイト証明書 'cert.pem' はそれぞれ
/usr/local/ssl/private/new.key.pem
/usr/local/ssl/certs/cert.pem
に移します。
ファイルのパーミッションは root の 400 とします。
SSLのモジュールを有効にし SSL 関係の設定をする。
(バーチャルホストで動かす様に設定する。)
# vi /usr/local/apache_ssl/conf/httpsd.conf
:
:
Port 80 <-- 通常は port の 80 を使う。
Listen 80
DocumentRoot "/usr/local/apache_ssl/htdocs" <-- 通常コンテンツのディレクトリー
SSLDisable <-- 通常は SSL を無効にする
SSLCacheServerPath /usr/local/apache_ssl/bin/gcache
SSLCacheServerPort /usr/local/apache_ssl/conf/ssl_gcache
SSLSessionCacheTimeout 300 ^^^^^^^^^^^^^^^^ <-- * 注意
:
:
Listen 443 <-- SSL では port 443 を使用する
<VirtualHost _default_:443> <-- バーチャルホストで使用
DocumentRoot /usr/local/apache_s/htdocs_secure <-- SSL 用のディレクトリー
SSLEnable <-- SSL を有効にする
SSLCertificateKeyFile /usr/local/ssl/private/key.pem
SSLCertificateFile /usr/local/ssl/certs/cert.pem
SSLVerifyClient 0
SSLVerifyDepth 10
CustomLog logs/ssl_log "%t %{version}c %{cipher}c %{clientcert}c"
</VirtualHost>
<Directory /usr/local/apache_ssl/htdocs_secure>
SSLRequireSSL
</Directory>
* G.W./F.W.で port 443 が閉じているときは開く
* SSLCacheServerPort のパラメータは存在するディレクトリーと存在しないファイル名
にするか、未使用のポート番号を書く。
Apache-SSL の起動
# /usr/local/apache_ssl/bin/httpsdctl start
^^^^^^^^^ <-- Apache-SSL は 'apachectl' ではなく 'httpsdctl'
となる。
自動起動を行う場合は関係する起動スクリプトを修正しておく。