発端

Apache2 on Debian で使うためにSSLの証明書を作ったのだけど、これの期限はたったの1ヶ月。すぐに期限が切れてしまった。
そのため、SSLの証明書を更新するとともに、今度は期限の長い証明書を作ることにした。

SSLの証明書を更新する

SSLの証明書は apache2-ssl-certificate コマンドで作る。


# apache2-ssl-certificate
/etc/apache2/ssl/apache.pem exists!  Use "/usr/sbin/apache2-ssl-certificate --force."

おぉっと。
すでに古い証明書があるので警告された。
--force オプションをつければそのまま上書きしてくれる模様。

また、日々の試行と実験: SSL導入(Debian sarge apache2) によると -days オプションで証明書の有効期限を指定できるらしい。

では、10年モノの証明書を作ることにして再度、挑戦。


# apache2-ssl-certificate --force -days 3650
 
creating selfsigned certificate
replace it with one signed by a certification authority (CA)
 
enter your ServerName at the Common Name prompt
 
If you want your certificate to expire after x days call this programm
with -days x
Generating a 1024 bit RSA private key
....++++++
...............................++++++
writing new private key to '/etc/apache2/ssl/apache.pem'
-----
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
State or Province Name (full name) [Some-State]:(一応ナイショ都道府県名)
Locality Name (eg, city) []:
Organization Name (eg, company; recommended) []:NI-Lab.
Organizational Unit Name (eg, section) []:
server name (eg. ssl.domain.tld; required!!!) []:kireinajaian.nilab.info
Email Address []:(一応ないしょメールアドレス)

そもそも -days オプションなんてどこのヘルプに書いてあるんだ?と思ったら、apache2-ssl-certificate がメッセージを出している。"If you want your certificate to expire after x days call this programm with -days x" って。

"server name" というのを訊ねてくる。これには FQDNだっけ? フル・サーバ・ホスト名を入れる必要があるらしい。

で、Apache2 を再起動して、証明書を反映させる。


# /etc/init.d/apache2 restart
Forcing reload of web server: Apache2.

Mozilla Firefox 1.5 にてオレオレ証明書を表示して、と

SSL証明書の有効期限が10年!

よし、有効期限10年!

参考

tags: zlashdot Apache Apache

Posted by NI-Lab. (@nilab)