Skip to content

Commit c3f8207

Browse files
committed
Fix Travis + mv issuer line down
Travis failure was due to debug output in function which return a string. The debug statement was removed, (stderr would have been choice \#2). Issuer is heading now the intermediate certificate section, not sure whethe this is redundant info.
1 parent d5a64ff commit c3f8207

1 file changed

Lines changed: 51 additions & 49 deletions

File tree

testssl.sh

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,10 +1992,10 @@ elif "$HAS_FREEBSDDATE"; then # FreeBSD, OS X and newer (~6.6) OpenBSD vers
19921992
LC_ALL=C TZ=GMT date -j -f "$3" "$2" "$1"
19931993
}
19941994
elif "$HAS_OPENBSDDATE"; then
1995-
# We bascially echo it as a conversion as we want it is too difficult. Approach for that would be:
1996-
# printf '%s\n' "$1" | awk '{ printf "%04d%02d%02d\n", $4, $2, (index("JanFebMarAprMayJunJulAugSepOctNovDec",$1)+2)/3}'
1997-
# 4: year, 1: month, 2: day, $3: time (e.g. "Dec 8 10:16:13 2016")
1998-
# This way we could also kind of convert args to epoch but as newer OpenBSDs "date" behave like FreeBSD
1995+
# We bascially echo it as a conversion as we want it is too difficult. Approach for that would be:
1996+
# printf '%s\n' "$1" | awk '{ printf "%04d%02d%02d\n", $4, $2, (index("JanFebMarAprMayJunJulAugSepOctNovDec",$1)+2)/3}'
1997+
# 4: year, 1: month, 2: day, $3: time (e.g. "Dec 8 10:16:13 2016")
1998+
# This way we could also kind of convert args to epoch but as newer OpenBSDs "date" behave like FreeBSD
19991999
parse_date() {
20002000
local tmp=""
20012001
if [[ $2 == +%s* ]]; then
@@ -2011,8 +2011,9 @@ else
20112011
}
20122012
fi
20132013

