get_all_keys.sh: fix error in case og old easyrsa layout (revert to previos version).

This commit is contained in:
Christoph 2019-07-16 16:56:06 +02:00
parent 08016ed7b2
commit 53c1600d3c
2 changed files with 26 additions and 12 deletions

Binary file not shown.

View File

@ -253,21 +253,35 @@ else
info "No revoked keys in \033[1m${OPENVPN_REVOKED_KEY_DIR}\033[m for OpenVPN service \033[1m$service_name\033[m exists."
fi
while IFS= read -r -d '' _cert ; do
if $EASYRSA_LAYOUT_NEW ; then
while IFS= read -r -d '' _cert ; do
_serial="$(basename "$_cert")"
_serial="${_serial%.*}"
_serial="$(basename "$_cert")"
_serial="${_serial%.*}"
_cn="$(openssl x509 -noout -text -in $_cert | grep Subject: | grep -oE "CN\s*=\s*[^,]+" | awk '{print$3}')"
if ! containsElement "$_cn" "${all_cn_arr[@]}" ; then
_cn="$(openssl x509 -noout -text -in $_cert | grep Subject: | grep -oE "CN\s*=\s*[^,]+" | awk '{print$3}')"
if ! containsElement "$_cn" "${all_cn_arr[@]}" ; then
all_arr+=("${_serial}:$(trim $_cn)")
all_cn_arr+=("$(trim $_cn)")
fi
if ! containsElement "$_cn" "${revoked_cn_arr[@]}" ; then
active_arr+=("${_serial}:$(trim $_cn)")
fi
done < <(find ${OPENVPN_CERT_DIR_SERIAL} -name "*\.pem" -print0 | sort -z )
else
while IFS= read -r -d '' _cert ; do
_serial="$(basename "$_cert")"
_serial="${_serial%.*}"
_cn="$(openssl x509 -noout -text -in $_cert | grep Subject: | grep -oE "CN\s*=\s*[^,]+" | awk '{print$3}')"
all_arr+=("${_serial}:$(trim $_cn)")
all_cn_arr+=("$(trim $_cn)")
fi
if ! containsElement "$_cn" "${revoked_cn_arr[@]}" ; then
active_arr+=("${_serial}:$(trim $_cn)")
fi
done < <(find ${OPENVPN_CERT_DIR_SERIAL} -name "*\.pem" -print0 | sort -z )
if ! containsElement "$_cn" "${revoked_cn_arr[@]}" ; then
active_arr+=("${_serial}:$(trim $_cn)")
fi
done < <(find ${OPENVPN_KEY_DIR} -name "??\.pem" -print0 | sort -z )
fi
if [[ ${#all_arr[@]} -gt 0 ]]; then
echo ""