ワンライナーで証明書を発行する

オレオレ証明書がとりあえず必要だけど、対話的に入力せずにワンライナーでつくりたい。

1
2
3
4
5
6
7
8
HOSTNAME=www.example.com

$openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "/C=JP/ST=Tokyo/L=Chiyoda/O=Dis/CN=${HOSTNAME}" -keyout ${HOSTNAME}.key -out ${HOSTNAME}.cert
Generating a RSA private key
...++++
...............................................................................................................................................................................................................................................................................................................................................................................................................................................++++
writing new private key to 'www.example.com.key'
-----