证书脚本--生成csr,key
Posted wangmo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了证书脚本--生成csr,key相关的知识,希望对你有一定的参考价值。
#!/bin/sh # this script can make certificate of each line in file you point which one! if [ $# -ne 1 ];then echo -e "\033[33m Input your domain‘s file \033[0m" exit 1 fi for line in `cat $1` do hostname=$line line="`echo $line|awk -F" " ‘{print $1}‘`.key" echo "==$line==" echo -e "\n\n\033[32m Make certificate of $line \033[0m\n\n" csr_file=`echo $line|awk -F".key" ‘{print $1}‘` expect -c " set timeout 20; spawn openssl genrsa -des3 -out $line 2048 expect { : {send 12345678\r;exp_continue} : {send 12345678\r;} } spawn openssl rsa -in $line -out $line expect { \"Enter pass phrase\" {send 12345678\r;exp_continue} } spawn openssl req -new -key $line -out $csr_file.csr expect { \"Enter pass phrase\" {send 12345678\r;exp_continue} \"Country Name\" {send CN\r;exp_continue} \"State or Province Name\" {send Beijing\r;exp_continue} \"Locality Name\" {send Beijing\r;exp_continue} \"Organization Name\" {send \"Beijing Yuanxin Technology Co., Ltd.\r\";exp_continue} \"Organizational Unit Name\" {send \"Beijing Yuanxin Technology Co., Ltd.\r\";exp_continue} \"Common Name*\" {send \"$hostname\r\";exp_continue} \"Email Address\" {send \r;exp_continue} \"A challenge password\" {send 12345678\r;exp_continue} \"An optional company name\" {send \"Beijing Yuanxin Technology Co., Ltd\r\";exp_continue} }" done
以上是关于证书脚本--生成csr,key的主要内容,如果未能解决你的问题,请参考以下文章
sh 笔记:OpenSSL生成「自签名」证书,配置Nodejs本地HTTPS服务 - 6.通过.key和.csr生成.crt