mirror of
https://github.com/nmap/nmap.git
synced 2026-01-02 04:49:02 +00:00
Fix date handling in ssl-cert
Was crashing on unparseable dates (example: "2147483647Z"). Now the exact string is placed in structured output when it cannot be normalized. Also, the structured-format timestamp is used for Normal output for consistency; no timezone offset was previously displayed.
This commit is contained in:
@@ -137,7 +137,7 @@ function date_to_string(date)
|
||||
if type(date) == "string" then
|
||||
return string.format("Can't parse; string is \"%s\"", date)
|
||||
else
|
||||
return os.date("%Y-%m-%d %H:%M:%S", os.time(date))
|
||||
return stdnse.format_timestamp(stdnse.date_to_timestamp(date, 0), 0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -190,7 +190,11 @@ local function output_tab(cert)
|
||||
o.pubkey = cert.pubkey
|
||||
o.validity = {}
|
||||
for k, v in pairs(cert.validity) do
|
||||
o.validity[k] = stdnse.format_timestamp(stdnse.date_to_timestamp(v, 0), 0)
|
||||
if type(v)=="string" then
|
||||
o.validity[k] = v
|
||||
else
|
||||
o.validity[k] = stdnse.format_timestamp(stdnse.date_to_timestamp(v, 0), 0)
|
||||
end
|
||||
end
|
||||
o.md5 = stdnse.tohex(cert:digest("md5"))
|
||||
o.sha1 = stdnse.tohex(cert:digest("sha1"))
|
||||
|
||||
Reference in New Issue
Block a user