Skip to content

Commit

Permalink
Add explicit confirmation for default 'pki/vars' setting a different PKI
Browse files Browse the repository at this point in the history
If the default 'pki/vars' exists and sets EASYRSA_PKI to a different PKI,
anything other than "$PWD/pki", then issue a warning with an explicit user
confirmation to proceed with this invalid configuration.

This is a left-over by-product of trying to move the vars file to the PKI.

Problem: 'pki/vars' sets EASYRSA_PKI to a different PKI.

Conclusion: Easy-RSA v3.1.7 does NOT support a vars file in the PKI.

Signed-off-by: Richard T Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Sep 4, 2023
1 parent b9914c6 commit 4283ad2
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion easyrsa3/easyrsa
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,13 @@ vars_in_pki_msg() {
return
fi

# Resolve setting EASYRSA_PKI in vars file
# when vars file is default 'pki/vars'
# and potentially points to a different PKI.
# Once resolved, a user set PKI will over-rule
# a vars setting and this message can be disabled
#return

information "
IMPORTANT:
Do NOT keep your 'vars' within your PKI directory.
Expand Down Expand Up @@ -5656,8 +5663,10 @@ setup_vars() {
[ -e "$prog_vars" ] && e_prog_vars=1

# PKI location, if present:
[ -e "$pki_vars" ] && e_pki_vars=1 && \
if [ -e "$pki_vars" ]; then
e_pki_vars=1
vars_in_pki=1
fi

# Count found vars files
found_vars="$((
Expand All @@ -5680,6 +5689,9 @@ setup_vars() {
vars="$prog_vars"
elif [ "$e_pki_vars" ]; then
vars="$pki_vars"
# Set expected_pki
# to stop vars changing EASYRSA_PKI
expected_pki="${pki_vars%/*}"
else
# This cannot happen
die "Detecting vars file failed!"
Expand Down Expand Up @@ -5708,6 +5720,9 @@ or remove the 'vars' files which are not in use.${NL}"
vars="$prog_vars"
elif [ "$e_pki_vars" ]; then
vars="$pki_vars"
# Set expected_pki
# to stop vars changing EASYRSA_PKI
expected_pki="${pki_vars%/*}"
else
# This cannot happen
die "Detecting vars file failed!"
Expand Down Expand Up @@ -5863,6 +5878,31 @@ Algorithm '$EASYRSA_ALGO' is invalid: Must be 'rsa', 'ec' or 'ed'"

set_var EASYRSA_MAX_TEMP 4

# expected_pki is set when default 'pki/vars' is used
# This blocks pki/vars changing EASYRSA_PKI
if [ "$expected_pki" ] # && [ "$require_pki" ]
then
if [ "$expected_pki" = "$EASYRSA_PKI" ]
then
: # ok
else
# Show warning
warn "\
'EASYRSA_PKI' is set incorrectly in the 'vars' file.

This vars file:
* $vars

Uses this PKI:
* $EASYRSA_PKI"

# Require user consent to continue
confirm "
Continue with this configuration ? " yes "
'vars' configuration for 'EASYRSA_PKI' is invalid."
fi
fi

# if the vars file in use is not in the PKI
# and not user defined then Show the messages
if [ "$require_pki" ]; then
Expand Down Expand Up @@ -7018,6 +7058,7 @@ detect_host

# Initialisation requirements
unset -v \
expected_pki \
verify_ssl_lib_ok \
secured_session \
working_safe_ssl_conf working_safe_org_conf \
Expand Down

0 comments on commit 4283ad2

Please sign in to comment.