Skip to content

Commit

Permalink
Implement wrapper function write_x509_type_tmp()
Browse files Browse the repository at this point in the history
write_x509_type_tmp():
* Input: X509 type
* Output: Temp file of the type specified, named $x509_tmp

Applied to command sign-req, for types COMMON and requested type.

Signed-off-by: Richard T Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Dec 6, 2023
1 parent 3c0ca17 commit 7df3026
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions easyrsa3/easyrsa
Original file line number Diff line number Diff line change
Expand Up @@ -2158,14 +2158,8 @@ Writing 'copy_exts' to SSL config temp-file failed"
x509_type_file="$EASYRSA_EXT_DIR/$crt_type"
else
# Use a temp file
x509_type_tmp=""
easyrsa_mktemp x509_type_tmp || \
die "sign_req - easyrsa_mktemp x509_type_tmp"

create_x509_type "$crt_type" > "$x509_type_tmp" || \
die "sign_req - create_x509_type $crt_type"

x509_type_file="$x509_type_tmp"
write_x509_type_tmp "$crt_type"
x509_type_file="$x509_tmp"
fi

# Find or create x509 COMMON file
Expand All @@ -2174,14 +2168,8 @@ Writing 'copy_exts' to SSL config temp-file failed"
x509_COMMON_file="$EASYRSA_EXT_DIR/COMMON"
else
# Use a temp file
x509_COMMON_tmp=""
easyrsa_mktemp x509_COMMON_tmp || \
die "sign_req - easyrsa_mktemp x509_COMMON_tmp"

create_x509_type COMMON > "$x509_COMMON_tmp" || \
die "sign_req - create_x509_type COMMON"

x509_COMMON_file="$x509_COMMON_tmp"
write_x509_type_tmp COMMON
x509_COMMON_file="$x509_tmp"
fi

# Support a dynamic CA path length when present:
Expand Down Expand Up @@ -5957,6 +5945,24 @@ force_set_var() {
############################################################################
#
# Create X509-type files

# Write x509 type file to a temp file
write_x509_type_tmp() {
# Use a temp file
type="$1"
shift

x509_tmp=""
easyrsa_mktemp x509_tmp || \
die "write_x509_type_tmp - easyrsa_mktemp x509_tmp"

create_x509_type "$type" > "$x509_tmp" || \
die "write_x509_type_tmp - create_x509_type $type"

verbose "write_x509_type_tmp: $type COMPLETE"
} # => write_x509_type_tmp()

# Create x509 type
create_x509_type() {
case "$1" in
COMMON)
Expand Down

0 comments on commit 7df3026

Please sign in to comment.