shell脚本生成ssl免费域名证书

#!/bin/sh
# create self-signed server certificate: 
read -p "Enter your domain [www.example.com]: " DOMAIN 
echo "Create server key..." 
openssl genrsa -des3 -out $DOMAIN.key 1024 
echo "Create server certificate signing request..." 
SUBJECT="/C=US/ST=Mars/L=iTranswarp/O=iTranswarp/OU=iTranswarp/CN=$DOMAIN" 
openssl req -new -subj $SUBJECT -key $DOMAIN.key -out $DOMAIN.csr 
echo "Remove password..." 
mv $DOMAIN.key $DOMAIN.origin.key
openssl rsa -in $DOMAIN.origin.key -out $DOMAIN.key 
echo "Sign SSL certificate..." 
openssl x509 -req -days 3650 -in $DOMAIN.csr -signkey $DOMAIN.key -out $DOMAIN.crt

 

posted @ 2019-11-09 13:56  赵海博运维笔记  阅读(587)  评论(0编辑  收藏  举报