- 將以下代碼另存為后綴名為sh的文件
#!/bin/bash
PASS=
Init_Selection() {
clear
echo "+------------------------------------------------------------------------+"
echo "| _ _ _ _ _ _ _ _ |"
echo "| / / //_|/_//_//_//_//_'/ //_/ |"
echo "| _/ / _/ |"
echo "+------------------------------------------------------------------------+"
echo "| openssl證書生成腳本v1.0 |"
echo "+------------------------------------------------------------------------+"
echo "| https://www.maoyupeng.club |"
echo "+------------------------------------------------------------------------+"
Echo_Green "請輸入證書密碼"
read -p "Password:" PASS
action_build
}
action_build()
{
echo "創(chuàng)建AES256加密密鑰..."
openssl genrsa -passout pass:${PASS} -out rsa_aes_private.pem 2048
echo "生成公鑰..."
openssl rsa -in rsa_aes_private.pem -passin pass:${PASS} -pubout -out rsa_public.pem
echo "PEM私鑰轉(zhuǎn)DER..."
openssl rsa -in rsa_aes_private.pem -passin pass:${PASS} -out rsa_private_key.der -outform der
echo "PEM公鑰轉(zhuǎn)DER..."
openssl rsa -in rsa_public.pem -out rsa_public_key.der -pubin -outform der
echo "Finish!"
}
Echo_Green()
{
echo $(Color_Text "$1" "32")
}
Echo_Yellow()
{
echo $(Color_Text "$1" "33")
}
Init_Selection
- 然后打開終端, 賦予權(quán)限
chmod -R 755 ./*.sh
- 最后執(zhí)行腳本文件, 根據(jù)提示輸入生成證書的密碼
./xxx.sh
- 等待片刻, 證書生成成功