[OpenSSL]自己署名証明書を生成する方法
目標
サーバ証明書(公開鍵)www.example.jp.csr
とサーバ秘密鍵www.example.jp.key
を生成する
構築環境
手順
# openssl genrsa > www.example.jp.key Generating RSA private key, 2048 bit long modulus ..............................................................+++ ..+++ e is 65537 (0x10001)
- コンソールでCSRファイルを生成
# openssl req -new -key www.example.jp.key > www.example.jp.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]:kyoto Locality Name (eg, city) []:kyoto Organization Name (eg, company) [Internet Widgits Pty Ltd]:Company Organizational Unit Name (eg, section) []:Department Common Name (e.g. server FQDN or YOUR name) []:www.example.jp Email Address []:example@example.jp Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:
まずCSRファイルってなんやねんってことですが、認証局(CA)に対して、SSLサーバ証明書への証明を申請する内容。
CSRファイルには「公開鍵」とそれの所有者情報と申請者が対応する秘密鍵を持っているのを示す申請者の署名が書いている。
(引用元CSRファイルとは何ですか? | SSLサーバ証明書のクロストラスト)
# openssl x509 -req -signkey www.example.jp.key < www.example.jp.csr > www.example.jp.crt Signature ok subject=/C=jp/ST=kyoto/L=kyoto/O=Company/OU=Department/CN=www.example.jp/emailAddress=example@example.jp Getting Private key