Files
wlan-lanforge-scripts/cert-builder.sh
2019-11-12 15:15:04 -08:00

37 lines
728 B
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# example based off https://www.endpoint.com/blog/2014/10/30/openssl-csr-with-alternative-names-one
hostname="$1"
hostname1=$hostname.local
ipaddr=
cat > tmp_csr_details.txt <<-EOF
[req]
default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn
[ dn ]
C=US
ST=Washington
L=Ferndale
O=Candela Technologies, Inc.
OU=LANforge
emailAddress=support@candelatech.com
CN = $hostname
[ req_ext ]
subjectAltName = @alt_names
[ alt_names ]
DNS.1 = $hostname1
DNS.2 = $ipaddr
EOF
# Lets call openssl now by piping the newly created file in
openssl req -new -sha256 -nodes -out ${hostname}.csr -newkey rsa:2048\
-keyout ${hostname}.key -config <( cat temp_csr_details.txt )
#