Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit a7e8aef

Browse files
committed
Clean up logic for determining the OpenSSL command to list ciphers
1 parent b335cbd commit a7e8aef

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

transcrypt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,16 @@ run_safety_checks() {
136136

137137
# unset the cipher variable if it is not supported by openssl
138138
validate_cipher() {
139-
# Support for OpenSSL versions after and before 1.1.0
140-
local list_cipher_commands="openssl list-cipher-commands"
141-
if [[ $($list_cipher_commands 2> /dev/null) ]]; then
142-
local supported=$(openssl list-cipher-commands | grep --line-regexp "$cipher")
139+
local list_cipher_commands
140+
if openssl list-cipher-commands &> /dev/null; then
141+
# OpenSSL < v1.1.0
142+
list_cipher_commands='openssl list-cipher-commands'
143143
else
144-
list_cipher_commands="openssl list -cipher-commands"
145-
local supported=$(openssl list -cipher-commands | tr -s ' ' '\n' | grep --line-regexp "$cipher")
144+
# OpenSSL >= v1.1.0
145+
list_cipher_commands='openssl list -cipher-commands'
146146
fi
147+
148+
local supported=$($list_cipher_commands | tr -s ' ' '\n' | grep --line-regexp "$cipher")
147149
if [[ ! $supported ]]; then
148150
if [[ $interactive ]]; then
149151
printf '"%s" is not a valid cipher; choose one of the following:\n\n' "$cipher"

0 commit comments

Comments
 (0)