openssl 命令自动创建证书请求

openssl 命令自动创建证书请求

前言

使用openssl命令自动创建证书请求可以免去交互过程中的繁琐。

ecc 算法证书请求

#!/bin/sh


`openssl ecparam -out private.pem -name secp384r1 -genkey `

if [[ "$1" = ""  || "$2" = ""  || "$3" = "" || "$4" = "" || "$5" = "" || "$6" = "" || "$7" = "" ]] ; then
	echo "certRequestCreate.sh  country state location organization organizationUnit commonName  email"  
	exit 0;
else
	if [ "$8" = "" ] ; then 
		`openssl req -new -key private.pem -passin pass:123456  -subj /C=$1/ST=$2/L=$3/O=$4/OU=$5/CN=$6/emailAddress=$7    -out client.pem `
	else	
		sed -i '/\[SAN\]*/d' /etc/pki/tls/openssl.cnf
		sed -i '/subjectAltName*/d' /etc/pki/tls/openssl.cnf
		`echo "[SAN]" >> /etc/pki/tls/openssl.cnf `
		`echo "subjectAltName=DNS:$8" >> /etc/pki/tls/openssl.cnf `
		`openssl req -new -key private.pem -passin pass:123456 -subj /C=$1/ST=$2/L=$3/O=$4/OU=$5/CN=$6/emailAddress=$7 -reqexts SAN -config  /etc/pki/tls/openssl.cnf  -out client.pem `
		sed -i '/\[SAN\]*/d' /etc/pki/tls/openssl.cnf
		sed -i '/subjectAltName*/d' /etc/pki/tls/openssl.cnf
	fi
fi



rsa 算法证书请求


#!/bin/sh


`openssl genrsa   -out private.pem 2048`




if [[ "$1" = ""  || "$2" = ""  || "$3" = "" || "$4" = "" || "$5" = "" || "$6" = "" || "$7" = "" ]] ; then
	echo "certRequestCreate.sh  country state location organization organizationUnit commonName  email"  
	exit 0;
else
	if [ "$8" = "" ] ; then 
		`openssl req -new -key private.pem -passin pass:123456  -subj /C=$1/ST=$2/L=$3/O=$4/OU=$5/CN=$6/emailAddress=$7   -extensions v3_ca -out client.pem `
	else	
		sed -i '/\[SAN\]*/d' /etc/pki/tls/openssl.cnf
		sed -i '/subjectAltName*/d' /etc/pki/tls/openssl.cnf
		`echo "[SAN]" >> /etc/pki/tls/openssl.cnf `
		`echo "subjectAltName=DNS:$8" >> /etc/pki/tls/openssl.cnf `
		`openssl req -new -key private.pem -passin pass:123456  -subj /C=$1/ST=$2/L=$3/O=$4/OU=$5/CN=$6/emailAddress=$7 -extensions v3_ca -reqexts SAN -config  /etc/pki/tls/openssl.cnf  -out client.pem `
		sed -i '/\[SAN\]*/d' /etc/pki/tls/openssl.cnf
		sed -i '/subjectAltName*/d' /etc/pki/tls/openssl.cnf
	fi
fi





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值