Skip to content

Commit c48b003

Browse files
committed
Better document OpenSSL time format.
1 parent 23c3a2e commit c48b003

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/resty/auto-ssl/utils/parse_openssl_time.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ local months = {
1515
Dec = 12,
1616
}
1717

18+
-- Parse the time strings that OpenSSL outputs via ASN1_TIME_print:
19+
-- https://www.openssl.org/docs/man1.1.1/man3/ASN1_TIME_print.html
20+
--
21+
-- Relevant pieces of specification:
22+
--
23+
-- > It will be of the format MMM DD HH:MM:SS YYYY [GMT], for example "Feb 3
24+
-- > 00:55:52 2015 GMT"
25+
-- > Does not print out the time zone: it either prints out "GMT" or nothing.
26+
-- > But all certificates complying with RFC5280 et al use GMT anyway.
1827
return function(time_str)
1928
local matches, match_err = ngx.re.match(time_str, [[(?<month>[A-Za-z]{3}) +(?<day>\d{1,2}) +(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2})(?:\.\d+)? +(?<year>-?\d{4})]], "jo")
2029
if match_err then

0 commit comments

Comments
 (0)