diff --git a/lib/Net/ACME2.pm b/lib/Net/ACME2.pm index 949907a..d8692b8 100644 --- a/lib/Net/ACME2.pm +++ b/lib/Net/ACME2.pm @@ -1043,7 +1043,7 @@ sub _key_thumbprint { sub _get_directory { my ($self) = @_; - return $self->{'_directory_promise'} ||= do { + return $self->{'_directory_cache'} ||= do { my $dir_path = $self->DIRECTORY_PATH(); my $http = $self->{'_http'}; @@ -1190,10 +1190,6 @@ sub _die_generic { *create_new_account = *create_account; *create_new_order = *create_order; -# sub DESTROY { -# print "ACME2 destroyed at ${^GLOBAL_PHASE}\n"; -# } - 1; =head1 TODO diff --git a/lib/Net/ACME2/Curl.pm b/lib/Net/ACME2/Curl.pm index 1d414dd..39d62fe 100644 --- a/lib/Net/ACME2/Curl.pm +++ b/lib/Net/ACME2/Curl.pm @@ -136,6 +136,8 @@ sub _imitate_http_tiny { my %headers; for my $line ( split m<\x0d?\x0a>, $head ) { + next if !length $line; + if (defined $reason) { my ($name, $value) = split m<\s*:\s*>, $line, 2; $name =~ tr; diff --git a/lib/Net/ACME2/HTTP.pm b/lib/Net/ACME2/HTTP.pm index 7e397cf..d15629b 100644 --- a/lib/Net/ACME2/HTTP.pm +++ b/lib/Net/ACME2/HTTP.pm @@ -39,11 +39,7 @@ our $verify_SSL = 1; sub new { my ( $class, %opts ) = @_; - my $is_sync; - $opts{'ua'} ||= do { - $is_sync = 1; - require Net::ACME2::HTTP_Tiny; Net::ACME2::HTTP_Tiny->new( verify_SSL => $verify_SSL ); }; @@ -53,7 +49,6 @@ sub new { _acme_key => $opts{'key'}, _key_id => $opts{'key_id'}, _retries_left => $_MAX_RETRIES, - _sync_io => $is_sync, }, $class; return bless $self, $class; @@ -144,8 +139,6 @@ sub _post { sub { my $jws = shift; - # local $opts_hr->{'headers'}{'Content-Type'} = 'application/jose+json'; - return Net::ACME2::PromiseUtil::do_then_catch( sub { return $self->_request_and_set_last_nonce( @@ -170,6 +163,10 @@ sub _post { my $resp; + # NB: We mutate $self->{'_retries_left'} rather than + # using local() because this code may run inside a + # promise chain where local's dynamic scope doesn't + # extend across async callbacks. if ( eval { $err->get('acme')->type() =~ m<:badNonce\z> } ) { if (!$self->{'_retries_left'}) { warn( "$url: Received “badNonce” error, and no retries left!\n" );