opensslでCSRを作成する方法をご紹介します。
CSR作成の前に秘密鍵を用意します。
まずは以下で「test.key」を作成します。
1 2 3 4 5 6 |
[root@kamatora ~]# openssl genrsa > test.key Generating RSA private key, 1024 bit long modulus ..............++++++ ...++++++ e is 65537 (0x10001) [root@kamatora ~]# |
続いて、CSRを作成します。
書式は以下の通りです。
1 |
openssl req -new -key 秘密鍵 -out CSRファイル |
では実際にCSR作成してみましょう。
実行すると、いろんな入力を要求されます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[root@kamatora ~]# openssl req -new -key test.key -out test.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) [XX]:JP State or Province Name (full name) []:Tokyo Locality Name (eg, city) [Default City]:xx Organization Name (eg, company) [Default Company Ltd]:kamotora Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) []:kamotora.net Email Address []:xxx@xxxxx Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: [root@kamatora ~]# |
「Country Name」には国名です。日本の場合はJPですね。
「State or Province Name」は都市名です。東京の場合は「Tokyo」です。
「Locality Name」は市区町村名ですね。
「Organization Name」には会社名、
「Organizational Unit Name」には組織名。ここは空欄でも問題ありません。
「Common Name」はURLを入力します。
「A challenge password」はパスワードを入力します。パスワードなしにする場合には何も入力しません。