おれおれ証明書(プライベート証明書) サーバ証明書編

おれおれCA(プライベート認証局)が構築できたところで、「サーバ証明書」を作成していきます。いわゆる「ルート証明書」に当たるものです。
サーバ証明書の作成は、秘密鍵を作って、署名リクエストを作成して、CAに認証させるという手順を踏むのですが、CAを新しく作る手順の場合は、このCA作成のなかでほとんどの手順が終了してしまっています。
それではできている公開鍵が認証できるかどうか確認してみましょう。
# openssl verify /etc/pki/CA/cacert.pem


cacert.pem: /C=JP/ST=Tokyo/L=Shinagawa-ku/O=Fs DataCenter CA/CN=ca1.free-style.biz
error 18 at 0 depth lookup:self signed certificate
OK


SSL証明書用のユーザディレクトリを作成して、移動します。
# mkdir /usr/local/ssl
# cd /usr/local/ssl

クライアントに組み込むためのサーバ証明書を作成します。
# openssl x509 -inform pem -in /etc/pki/CA/cacert.pem -out ca1.free-style.biz.crt -outform der
これで終わりです。
というのもあんまりですので、別に証明書を作成して署名してみましょう。
証明書はユーザディレクトリに作成します。
# cd /usr/local/ssl
新しく秘密鍵を2048bitで生成します。
# openssl genrsa -out private.pem 2048


Generating RSA private key, 2048 bit long modulus
..+++
……………………..+++
e is 65537 (0x10001)


秘密鍵を使用して署名リクエスト(公開鍵)を作成します。
# openssl req -new -key private.pem -out request.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.