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 4
4
CERT_BASE=" certs"
5
5
6
6
if [ -z $1 ]; then
7
- echo " Usage: gen_certs.sh <hostname> [<password>]"
7
+ echo " Usage: gen_certs.sh <hostname> <ip> [<password>]"
8
8
exit 1
9
9
fi
10
10
11
11
mkdir -p $CERT_BASE
12
12
13
13
# Setting up a CA
14
14
openssl 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
16
16
17
17
# Setting up device cert and key
18
18
openssl genrsa -out $CERT_BASE /device.key 2048
19
19
openssl 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 " )
21
21
22
22
# Encrypt device key - needed for input to IOS
23
- if [ ! -z $2 ]; then
23
+ if [ ! -z $3 ]; then
24
24
openssl rsa -des3 -in $CERT_BASE /device.key -out $CERT_BASE /device.des3.key -passout pass:$2
25
25
else
26
26
echo " Skipping device key encryption."
29
29
# Setting up client cert and key
30
30
openssl genrsa -out $CERT_BASE /client.key 2048
31
31
openssl 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