sh 为httpS生成SSL密钥
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 为httpS生成SSL密钥相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env bash
declare -a arr=( "certs/web" )
Country_Name=ES
State_Name=Catalunya
Locality=Barcelona
Organization="Example Co"
Common_Name=www.example.com
function ssl_keys(){
mkdir -p $1
echo 'Generating a Private Key...'
openssl genrsa -out $1/selfsigned.key 2048
echo 'Generating a Self-Signed Certificate...'
openssl req -new -x509 -sha256 -days 3650 \
-subj "/C=$Country_Name/ST=$State_Name/L=$Locality/O=$Organization/CN=$Common_Name" \
-key $1/selfsigned.key \
-out $1/selfsigned.crt
echo 'HTTPS Self-Signed Certificate...'
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
-subj "/C=$Country_Name/ST=$State_Name/L=$Locality/O=$Organization/CN=$Common_Name" \
-keyout $1/https.key \
-out $1/https.crt
echo 'Nginx Perfect Forward Secrecy Diffie-Hellman group...'
openssl dhparam -dsaparam -out $1/dhparam.pem 4096
}
for i in "${arr[@]}"
do
ssl_keys "$i"
done
以上是关于sh 为httpS生成SSL密钥的主要内容,如果未能解决你的问题,请参考以下文章
ssl(https)介绍实验环境生成密钥对nginx配置SSLhttps
https如何生成密钥
acme.sh及https证书实践
NodeJS 为签名和验证消息生成有效的 PEM 密钥
sh SSL创建.dev密钥
ssl协议工作流程详解