Skip to content

Commit

Permalink
inline_file(): Provide full header details
Browse files Browse the repository at this point in the history
Signed-off-by: Richard T Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Aug 6, 2024
1 parent 17a759b commit 6f366e6
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions easyrsa3/easyrsa
Original file line number Diff line number Diff line change
Expand Up @@ -2955,27 +2955,44 @@ inline_file() {
easyrsa_mkdir "${EASYRSA_PKI}/inline"
inline_incomplete=

# Generate fingerprint
crt_fingerprint="$(
"$EASYRSA_OPENSSL" x509 -in "$crt_source" \
-noout -sha256 -fingerprint
)" || die "inline_file - Failed -fingerprint"
# strip prefix
crt_fingerprint="${crt_fingerprint#*=}"

# Generate Inline data
# Certificate
if [ -f "$crt_source" ]; then
crt_data="\
<cert>
$(cat "$crt_source")
</cert>"

# Generate fingerprint
crt_fingerprint="$(
"$EASYRSA_OPENSSL" x509 -in "$crt_source" \
-noout -sha256 -fingerprint
)" || die "inline_file - Failed -fingerprint"
# strip prefix
crt_fingerprint="${crt_fingerprint#*=}"

# Certificate type
if [ -z "$crt_type" ]; then
ssl_cert_x509v3_eku "$crt_source" crt_type || \
die "inline_file: Failed to set crt_type"
fi

# commonName
crt_CN="$(
display_dn x509 "$crt_source" | grep 'commonName'
)" || die "inline_file: Failed to set crt_CN"
# strip prefix
crt_CN="${crt_CN#*= }"
else
inline_incomplete=1
crt_data="\
<cert>
* Paste your user certificate here *
</cert>"

crt_fingerprint=unknown
crt_type=unknown
crt_CN=unknown
fi

# Private key
Expand Down Expand Up @@ -3009,7 +3026,8 @@ $(cat "$ca_source")
# Print data
print "\
# Easy-RSA Inline file
# Name: ${1}
# Certificate type: $crt_type
# commonName: $crt_CN
# SHA256 fingerprint:
# $crt_fingerprint

Expand Down

0 comments on commit 6f366e6

Please sign in to comment.