ホーム | カスタムPC | サポート | リナックス | ギャラリー | 会社概要 | お問合せ

apache2 の証明書の作成(Ubuntu 8.04)


 Ubuntu 8.04 での apache2 の証明書の作成方法です。ここで生成するのは、/etc/ssl/private/apache.key と /etc/ssl/certs/apache.pem です。すべて、root での操作なので、
$ sudo -i

で、root になってから操作する事にします。。

1.プライベートキーの生成
まず、プライベートキーを生成します。

# cd /etc/ssl/private
# openssl genrsa -des3 1024 > apache.key
Generating RSA private key, 1024 bit long modulus
...++++++
....................++++++
e is 65537 (0x10001)
Enter pass phrase:
Verifying - Enter pass phrase:









<---適当に入力

<---適当に入力

訊かれるパスフレーズは適当に入力します。空のパスフレーズは拒否されます。
/etc/ssl/private は root と ssl-cert に属する人しか見えないので、このままでも問題はないですが、
# chown root.ssl-cert apache.key
# chmod 640 apache.key



で、mail.key も他の人に見られない様にします。

2. プライベートキーからパスワードを削除。

# openssl rsa -in apache.key -out apache.key
Enter pass phrase for test.key:
writing RSA key




<--- 1.で入力した
       パスフレーズを入力

ここで入力するパスワードを聞かれるので、1. で入力したパスフレーズを入れます。

3. パブリックキーの生成
次にパブリックキーを生成します。証明書に含める情報を質問してくるので、必要な情報を入れます。

# cd ../certs
# openssl req -utf8 -new -key ../private/apache.key -x509 -days 365 -out apache.pem -set_serial 0

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]:Tokyo
Locality Name (eg, city) []:Bunkyo-ku
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Terra Corp.
Organizational Unit Name (eg, section) []:HQ
Common Name (eg, YOUR name) []:www.la-terre.co.jp
Email Address []:webmaster.la-terre.co.jp













<--- 国コードを入力
<--- 都道府県名を入力
<--- 市区町村名を入力
<--- 会社名を入力
<--- 組織名称を入力
<--- サーバのホストネーム
<--- 連絡先

Common Name には、ウェブサーバのホスト名を入力します。

4. apache2 の設定
まず、apache2 の SSL に関する設定を、
# a2ensite httpd-ssl.conf


で、利用可能にします。
/etc/apache2/sites-enabled/httpd-ssl.conf を編集し、今作ったキーの使用を指定します。
(/etc/apache2/sites-enabled/httpd-ssl.conf)

92 # Server Certificate:
93 # Point SSLCertificateFile at a PEM encoded certificate. If
94 # the certificate is encrypted, then you will be prompted for a
95 # pass phrase. Note that a kill -HUP will prompt again. Keep
96 # in mind that if you have both an RSA and a DSA certificate you
97 # can configure both in parallel (to also allow the use of DSA
98 # ciphers, etc.)
99 SSLCertificateFile "/etc/ssl/certs/apache.pem"
100 #SSLCertificateFile "/etc/apache2/server-dsa.crt"
101
102 # Server Private Key:
103 # If the key is not combined with the certificate, use this
104 # directive to point at the key file. Keep in mind that if
105 # you've both a RSA and a DSA private key you can configure
106 # both in parallel (to also allow the use of DSA ciphers, etc.)
107 SSLCertificateKeyFile "/etc/ssl/private/apache.key"
108 #SSLCertificateKeyFile "/etc/apache2/server-dsa.key"
109









<--- この行を追加







<--- この行を追加



最後に
# /etc/init.d/apache2 restart
で、apache2 を再起動します。