diff options
-rw-r--r-- | Changelog | 2 | ||||
-rwxr-xr-x | client | 2 | ||||
-rwxr-xr-x | lacme | 29 |
3 files changed, 5 insertions, 28 deletions
@@ -1,6 +1,8 @@ lacme (0.6) UNRELEASED + client: poll order URL instead of each authz URL successively. + - lacme, client: new dependency Date::Parse, don't parse RFC 3339 + datetime strings from X.509 certs manually. -- Guilhem Moulin <guilhem@fripost.org> Mon, 21 Jan 2019 02:07:58 +0100 @@ -50,6 +50,7 @@ use Fcntl qw/O_CREAT O_EXCL O_WRONLY/; use Digest::SHA qw/sha256 sha256_hex/; use MIME::Base64 qw/encode_base64 encode_base64url/; +use Date::Parse (); use LWP::UserAgent (); use Types::Serialiser (); use JSON (); @@ -148,7 +149,6 @@ sub request_retry_after($) { my $r = shift; my $v = $r->header('Retry-After'); if (defined $v and $v !~ /\A\d+\z/) { - require 'Date/Parse.pm'; $v = Date::Parse::str2time($v); if (defined $v) { $v = $v - time; @@ -36,6 +36,7 @@ use Socket 1.95 qw/AF_UNIX AF_INET AF_INET6 PF_UNIX PF_INET PF_INET6 PF_UNSPEC SOCK_STREAM SOL_SOCKET SO_REUSEADDR SHUT_RDWR/; use Config::Tiny (); +use Date::Parse (); use Net::SSLeay (); # Clean up PATH @@ -199,33 +200,7 @@ sub x509_enddate($) { $time = Net::SSLeay::X509_get_notAfter($x509) if defined $x509; $dt = Net::SSLeay::P_ASN1_TIME_get_isotime($time) if defined $time; - my $t; - if (defined $dt and $dt =~ s/\A(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})//) { - # RFC3339 datetime strings; assume epoch is on January 1 of $epoch_year - my ($y, $m, $d, $h, $min, $s) = ($1, $2, $3, $4, $5, $6); - my (undef,undef,undef,undef,undef,$epoch_year,undef,undef,undef) = gmtime(0); - $t = 0; - foreach (($epoch_year+1900) .. $y-1) { - $t += 365*86400; - $t += 86400 if ($_ % 4 == 0 and $_ % 100 != 0) or ($_ % 400 == 0); # leap - } - - if ($m > 1) { - my @m = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); - $m[1]++ if ($y % 4 == 0 and $y % 100 != 0) or ($y % 400 == 0); # leap - $t += 86400*$m[$_] for (0 .. $m-2); - } - - $t += 86400*($d-1); - $t += $s + 60*($min + 60*$h); - - $dt =~ s/\A\.(\d{1,9})\d*//; # ignore nanosecs - - if ($dt =~ /\A([+-])(\d{2}):(\d{2})\z/) { - my $tz = 60*($3 + 60*$2); - $t = $1 eq '-' ? ($t+$tz) : ($t-$tz); - } - } + my $t = Date::Parse::str2time($dt) if defined $dt; Net::SSLeay::X509_free($x509) if defined $x509; Net::SSLeay::BIO_free($bio) if defined $bio; |