4 echo "usage: certreq [-h] [-a ALTNAMES] SUBJECT KEYFILE"
5 echo ' SUBJECT is of the form `/PART1=VALUE1/PART2=VALUE2/...'\'
6 echo ' ALTNAMES is of the form `DNS:name1,DNS:name,...'\'
9 declare -A reqexts config
10 while getopts ha: OPT; do
19 config_SAN=("${config_SAN[@]}" "subjectAltName=$OPTARG")
29 args=(openssl req -new)
30 if [ -n "${!reqexts[*]}" ]; then
31 args=("${args[@]}" -reqexts "${!reqexts[@]}")
33 if [ -n "${!config[*]}" ]; then
34 confpath="$(mktemp /tmp/certreq-XXXXXX)"
35 cat /etc/ssl/openssl.cnf >>"$confpath"
36 for section in "${!config[@]}"; do
37 echo "[${section}]" >>"$confpath"
38 var="config_${section}[@]"
39 for confopt in "${!var}"; do
40 echo "$confopt" >>"$confpath"
44 trap 'rm -f "$confpath"' EXIT
45 args=("${args[@]}" -config "$confpath")
47 args=("${args[@]}" -subj "$1" -key "$2")