2014-
# arg1: An ASCII-HEX string
2015-
# Print $arg1 in binary format
2014+
2015+
# Print $arg1 in binary format. arg1: An ASCII-HEX string
2016+
#
20162017
asciihex_to_binary() {
20172018
local string="$1"
20182019
local -i len
@@ -8348,7 +8349,6 @@ determine_dates_certificate() {
83488349
startdate="${startdate%%GMT*}GMT"
83498350
enddate="${cert_txt#*Validity*Not Before: *Not After : }"
83508351
enddate="${enddate%%GMT*}GMT"
8351-
debugme echo "$enddate - $startdate"
83528352
# Now we have a normalized enddate and startdate like "Feb 27 10:03:20 2017 GMT" -- also for OpenBSD
83538353
if "$HAS_OPENBSDDATE"; then
83548354
# Best we want to do under old versions of OpenBSD, first just remove the GMT and keep start/endate for later output
@@ -8866,49 +8866,13 @@ certificate_info() {
88668866
fi
88678867
fi
88688868

8869-
out "$indent"; pr_bold " Issuer "
8870-
jsonID="cert_caIssuers"
8871-
#FIXME: oid would be better maybe (see above). And the line by line input could be done w/o awk
8869+
# Determine the issuer now as we need them for host certificate warning
88728870
issuer="$($OPENSSL x509 -noout -issuer -nameopt multiline,-align,sname,-esc_msb,utf8,-space_eq 2>>$ERRFILE <<< "$hostcert")"
88738871
issuer_CN="$(awk -F'=' '/CN=/ { print $2 }' <<< "$issuer")"
88748872
issuer_O="$(awk -F'=' '/O=/ { print $2 }' <<< "$issuer")"
88758873
issuer_C="$(awk -F'=' '/ C=/ { print $2 }' <<< "$issuer")"
88768874
issuer_DC="$(awk -F'=' '/DC=/ { print $2 }' <<< "$issuer")"
88778875

8878-
if [[ "$issuer_O" == issuer= ]] || [[ "$issuer_O" == issuer=\ ]] || [[ "$issuer_CN" == "$cn" ]]; then
8879-
prln_svrty_critical "self-signed (NOT ok)"
8880-
fileout "${jsonID}${json_postfix}" "CRITICAL" "selfsigned"
8881-
set_grade_cap "T" "Self-signed certificate"
8882-
else
8883-
issuerfinding="$issuer_CN"
8884-
pr_italic "$issuer_CN"
8885-
if [[ -z "$issuer_O" ]] && [[ -n "$issuer_DC" ]]; then
8886-
for san in $issuer_DC; do
8887-
if [[ -z "$issuer_O" ]]; then
8888-
issuer_O="${san}"
8889-
else
8890-
issuer_O="${san}.${issuer_O}"
8891-
fi
8892-
done
8893-
fi
8894-
if [[ -n "$issuer_O" ]]; then
8895-
issuerfinding+=" ("
8896-
out " ("
8897-
issuerfinding+="$issuer_O"
8898-
pr_italic "$issuer_O"
8899-
if [[ -n "$issuer_C" ]]; then
8900-
issuerfinding+=" from "
8901-
out " from "
8902-
issuerfinding+="$issuer_C"
8903-
pr_italic "$issuer_C"
8904-
fi
8905-
issuerfinding+=")"
8906-
out ")"
8907-
fi
8908-
outln
8909-
fileout "${jsonID}${json_postfix}" "INFO" "$issuerfinding"
8910-
fi
8911-
89128876
out "$indent"; pr_bold " Trust (hostname) "
89138877
compare_server_name_to_cert "$HOSTCERT"
89148878
trust_sni=$?
@@ -9054,7 +9018,7 @@ certificate_info() {
90549018
out "no "
90559019
fileout "${jsonID}${json_postfix}" "INFO" "no"
90569020
fi
9057-
debugme echo "($(newline_to_spaces "$policy_oid"))"
9021+
debugme1 echo -n "($(newline_to_spaces "$policy_oid"))"
90589022
outln
90599023
#TODO: check browser OIDs:
90609024
# https://dxr.mozilla.org/mozilla-central/source/security/certverifier/ExtendedValidation.cpp
@@ -9072,7 +9036,7 @@ certificate_info() {
90729036
days2warn1=$((days2warn1 / 2))
90739037
fi
90749038

9075-
debugme echo -n "diffseconds: $diffseconds"
9039+
debugme echo -n "(diffseconds: $diffseconds)"
90769040
if ! [[ "$($OPENSSL x509 -checkend 1 2>>$ERRFILE <<< "$hostcert")" =~ \ not\ ]]; then
90779041
pr_svrty_critical "expired"
90789042
expfinding="expired"
@@ -9154,7 +9118,7 @@ certificate_info() {
91549118
else
91559119
# All is fine with validity period
91569120
# We ignore for now certificates < 2018/03/01. On the screen we only show debug info
9157-
debugme1 outln "${spaces}DEBUG: all is fine with total certificate life time"
9121+
debugme1 echo "${spaces}DEBUG: all is fine with total certificate life time"
91589122
fileout "cert_extlifeSpan${json_postfix}" "OK" "certificate has no extended life time according to browser forum"
91599123
fi
91609124

@@ -9298,7 +9262,7 @@ certificate_info() {
92989262
caa_node=${caa_node#*.}
92999263
done
93009264
if [[ -n "$caa" ]]; then
9301-
pr_svrty_good "available"; out " - please check for match with \"Issuer\" above"
9265+
pr_svrty_good "available"; out " - please check for match with \"Issuer\" below"
93029266
if [[ $(count_lines "$caa") -eq 1 ]]; then
93039267
out ": "
93049268
else
@@ -9344,6 +9308,44 @@ certificate_info() {
93449308
outln
93459309
fi
93469310

9311+
out "$indent"; pr_bold " Issuer "
9312+
jsonID="cert_caIssuers"
9313+
9314+
if [[ "$issuer_O" == issuer= ]] || [[ "$issuer_O" == issuer=\ ]] || [[ "$issuer_CN" == "$cn" ]]; then
9315+
prln_svrty_critical "self-signed (NOT ok)"
9316+
fileout "${jsonID}${json_postfix}" "CRITICAL" "selfsigned"
9317+
set_grade_cap "T" "Self-signed certificate"
9318+
else
9319+
issuerfinding="$issuer_CN"
9320+
pr_italic "$issuer_CN"
9321+
if [[ -z "$issuer_O" ]] && [[ -n "$issuer_DC" ]]; then
9322+
for san in $issuer_DC; do
9323+
if [[ -z "$issuer_O" ]]; then
9324+
issuer_O="${san}"
9325+
else
9326+
issuer_O="${san}.${issuer_O}"
9327+
fi
9328+
done
9329+
fi
9330+
if [[ -n "$issuer_O" ]]; then
9331+
issuerfinding+=" ("
9332+
out " ("
9333+
issuerfinding+="$issuer_O"
9334+
pr_italic "$issuer_O"
9335+
if [[ -n "$issuer_C" ]]; then
9336+
issuerfinding+=" from "
9337+
out " from "
9338+
issuerfinding+="$issuer_C"
9339+
pr_italic "$issuer_C"
9340+
fi
9341+
issuerfinding+=")"
9342+
out ")"
9343+
fi
9344+
outln
9345+
fileout "${jsonID}${json_postfix}" "INFO" "$issuerfinding"
9346+
fi
9347+
9348+
93479349
# Now we take care of the intermediate certificates. We basically (should) have them on disk
93489350
# as "intermediatecerts.pem" (which could be split into intermediatecert1.crt, intermediatecert2.crt, ..)
93499351
# However we do this in RAM which is better as it was passed to this function.
@@ -9388,7 +9390,7 @@ certificate_info() {
93889390
pr_svrty_medium "$cn_finding"
93899391
expok="MEDIUM"
93909392
else
9391-
cn_finding="valid > 40 days"
9393+
cn_finding="ok > 40 days"
93929394
pr_svrty_good "$cn_finding"
93939395
expok="OK"
93949396
fi

0 commit comments

Comments
 (0)