diff --git a/app/services/ssl/parser.rb b/app/services/ssl/parser.rb index a224d43..d488bc3 100644 --- a/app/services/ssl/parser.rb +++ b/app/services/ssl/parser.rb @@ -3,10 +3,11 @@ module SSL class Parser - DATE_REGEX = /will expire on (.+)\./ + DATE_REGEX = /will expire (in (?\d+) days )?on (?.+)\./ # 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 diff --git a/test/fixtures/files/ssl/ssl1.domain.org.txt b/test/fixtures/files/ssl/ssl1.domain.org.txt index 91b39ee..6463f63 100644 --- a/test/fixtures/files/ssl/ssl1.domain.org.txt +++ b/test/fixtures/files/ssl/ssl1.domain.org.txt @@ -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. \ No newline at end of file