Last active
October 19, 2016 07:02
-
-
Save tksst/d679171c2ff912c19d13 to your computer and use it in GitHub Desktop.
1発でTLS証明書の秘密鍵&CSRを作成するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CN=example.jp | |
OU="XYZ Department" | |
O="Foo Bar Institute, Ltd." | |
L=Yokohama | |
ST=Kanagawa | |
C=JP | |
# RSA 2048bit、SHA-256のTLS証明書の秘密鍵&CSRを作成するスクリプト | |
# 秘密鍵、CSRの情報、CSRを標準出力に出力 | |
# RSA 2048bit の秘密鍵を作成する | |
function create_private_key(){ | |
openssl genrsa 2048 | |
} | |
# 秘密鍵ファイルからCSRを作成する | |
# 引数1: 鍵ファイル | |
function create_csr(){ | |
# -new : CSRを作成する | |
# -text : CSRをテキスト形式(情報が分かりやすい形)で出力する | |
openssl req -new -text -sha256 -subj "/C=$C/ST=$ST/L=$L/O=$O/OU=$OU/CN=$CN/" -key "$1" | |
} | |
( | |
create_csr <( create_private_key | tee >( cat >&9 ) ) | |
) 9>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment