Skip to content

Commit

Permalink
renew: Ensure request and certificate commonName matches
Browse files Browse the repository at this point in the history
Signed-off-by: Richard T Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Jul 30, 2024
1 parent 12d8fef commit 4786a14
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dev/easyrsa-tools.lib
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,21 @@ Missing request file:
* $req_in"
fi

# Get cert commonName
cert_CN="$(
display_dn x509 "$crt_in" | grep 'commonName'
)" || die "renew - display_dn of cert failed"

# Get req commonName
req_CN="$(
display_dn req "$req_in" | grep 'commonName'
)" || die "renew - display_dn of req failed"

# For renew, cert_CN must match req_CN
[ "$cert_CN" = "$req_CN" ] || user_error \
"Certificate cannot be renewed due to commonName mismatch"
verbose "renew - cert_CN MATCH req_CN"

# get the serial number of the certificate
ssl_cert_serial "$crt_in" cert_serial || \
die "$cmd: Failed to get cert serial number!"
Expand Down

0 comments on commit 4786a14

Please sign in to comment.