★ブログ移行のお知らせ
サイトを移行しました。以下をクリックください。
きよしの倶楽部 – 生活を潤わす情報を発信中。GTDを得意としてます。


ーーー
opensslで自己証明書を作るもっとも手軽な方法。

# openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
.................................++++++
.....++++++
e is 65537 (0x10001)
Enter pass phrase for server.key: (ここではきちんとパスワードを設定する)
Verifying - Enter pass phrase for server.key:

  • 自己証明書の生成

CSR(本来であればサーバIDを申請・取得するために認証局へ提出する署名リクエスト(Certificate Signing Request)証明書要求)を生成します。

# openssl req -new -x509 -days 365 -keyserver.key -out server.crt
Enter pass phrase for server.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 (jpでしょうね)
State or Province Name (full name) [Berkshire]:Tokyo (適当に)
Locality Name (eg, city) [Newbury]:Fussa (適当)
Organization Name (eg, company) [My Company Ltd]:shino (適当)
Organizational Unit Name (eg, section) :office (適当)
Common Name (eg, your name or your server's hostname)
:abc.com (実際に使用するURLを。もしくは適当)
Email Address []: (無視)

※いうまでもなく、本当にサーバIDを発行してもらうときは、うそ偽りなく入力しないと、まともな認証局からはID発行してもらえない。自己証明は適当にやってもいいけど、本物の証明書もらうときはまじめに! 間違えて再申請する際、有償対応の認証曲もある。

  • パスワードの解除

セキュリティは落ちるが、このままだとサーバやapacheの再起動のたびにパスワード入力を求めるので、意外な落とし穴になってしまうので、解除する。

openssl rsa -in server.key -out server.key
Enter pass phrase for server.key: (先ほど設定したパスワード)
writing RSA key

あとはapahceのssl.confとかSSLの設定ファイルで決めた場所に移し、apacheをリスタートする。パーミッションも変更したほうが無難なサーバでは必要に応じ対応する。