Skip to content

Commit

Permalink
Modifications for shellcheck (NFC)
Browse files Browse the repository at this point in the history
Signed-off-by: Richard T Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Mar 8, 2022
1 parent 640a6ed commit 507f96b
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions easytls
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ cleanup () {
# non-fatal warning output
warn () {
[ -z "${EASYTLS_SILENT}" ] || return 0
print "
print "
WARNING:
${1}
" 1>&2
Expand All @@ -594,7 +594,7 @@ WARNING:
notice () {
[ -z "${EASYTLS_QUIET}" ] || return 0
[ -z "${EASYTLS_SILENT}" ] || return 0
print "
print "
${1}"
} # => notice ()

Expand Down Expand Up @@ -634,8 +634,7 @@ verify_pki_init () {
error_msg "Easy-RSA has not been initialised."
error_msg "Easy-TLS requires an Easy-RSA CA"
error_msg "Otherwise, use Easy-TLS in No-CA mode"
# shellcheck disable=2312
error_msg "$(cmd_help init-tls)"
error_msg "$(cmd_help init-tls||:)"
return 1
# die "verify_pki_init - vars_source_check"
}
Expand All @@ -646,8 +645,7 @@ verify_pki_init () {
error_msg "Easy-RSA has not been initialised."
error_msg "Easy-TLS requires an Easy-RSA CA"
error_msg "Otherwise, use Easy-TLS in No-CA mode"
# shellcheck disable=2312
error_msg "$(cmd_help init-tls)"
error_msg "$(cmd_help init-tls||:)"
return 1
# die "verify_pki_init - private reqs"
}
Expand Down Expand Up @@ -1764,6 +1762,7 @@ authorityKeyIdentifier = keyid:always,issuer
} # => easytls_ssl_file ()

# SSL hash of empty data for forbidden hash
# shellcheck disable=SC2031 # modified in a subshell
ssl_generate_empty_hash ()
{
[ -n "${unlock_ssl}" ] || return 1
Expand All @@ -1772,6 +1771,7 @@ ssl_generate_empty_hash ()
} # => ssl_generate_empty_hash ()

# Extract the forbidden empty_hash from SSL hash
# shellcheck disable=SC2030 # subshell modification
easytls_ssl_generate_empty_hash ()
{
error_msg "easytls_ssl_generate_empty_hash - ssl_out"
Expand Down Expand Up @@ -1799,13 +1799,15 @@ ssl_generate_old_master_data_hash ()
} # => openssl_generate_data_hash ()

# SSL file via command hash output
# shellcheck disable=SC2031 # modified in a subshell
ssl_generate_file_hash ()
{
[ -n "${unlock_ssl}" ] || return 1
"${EASYRSA_OPENSSL}" dgst -"${EASYTLS_HASH_ALGO}" -r "${1}" || return 1
} # => ssl_generate_file_hash ()

# easytls wrapper for ssl file hash
# shellcheck disable=SC2030 # subshell modification
easytls_ssl_generate_file_hash ()
{
# input MUST be an existing file-name
Expand All @@ -1825,13 +1827,15 @@ easytls_ssl_generate_file_hash ()
} # => easytls_ssl_encode_base64_data ()

# SSL data in via pipe hash output
# shellcheck disable=SC2031 # modified in a subshell
ssl_generate_data_hash ()
{
[ -n "${unlock_ssl}" ] || return 1
"${EASYRSA_OPENSSL}" dgst -"${EASYTLS_HASH_ALGO}" -r || return 1
} # => ssl_generate_data_hash ()

# easytls wrapper for ssl data hash
# shellcheck disable=SC2030 # subshell modification
easytls_ssl_generate_data_hash ()
{
# input MUST not be a file-name
Expand All @@ -1852,13 +1856,15 @@ easytls_ssl_generate_data_hash ()
} # => easytls_ssl_generate_data_hash ()

# SSL Base64 encode output
# shellcheck disable=SC2031 # modified in a subshell
ssl_encode_base64_data ()
{
[ -n "${unlock_ssl}" ] || return 1
"${EASYRSA_OPENSSL}" enc -e -a -A || return 1
} # => ssl_encode_base64_data ()

# easytls wrapper for ssl Base64 encode data
# shellcheck disable=SC2030 # subshell modification
easytls_ssl_encode_base64_data ()
{
error_msg "easytls_ssl_encode_base64_data - ssl_out"
Expand All @@ -1871,13 +1877,15 @@ easytls_ssl_encode_base64_data ()
} # => easytls_ssl_encode_base64_data ()

# SSL -enddate output
# shellcheck disable=SC2031 # modified in a subshell
ssl_cert_expire_date ()
{
[ -n "${unlock_ssl}" ] || return 1
"${EASYRSA_OPENSSL}" x509 -in "${1}" -noout -enddate || return 1
} # => openssl_cert_expire_date ()

# Extract expire date from SSL -enddate
# shellcheck disable=SC2030 # subshell modification
easytls_ssl_cert_expire_date ()
{
error_msg "easytls_ssl_cert_expire_date - ssl_out"
Expand All @@ -1890,13 +1898,15 @@ easytls_ssl_cert_expire_date ()
} # => easytls_ssl_generate_fingerprint ()

# SSL -purpose output (List of purposes Yes/No)
# shellcheck disable=SC2031 # modified in a subshell
ssl_cert_purpose ()
{
[ -n "${unlock_ssl}" ] || return 1
"${EASYRSA_OPENSSL}" x509 -in "${1}" -noout -purpose || return 1
} # => openssl_cert_purpose ()

# Return the purpose-list from SSL -purpose
# shellcheck disable=SC2030 # subshell modification
easytls_ssl_cert_purpose ()
{
error_msg "easytls_ssl_cert_purpose - ssl_out"
Expand All @@ -1909,13 +1919,15 @@ easytls_ssl_cert_purpose ()
} # => easytls_ssl_generate_fingerprint ()

# SSL -fingerprint output
# shellcheck disable=SC2031 # modified in a subshell
ssl_generate_fingerprint ()
{
[ -n "${unlock_ssl}" ] || return 1
"${EASYRSA_OPENSSL}" x509 -in "${1}" -noout -sha256 -fingerprint || return 1
} # => ssl_generate_fingerprint ()

# Extract the fingerprint from SSL -fingerprint
# shellcheck disable=SC2030 # subshell modification
easytls_ssl_generate_fingerprint ()
{
error_msg "easytls_ssl_generate_fingerprint - ssl_out"
Expand All @@ -1928,13 +1940,15 @@ easytls_ssl_generate_fingerprint ()
} # => easytls_ssl_generate_fingerprint ()

# SSL -serial output
# shellcheck disable=SC2031 # modified in a subshell
ssl_cert_serial ()
{
[ -n "${unlock_ssl}" ] || return 1
"${EASYRSA_OPENSSL}" x509 -in "${1}" -noout -serial || return 1
} # => ssl_cert_serial ()

# Extract the serialNumber from OpenSSL -serial
# shellcheck disable=SC2030 # subshell modification
easytls_ssl_cert_serial ()
{
error_msg "easytls_ssl_cert_serial - ssl_out"
Expand All @@ -1947,6 +1961,7 @@ easytls_ssl_cert_serial ()
} # => easytls_ssl_cert_serial ()

# SSL -subject output and grep for commonName
# shellcheck disable=SC2031 # modified in a subshell
ssl_crt_common_name ()
{
[ -n "${unlock_ssl}" ] || return 1
Expand All @@ -1956,6 +1971,7 @@ ssl_crt_common_name ()
} # => ssl_crt_common_name ()

# Extract the CommonName from OpenSSL -subject
# shellcheck disable=SC2030 # subshell modification
easytls_ssl_crt_common_name ()
{
error_msg "easytls_ssl_crt_common_name - ssl_out"
Expand Down Expand Up @@ -9142,6 +9158,7 @@ shellcheck_ignore_2154 ()
EASYTLS_TEMP_LIST=
EASYTLS_TEMP_RECORD=
EASYTLS_TEMP_LOCK=
EASYTLS_TEMP_DELETED=

EASYTLS_CA_IDENTITY=
TLSKEY_SUBNAME=
Expand Down Expand Up @@ -9181,6 +9198,8 @@ external_deps ()
'
new_line='
'
# MUST be unset
unset unlock_ssl

# Testing
validate_hash_block=0
Expand Down

0 comments on commit 507f96b

Please sign in to comment.