码迷,mamicode.com
首页 > 其他好文 > 详细

证书脚本--生成csr,key

时间:2018-05-23 20:37:32      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:AC   ica   dom   ase   ras   host   org   address   bsp   

#!/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

标签:AC   ica   dom   ase   ras   host   org   address   bsp   

原文地址:https://www.cnblogs.com/wangmo/p/9078297.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!