Skip to content

Commit

Permalink
Clean up logic for determining the OpenSSL command to list ciphers
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticdog committed May 25, 2018
1 parent b335cbd commit a7e8aef
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions transcrypt
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,16 @@ run_safety_checks() {

# unset the cipher variable if it is not supported by openssl
validate_cipher() {
# Support for OpenSSL versions after and before 1.1.0
local list_cipher_commands="openssl list-cipher-commands"
if [[ $($list_cipher_commands 2> /dev/null) ]]; then
local supported=$(openssl list-cipher-commands | grep --line-regexp "$cipher")
local list_cipher_commands
if openssl list-cipher-commands &> /dev/null; then
# OpenSSL < v1.1.0
list_cipher_commands='openssl list-cipher-commands'
else
list_cipher_commands="openssl list -cipher-commands"
local supported=$(openssl list -cipher-commands | tr -s ' ' '\n' | grep --line-regexp "$cipher")
# OpenSSL >= v1.1.0
list_cipher_commands='openssl list -cipher-commands'
fi

local supported=$($list_cipher_commands | tr -s ' ' '\n' | grep --line-regexp "$cipher")
if [[ ! $supported ]]; then
if [[ $interactive ]]; then
printf '"%s" is not a valid cipher; choose one of the following:\n\n' "$cipher"
Expand Down

0 comments on commit a7e8aef

Please sign in to comment.