mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-05-17 04:17:00 +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:
+9
-9
@@ -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
|
||||||
@@ -937,7 +932,7 @@ sign_domain() {
|
|||||||
|
|
||||||
crt_path="${certdir}/cert-${timestamp}.pem"
|
crt_path="${certdir}/cert-${timestamp}.pem"
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
sign_csr "$(< "${certdir}/cert-${timestamp}.csr" )" ${altnames} 3>"${crt_path}"
|
sign_csr "$(< "${certdir}/cert-${timestamp}.csr")" ${altnames} 3>"${crt_path}"
|
||||||
|
|
||||||
# Create fullchain.pem
|
# Create fullchain.pem
|
||||||
echo " + Creating fullchain.pem..."
|
echo " + Creating fullchain.pem..."
|
||||||
@@ -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