Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status reports: Warn if given commonName is not found in database #911

Merged
merged 3 commits into from
Mar 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions easyrsa3/easyrsa
Original file line number Diff line number Diff line change
Expand Up @@ -4084,6 +4084,8 @@ read_db() {
db_in="$EASYRSA_PKI/index.txt"
pki_r_issued="$EASYRSA_PKI/renewed/issued"
pki_r_by_sno="$EASYRSA_PKI/renewed/certs_by_serial"
unset -v target_found

while read -r db_status db_notAfter db_record; do

# Interpret the db/certificate record
Expand Down Expand Up @@ -4124,7 +4126,10 @@ read_db() {
V|E)
case "$target" in
'') expire_status ;;
*) [ "$target" = "$db_cn" ] && expire_status
*)
if [ "$target" = "$db_cn" ]; then
expire_status
fi
esac
;;
*)
Expand All @@ -4136,7 +4141,10 @@ read_db() {
if [ "$db_status" = R ]; then
case "$target" in
'') revoke_status ;;
*) [ "$target" = "$db_cn" ] && revoke_status
*)
if [ "$target" = "$db_cn" ]; then
revoke_status
fi
esac
fi
;;
Expand All @@ -4145,13 +4153,28 @@ read_db() {
if [ "$db_status" = V ]; then
case "$target" in
'') renew_status ;;
*) [ "$target" = "$db_cn" ] && renew_status
*)
if [ "$target" = "$db_cn" ]; then
renew_status
fi
esac
fi
;;
*) die "Unrecognised report: $report"
esac

# Is db record for target found
if [ "$target" = "$db_cn" ]; then
target_found=1
fi

done < "$db_in"

# Check for target found/valid commonName, if given
if [ "$target" ]; then
[ "$target_found" ] || \
warn "Certificate for $target was not found"
fi
} # => read_db()

# Expire status
Expand Down Expand Up @@ -5750,10 +5773,14 @@ esac

# Check for untrapped errors
# shellcheck disable=SC2181
[ $? = 0 ] || warn "Untrapped error detected!"
if [ $? = 0 ]; then
# Do 'cleanup ok' on successful completion
#print "mktemp_counter: $mktemp_counter uses"
cleanup ok
fi

# Do 'cleanup ok' on successful completion
#print "mktemp_counter: $mktemp_counter uses"
cleanup ok
# Otherwise, exit with error
warn "Untrapped error detected!"
cleanup

# vim: ft=sh nu ai sw=8 ts=8 noet