Check status of command, not exit-code, in default_server_san()

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
Richard T Bonhomme 2022-04-19 15:27:20 +01:00
parent 60f3fc2728
commit adc2cbed58
No known key found for this signature in database
GPG Key ID: 2D767DB92FB6C246

View File

@ -1991,10 +1991,8 @@ default_server_san() {
easyrsa_openssl req -in "$path" -noout -subject -nameopt sep_multiline |
awk -F'=' '/^ *CN=/{print $2}'
)
echo "$cn" | grep -E -q '^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'
# Check exit code directly with e.g. if mycmd;, not indirectly with $?.
# shellcheck disable=SC2181
if [ $? -eq 0 ]; then
if echo "$cn" | grep -E -q '^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'; then
print "subjectAltName = IP:$cn"
else
print "subjectAltName = DNS:$cn"