OpenSSL

自己認証証明書の作成

自己認証局(CA)の作成

SSL/TLSで使用する証明書を作成します。 まず、自己認証で使用するルート証明書を作成します。

# openssl genrsa -out CA.key 1024
# openssl req -new -x509 -days 3653 -key CA.key -out CA.crt
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) []:Chiyoda
Organization Name (eg, company) [Internet Widgits Pty Ltd]:example.net
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:example.net

これで CA の公開鍵(CA.crt)と秘密鍵(CA.key)が作成されました。

サーバ証明書の作成

HTTP サーバや SMTP/IMAP サーバで STARTTLS を使用するときに必要な、サーバー証明書を作成します。今回は全てのサブドメイン(*.example.net)に対して有効なワイルドカード SSL 証明書を作成します。また、運用上の負担軽減のため、パスフレーズは設定していません。 まず、サーバ側の秘密鍵(example.key)と証明書要求(example.csr)を作成します。

# openssl genrsa -out example.key 1024
# openssl req -new -key example.key -out example.csr
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) []:Chiyoda
Organization Name (eg, company) [Internet Widgits Pty Ltd]:example.net
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:*.example.net
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

Common Name として *.example.net とサブドメインにワイルドカード(*)を使用したものを指定します。この証明書要求(example.csr)に対して、CA として署名し、署名されたサーバ証明書(example.crt)を作成します。

# mkdir demoCA
# touch demoCA/index.txt
# echo '01' > demoCA/serial 
# mkdir demoCA/newcerts
# openssl ca -in example.csr -out example.crt -keyfile CA.key -cert CA.crt

Link


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-05-11 (水) 15:25:24