gen-req, sign-req, build-full: Verify requirements correctly

* gen-req: Use verify_pki_init().
* sign-req: Use verify_ca_init().
* build-full: Defer requirements to functions above.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
Richard T Bonhomme 2023-05-01 20:32:49 +01:00
parent 8451adee6b
commit f92fa738a9
No known key found for this signature in database
GPG Key ID: 2D767DB92FB6C246

View File

@ -1729,6 +1729,9 @@ DH parameters of size $EASYRSA_KEY_SIZE created at:
# gen-req and key backend: # gen-req and key backend:
gen_req() { gen_req() {
# Verify PKI has been initialised
verify_pki_init
# pull filename, use as default interactive CommonName # pull filename, use as default interactive CommonName
[ "$1" ] || die "\ [ "$1" ] || die "\
Error: gen-req must have a file base as the first argument. Error: gen-req must have a file base as the first argument.
@ -1756,9 +1759,6 @@ Run easyrsa without commands for usage and commands."
shift # scrape off file-name shift # scrape off file-name
# Verify PKI has been initialised
verify_pki_init
# function opts support # function opts support
while [ "$1" ]; do while [ "$1" ]; do
case "$1" in case "$1" in
@ -1860,6 +1860,9 @@ Keypair and certificate request completed. Your files are:
# common signing backend # common signing backend
sign_req() { sign_req() {
# CA is required to sign
verify_ca_init
crt_type="$1" crt_type="$1"
req_in="$EASYRSA_PKI/reqs/$2.req" req_in="$EASYRSA_PKI/reqs/$2.req"
crt_out="$EASYRSA_PKI/issued/$2.crt" crt_out="$EASYRSA_PKI/issued/$2.crt"
@ -2114,8 +2117,6 @@ Certificate created at:
# common build backend # common build backend
# used to generate+sign in 1 step # used to generate+sign in 1 step
build_full() { build_full() {
verify_ca_init
# pull filename base: # pull filename base:
[ "$2" ] || die "\ [ "$2" ] || die "\
Error: didn't find a file base name as the first argument. Error: didn't find a file base name as the first argument.