From 1c90df94ea504fa8e1f73d95709329b5c8271456 Mon Sep 17 00:00:00 2001 From: Josh Cepek Date: Wed, 11 Dec 2013 12:01:04 -0600 Subject: [PATCH] Fix incorrect handling of invalid --use-algo option The prior warn/fallback to rsa didn't work, and fallback is probably the wrong thing to do, especially for batch callers. It is now an error to supply an invalid value. No need to export the EASYRSA_ALGO_PARAMS either. Signed-off-by: Josh Cepek --- easyrsa3/easyrsa | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/easyrsa3/easyrsa b/easyrsa3/easyrsa index eafafe9..4935164 100755 --- a/easyrsa3/easyrsa +++ b/easyrsa3/easyrsa @@ -966,14 +966,13 @@ Note: using Easy-RSA configuration from: $vars" else set_var EASYRSA_EXT_DIR "$EASYRSA/x509-types" fi - # EASYRSA_ALGO_PARAMS must be set depending on config. Defaults to rsa - if [ $EASYRSA_ALGO = "ec" ]; then - export EASYRSA_ALGO_PARAMS="$EASYRSA_EC_DIR/${EASYRSA_CURVE}.pem" + # EASYRSA_ALGO_PARAMS must be set depending on selected algo + if [ "ec" = "$EASYRSA_ALGO" ]; then + EASYRSA_ALGO_PARAMS="$EASYRSA_EC_DIR/${EASYRSA_CURVE}.pem" + elif [ "rsa" = "$EASYRSA_ALGO" ]; then + EASYRSA_ALGO_PARAMS="${EASYRSA_KEY_SIZE}" else - export EASYRSA_ALGO_PARAMS="${EASYRSA_KEY_SIZE}" - # Warn if the ALGO isn't rsa as we default to rsa anyway - [ "$EASYRSA_ALGO" = "rsa" ] || warn "\ -Warning: unknown algo '$EASYRSA_ALGO' -- using rsa default" + die "Alg '$EASYRSA_ALGO' is invalid: must be 'rsa' or 'ec'" fi # Setting OPENSSL_CONF prevents bogus warnings (especially useful on win32)