ssl 生成客户端key和证书
开发脚本
[root@centos m2]# cat gen_clientKey2.sh
#!/bin/bash
# Check if the 'client_name' argument is passed
if [ -n "$1" ]
then
client_name=$1
else
# Generate a random 5-digit number
rand=$(printf "%05d" $(( RANDOM % 100000 )))
# Concatenate 'client_' with the random number
client_name="client_$rand"
fi
# Print the client_name
echo $client_name
openssl genrsa -out $client_name.key 2048
openssl req -new -key $client_name.key -out $client_name.csr -subj "/C=CN/ST=ShangHai/L=MinHang/O=CwFlinkTeam/CN=demo2"
openssl x509 -req -days 3650 -in $client_name.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out $client_name.pem
测试脚本
sh gen_clientKey2.sh client-a
sh gen_clientKey2.sh client-b
sh gen_clientKey2.sh client-a
sh gen_clientKey2.sh client-b
sh gen_clientKey2.sh client-java
sh gen_clientKey2.sh client-scala