21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-04-27 06:20:50 +02:00

SSLParser: enable other formats

This commit is contained in:
Jérémy Lecour 2022-02-13 19:02:17 +01:00 committed by Jérémy Lecour
parent 6aa0e242aa
commit 379e43de89
2 changed files with 4 additions and 3 deletions

View file

@ -3,10 +3,11 @@
module SSL
class Parser
DATE_REGEX = /will expire on (.+)\./
DATE_REGEX = /will expire (in (?<days>\d+) days )?on (?<date>.+)\./
# Several date formats possible:
# OK - Certificate 'domain.net' will expire on Sat 10 Jun 2028 09:14:18 AM GMT +0000.
# OK - Certificate 'domain.net' will expire on 2018-08-06 02:57 +0200/CEST.
# SSL OK - Certificate 'domain.net' will expire in 52 days on 2022-04-07 00:33 +0200/CEST.
attr_reader :logger
attr_reader :domain
@ -45,7 +46,7 @@ module SSL
def build_response(match)
Response.new(domain).tap do |response|
response.expire_at = parse_datetime(match[1])
response.expire_at = parse_datetime(match[:date])
end
end

View file

@ -1 +1 @@
SSL OK - Certificate 'ssl1.domain.org' will expire on 2022-08-06 02:57 +0200/CEST.
SSL OK - Certificate 'ssl1.domain.org' will expire in 45 days on 2022-08-06 02:57 +0200/CEST.