作業メモという感じですが、何枚かまとめて証明書を作りたいという時に、一行でサクッと書きたいという要求が出てきます。ワンライナー。
openssl req -new -sha256 -subj "/C=JP/ST=Tokyo/L=Chiyoda-ku/O=Example Inc./OU=example/CN=foo.example.com" -out foo.example.com.csr -newkey rsa:4096 -nodes -keyout foo.example.com.key
こんな感じで1行で書いたものをいくつか作っておいて、一気に流し込むやつです。
大抵はこれで事足りるのですが、時々何かの拍子に「このキーとの組み合わせは、どれだ?」となった場合、
openssl rsa -noout -modulus -in foo.example.com.key | openssl md5
openssl req -noout -modulus -in foo.example.com.csr | openssl md5
openssl x509 -noout -modulus -in foo.example.com.crt | openssl md5
こんな感じで確認が取れるやつがありますので、上手い事やると良いですよ。というお話。
[root@ ]# openssl req -new -sha256 -subj "/C=JP/ST=Tokyo/L=Chiyoda-ku/O=Example Inc./OU=example/CN=foo.example.com" -out foo.example.com.csr -newkey rsa:4096 -nodes -keyout foo.example.com.key
Generating a 4096 bit RSA private key
....................++
...................................................................................................++
writing new private key to 'foo.example.com.key'
-----
(証明書をもらう)
[root@ ]# openssl rsa -noout -modulus -in foo.example.com.key | openssl md5
(stdin)= a348b393dee6c00610f426bd953abcdf
[root@ ]# openssl req -noout -modulus -in foo.example.com.csr | openssl md5
(stdin)= a348b393dee6c00610f426bd953abcdf
[root@ ]# openssl x509 -noout -modulus -in foo.example.com.crt | openssl md5
(stdin)= a348b393dee6c00610f426bd953abcdf
書いて忘れるような日報みたいなエントリー。