File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 44CERT_BASE=" certs"
55
66if [ -z $1 ]; then
7- echo " Usage: gen_certs.sh <hostname> [<password>]"
7+ echo " Usage: gen_certs.sh <hostname> <ip> [<password>]"
88 exit 1
99fi
1010
1111mkdir -p $CERT_BASE
1212
1313# Setting up a CA
1414openssl genrsa -out $CERT_BASE /rootCA.key 2048
15- openssl req -subj /C=/ST=/L=/O=/CN=rootCA -x509 -new -nodes -key $CERT_BASE /rootCA.key -sha256 -out $CERT_BASE /rootCA.pem
15+ openssl req -subj /C=/ST=/L=/O=/CN=rootCA -x509 -new -nodes -key $CERT_BASE /rootCA.key -sha256 -days 1095 - out $CERT_BASE /rootCA.pem
1616
1717# Setting up device cert and key
1818openssl genrsa -out $CERT_BASE /device.key 2048
1919openssl req -subj /C=/ST=/L=/O=/CN=$1 -new -key $CERT_BASE /device.key -out $CERT_BASE /device.csr
20- openssl x509 -req -in $CERT_BASE /device.csr -CA $CERT_BASE /rootCA.pem -CAkey $CERT_BASE /rootCA.key -CAcreateserial -out $CERT_BASE /device.crt -sha256
20+ openssl x509 -req -in $CERT_BASE /device.csr -CA $CERT_BASE /rootCA.pem -CAkey $CERT_BASE /rootCA.key -CAcreateserial -out $CERT_BASE /device.crt -days 1095 - sha256 -extfile <( printf " %s " " subjectAltName=DNS: $1 ,IP: $2 " )
2121
2222# Encrypt device key - needed for input to IOS
23- if [ ! -z $2 ]; then
23+ if [ ! -z $3 ]; then
2424 openssl rsa -des3 -in $CERT_BASE /device.key -out $CERT_BASE /device.des3.key -passout pass:$2
2525else
2626 echo " Skipping device key encryption."
2929# Setting up client cert and key
3030openssl genrsa -out $CERT_BASE /client.key 2048
3131openssl req -subj /C=/ST=/L=/O=/CN=gnmi_client -new -key $CERT_BASE /client.key -out $CERT_BASE /client.csr
32- openssl x509 -req -in $CERT_BASE /client.csr -CA $CERT_BASE /rootCA.pem -CAkey $CERT_BASE /rootCA.key -CAcreateserial -out $CERT_BASE /client.crt -sha256
32+ openssl x509 -req -in $CERT_BASE /client.csr -CA $CERT_BASE /rootCA.pem -CAkey $CERT_BASE /rootCA.key -CAcreateserial -out $CERT_BASE /client.crt -days 1095 - sha256
You can’t perform that action at this time.
0 commit comments