workaround for missing date format conversion (OpenBSD) in http date
This commit is contained in:
parent
7c015c5a13
commit
224d851f7b
25
testssl.sh
25
testssl.sh
|
@ -1724,25 +1724,32 @@ match_ipv4_httpheader() {
|
||||||
|
|
||||||
run_http_date() {
|
run_http_date() {
|
||||||
local now difftime
|
local now difftime
|
||||||
|
local spaces=" "
|
||||||
jsonID="HTTP_clock_skew"
|
jsonID="HTTP_clock_skew"
|
||||||
|
|
||||||
if [[ $SERVICE != "HTTP" ]] || "$CLIENT_AUTH"; then
|
if [[ $SERVICE != "HTTP" ]] || "$CLIENT_AUTH"; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -s $HEADERFILE ]]; then
|
if [[ ! -s $HEADERFILE ]]; then
|
||||||
run_http_header "$1" || return 1
|
run_http_header "$1" || return 1
|
||||||
fi
|
fi
|
||||||
pr_bold " HTTP clock skew "
|
pr_bold " HTTP clock skew "
|
||||||
if [[ -n "$HTTP_TIME" ]]; then
|
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
|
||||||
difftime=$((HTTP_TIME - NOW_TIME))
|
# we can't normalize the date under OpenBSD thus no substraction is possible
|
||||||
[[ $difftime != "-"* ]] && [[ $difftime != "0" ]] && difftime="+$difftime"
|
outln "remote: $HTTP_TIME"
|
||||||
# process was killed, so we need to add an error:
|
out "${spaces}local: $(date)"
|
||||||
[[ $HAD_SLEPT -ne 0 ]] && difftime="$difftime (± 1.5)"
|
fileout "$jsonID" "INFO" "$HTTP_TIME - $(date)"
|
||||||
out "$difftime sec from localtime";
|
else
|
||||||
fileout "$jsonID" "INFO" "$difftime seconds from localtime"
|
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 "$jsonID" "INFO" "$difftime seconds from localtime"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
out "Got no HTTP time, maybe try different URL?";
|
out "Got no HTTP time, maybe try different URL?";
|
||||||
fileout "$jsonID" "INFO" "Got no HTTP time, maybe try different URL?"
|
fileout "$jsonID" "INFO" "Got no HTTP time, maybe try different URL?"
|
||||||
|
|
Loading…
Reference in New Issue