1
0
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:
dmiller
2012-09-13 20:23:07 +00:00
parent d88d8720a9
commit 2f36d0b968

View File

@@ -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"))