mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-05-18 21:06:56 +02:00
fixed altname extraction of csr with wildcard domains, moved altname extraction from sign_csr to command_sign_csr
This commit is contained in:
+8
-8
@@ -576,8 +576,7 @@ extract_altnames() {
|
|||||||
fi
|
fi
|
||||||
# strip away the DNS: prefix
|
# strip away the DNS: prefix
|
||||||
altnames="$( <<<"${altnames}" _sed -e 's/^(DNS:|othername:<unsupported>)//' )"
|
altnames="$( <<<"${altnames}" _sed -e 's/^(DNS:|othername:<unsupported>)//' )"
|
||||||
echo "${altnames}"
|
echo "${altnames}" | tr '\n' ' '
|
||||||
|
|
||||||
else
|
else
|
||||||
# No SANs, extract CN
|
# No SANs, extract CN
|
||||||
altnames="$( <<<"${reqtext}" grep '^[[:space:]]*Subject:' | _sed -e 's/.* CN ?= ?([^ /,]*).*/\1/' )"
|
altnames="$( <<<"${reqtext}" grep '^[[:space:]]*Subject:' | _sed -e 's/.* CN ?= ?([^ /,]*).*/\1/' )"
|
||||||
@@ -596,11 +595,7 @@ sign_csr() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
shift 1 || true
|
shift 1 || true
|
||||||
altnames="${*:-}"
|
export altnames="${*}"
|
||||||
if [ -z "${altnames}" ]; then
|
|
||||||
altnames="$( extract_altnames "${csr}" )"
|
|
||||||
fi
|
|
||||||
export altnames
|
|
||||||
|
|
||||||
if [[ ${API} -eq 1 ]]; then
|
if [[ ${API} -eq 1 ]]; then
|
||||||
if [[ -z "${CA_NEW_AUTHZ}" ]] || [[ -z "${CA_NEW_CERT}" ]]; then
|
if [[ -z "${CA_NEW_AUTHZ}" ]] || [[ -z "${CA_NEW_CERT}" ]]; then
|
||||||
@@ -1253,14 +1248,19 @@ command_sign_csr() {
|
|||||||
|
|
||||||
init_system
|
init_system
|
||||||
|
|
||||||
|
# load csr
|
||||||
csrfile="${1}"
|
csrfile="${1}"
|
||||||
if [ ! -r "${csrfile}" ]; then
|
if [ ! -r "${csrfile}" ]; then
|
||||||
_exiterr "Could not read certificate signing request ${csrfile}"
|
_exiterr "Could not read certificate signing request ${csrfile}"
|
||||||
fi
|
fi
|
||||||
|
csr="$(cat "${csrfile}")"
|
||||||
|
|
||||||
|
# extract names
|
||||||
|
altnames="$(extract_altnames "${csr}")"
|
||||||
|
|
||||||
# gen cert
|
# gen cert
|
||||||
certfile="$(_mktemp)"
|
certfile="$(_mktemp)"
|
||||||
sign_csr "$(< "${csrfile}" )" 3> "${certfile}"
|
sign_csr "${csr}" ${altnames} 3> "${certfile}"
|
||||||
|
|
||||||
# print cert
|
# print cert
|
||||||
echo "# CERT #" >&3
|
echo "# CERT #" >&3
|
||||||
|
|||||||
Reference in New Issue
Block a user