Skip to content

Instantly share code, notes, and snippets.

@nojimage
Last active June 17, 2016 05:43
Show Gist options
  • Save nojimage/8661202 to your computer and use it in GitHub Desktop.
Save nojimage/8661202 to your computer and use it in GitHub Desktop.
OpenSSL 秘密鍵とCSRを一緒に生成するシェルスクリプト
#!/usr/bin/env bash
#Common Name (eg, your name or your server's hostname)
CN="ssl.example.com"
# Country Name (2 letter code)
C="JP"
# State or Province Name (full name)
ST="Fukuoka"
# Locality Name (eg, city)
L="Fukuoka"
# Organization Name (eg, company)
O="Example Company co,ltd."
# Organizational Unit Name (eg, section)
OU="Web"
csrfile=$CN.csr
pkeyfile=$CN.key
subject="/C=$C/ST=$ST/L=$L/O=$O/OU=$OU/CN=$CN"
if [ -f $pkeyfile ] ; then
echo "Error: Private Key already exists."
exit
fi
openssl req -new -sha256 -newkey rsa:2048 -nodes -out $csrfile -keyout $pkeyfile -subj "$subject"
# CHECK modules
openssl req -in $csrfile -text
openssl rsa -in $pkeyfile -text
#cat $pkeyfile $csrfile
@nojimage
Copy link
Author

nojimage commented Feb 9, 2015

SHA2(sha256) 対応

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment