SSL証明書のCSRファイル・KEYファイルの生成コマンド

概要

SSL証明書の更新作業でCSRファイルとKEYファイルの作成を行うコマンドを調べたので備忘録。

事前知識

CSRファイル

SSL証明書を発行する上で必要な個人情報。

KEYファイル

暗号化されたCSRファイルを復号化するための暗号キー。

コマンド

秘密鍵を生成

openssl genrsa -des3 -out test.key 2048

openssl genrsa:秘密鍵を生成するコマンド
-out          :生成した秘密鍵の名前
2048          :bit数
-des3         :秘密鍵のパスワードを付与する時の暗号方式
Generating RSA private key, 2048 bit long modulus
.....................................+++
.............................+++
e is 65537 (0x10001)
Enter pass phrase for test.key:
Verifying - Enter pass phrase for test.key:

証明書の作成

openssl req -new -key test.key -out test.csr

openssl req :CSRファイルを作成するコマンド
-new        :新しく証明書を生成するオプション
-key        :CSRファイルを作成する上で利用する秘密鍵
-out        :作成するCSRファイル名
Enter pass phrase for test.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) []:JP
State or Province Name (full name) []:test
Locality Name (eg, city) []:hoge
Organization Name (eg, company) []:fuga
Organizational Unit Name (eg, section) []:hogehoge
Common Name (eg, fully qualified host name) []:huge
Email Address []:test@mail

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