mirror of
https://github.com/drwetter/testssl.sh.git
synced 2025-01-10 18:50:58 +01:00
workaround for missing date format conversion (OpenBSD) in http date
This commit is contained in:
parent
7cd872313e
commit
68b07f1ebc
12
testssl.sh
12
testssl.sh
@ -1535,6 +1535,7 @@ detect_ipv4() {
|
||||
|
||||
run_http_date() {
|
||||
local now difftime
|
||||
local spaces=" "
|
||||
|
||||
if [[ ! -s $HEADERFILE ]]; then
|
||||
run_http_header "$1" || return 3 # this is just for the line "Testing HTTP header response"
|
||||
@ -1544,14 +1545,21 @@ run_http_date() {
|
||||
out "not tested as we're not targeting HTTP"
|
||||
else
|
||||
if [[ -n "$HTTP_TIME" ]]; then
|
||||
HTTP_TIME=$(parse_date "$HTTP_TIME" "+%s" "%a, %d %b %Y %T %Z" 2>>$ERRFILE) # the trailing \r confuses BSD flavors otherwise
|
||||
|
||||
HTTP_TIME="$(strip_lf "$HTTP_TIME")"
|
||||
if "$HAS_OPENBSDDATE"; then
|
||||
# we can't normalize the date under OpenBSD thus no substraction is possible
|
||||
outln "remote: $HTTP_TIME"
|
||||
out "${spaces}local: $(date)"
|
||||
fileout "$jsonID" "INFO" "$HTTP_TIME - $(date)"
|
||||
else
|
||||
HTTP_TIME=$(parse_date "$HTTP_TIME" "+%s" "%a, %d %b %Y %T %Z" 2>>$ERRFILE)
|
||||
difftime=$((HTTP_TIME - NOW_TIME))
|
||||
[[ $difftime != "-"* ]] && [[ $difftime != "0" ]] && difftime="+$difftime"
|
||||
# process was killed, so we need to add an error:
|
||||
[[ $HAD_SLEPT -ne 0 ]] && difftime="$difftime (± 1.5)"
|
||||
out "$difftime sec from localtime";
|
||||
fileout "http_clock_skew" "INFO" "HTTP clock skew $difftime sec from localtime"
|
||||
fi
|
||||
else
|
||||
out "Got no HTTP time, maybe try different URL?";
|
||||
fileout "http_clock_skew" "INFO" "HTTP clock skew not measured. Got no HTTP time, maybe try different URL?"
|
||||
|
Loading…
Reference in New Issue
Block a user