SSL鍵更新作業手順
会社で使用しているSSL鍵の更新時期になったので更新作業。
ついでに手順をメモ
会社サーバのSSL証明書は /etc/httpd/conf に年毎にディレクトリを作成している。 年度のない ssl_key ディレクトリが現行のSSL鍵ディレクトリ。
[hoge@serv conf]# ls -l 合計 176 lrwxrwxrwx 1 hoge hage 37 3月 29日 2010 Makefile -> ../../../usr/share/ssl/certs/Makefile
- rw-r--r-- 1 hoge hage 35903 1月 29日 2008 httpd.conf
- rw-r--r-- 1 hoge hage 34704 1月 10日 2008 httpd.conf.org
- rw-r--r-- 1 hoge hage 34790 1月 17日 2008 httpd.conf~
- rw-r--r-- 1 hoge hage 12959 3月 26日 2010 magic
2011年度のディレクトリつくって、その中で秘密鍵のつくり直しから やる。
[hoge@serv conf]# mkdir ssl_key2011 [hoge@serv conf]# cd ssl_key2011
秘密鍵の作成
[hoge@serv ssl_key2011]# openssl genrsa -des3 -out example.com.key 2048 Generating RSA private key, 2048 bit long modulus .....+++ .......................+++ e is 65537 (0x10001) Enter pass phrase for example.com.key: # ←秘密鍵のパスフレーズを入力 Verifying - Enter pass phrase for example.com.key: # ←パスフレーズの再入力
作成した秘密鍵から CSR ファイルを作成、 CSR ファイルは Certificate Signing Request の意味で、証明書署名要求というらしい。
[hoge@serv ssl_key2011]# openssl req -new -key example.com.key -out example.com.csr Enter pass phrase for example.com.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 # ←国コードを入力 State or Province Name (full name) [Berkshire]:Kyoto # ←都道府県を入力 Locality Name (eg, city) [Newbury]:Kyoto-Shi # ←市区町村を入力 Organization Name (eg, company) [My Company Ltd]:CompanyName # ←会社の名前を入力 Organizational Unit Name (eg, section) :MySection # ←部署名 Common Name (eg, your name or your server's hostname) :example.com # ←ドメイン名 Email Address :hoge@example.com # ←メールアドレス Please enter the following 'extra' attributes to be sent with your certificate request A challenge password : # ←入力不要 Enter のみ An optional company name []: # ←入力不要 Enter のみ [hoge@serv ssl_key2011]#
CSR ファイルには先に作成した秘密鍵に対応する公開鍵と、上で入力した国や地域、会社名などの情報が含まれる。
この CSR ファイルを認証局へ送り、認証局は認証局の秘密鍵でこの CSR ファイルに署名することで、この CSR ファイルは有効なものとして認証される。
認証局とか、信用の連鎖とか秘密鍵とか大まかな概要は理解してるんだけど、こまかい部分になると結構ややこしい。
認証局からは CSR を送ってきた企業の確認などが完了したら、送られてきた CSR に対して証明書を送ってくるので、それを /etc/httpd/conf/ssl_2011/servername.cer なとに保存しておく。
必要に応じて、認証局から中間証明書などが送られてくることがあるので、それも同じように保存しておく。
以上で証明書発行の手続きなどは終了。
あとは apache で使用している証明書の更新をするために、ssl_keyディレクトリを入れ替えて、apache を再起動して完了。