mirror of
				https://github.com/drwetter/testssl.sh.git
				synced 2025-10-31 05:45:26 +01:00 
			
		
		
		
	workaround for missing date format conversion (OpenBSD) in http date
This commit is contained in:
		
							
								
								
									
										15
									
								
								testssl.sh
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								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 | ||||||
|  |                # 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=$((HTTP_TIME - NOW_TIME)) | ||||||
|                [[ $difftime != "-"* ]] && [[ $difftime != "0" ]] && difftime="+$difftime" |                [[ $difftime != "-"* ]] && [[ $difftime != "0" ]] && difftime="+$difftime" | ||||||
|           # process was killed, so we need to add an error: |                # process was killed, so we need to add an error | ||||||
|                [[ $HAD_SLEPT -ne 0 ]] && difftime="$difftime (± 1.5)" |                [[ $HAD_SLEPT -ne 0 ]] && difftime="$difftime (± 1.5)" | ||||||
|                out "$difftime sec from localtime"; |                out "$difftime sec from localtime"; | ||||||
|                fileout "$jsonID" "INFO" "$difftime seconds 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?" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Dirk
					Dirk