@@ -4,15 +4,15 @@ use 5.006;
44use strict;
55use warnings;
66
7- our $VERSION = ' 0.34 ' ;
7+ our $VERSION = ' 0.35 ' ;
88
99=head1 NAME
1010
1111Crypt::LE - Let's Encrypt API interfacing module and client.
1212
1313=head1 VERSION
1414
15- Version 0.34
15+ Version 0.35
1616
1717=head1 SYNOPSIS
1818
@@ -830,7 +830,7 @@ sub request_challenge {
830830 unless ($self -> {authz }) {
831831 my ($status , $content ) = $self -> _request($self -> {directory }-> {' new-cert' }, { resource => ' new-cert' });
832832 if ($status == CREATED and $content -> {' identifiers' } and $content -> {' authorizations' }) {
833- push @{$self -> {authz }}, [ $_ ] for @{$content -> {' authorizations' }};
833+ push @{$self -> {authz }}, [ $_ , ' ' ] for @{$content -> {' authorizations' }};
834834 $self -> {finalize } = $content -> {' finalize' };
835835 } else {
836836 return $self -> _status(ERROR, " Cannot request challenges." ) unless $self -> {directory }-> {' new-authz' };
@@ -1132,11 +1132,12 @@ sub verify_challenge {
11321132 if ($status == $expected_status ) {
11331133 $content -> {uri } ||= $content -> {url };
11341134 if ($content -> {uri }) {
1135- my $check = $content -> {uri };
1135+ my @check = ($content -> {uri });
1136+ push @check , ' ' if ($self -> version() > 1);
11361137 my $try = 0;
11371138 while ($status == $expected_status and $content and $content -> {status } and $content -> {status } eq ' pending' ) {
11381139 select (undef , undef , undef , $self -> {delay });
1139- ($status , $content ) = $self -> _request($ check );
1140+ ($status , $content ) = $self -> _request(@ check );
11401141 last if ($self -> {try } and (++$try == $self -> {try }));
11411142 }
11421143 if ($status == $expected_status and $content and $content -> {status }) {
@@ -1205,7 +1206,7 @@ sub request_certificate {
12051206 ($status , $content ) = $self -> _request($self -> {directory }-> {' new-cert' }, { resource => ' new-cert' , csr => $csr });
12061207 return $self -> _status($status == AUTH_ERROR ? AUTH_ERROR : ERROR, $content ) unless ($status == CREATED);
12071208 if (ref $content eq ' HASH' and $content -> {' identifiers' } and $content -> {' authorizations' }) {
1208- push @{$self -> {authz }}, [ $_ ] for @{$content -> {' authorizations' }};
1209+ push @{$self -> {authz }}, [ $_ , ' ' ] for @{$content -> {' authorizations' }};
12091210 $self -> {finalize } = $content -> {' finalize' };
12101211 }
12111212 }
@@ -1222,7 +1223,9 @@ sub request_certificate {
12221223 if ($content -> {status } eq ' valid' ) {
12231224 if ($content -> {certificate }) {
12241225 $self -> _debug(" The certificate is ready for download at $content ->{certificate}." );
1225- ($status , $content ) = $self -> _request($content -> {certificate });
1226+ my @cert = ($content -> {certificate });
1227+ push @cert , ' ' if ($self -> version() > 1);
1228+ ($status , $content ) = $self -> _request(@cert );
12261229 return $self -> _status(ERROR, " Certificate could not be downloaded from $content ->{certificate}." ) unless ($status == SUCCESS);
12271230 # In v2 certificate is returned along with the chain.
12281231 $ready = 1;
@@ -1677,8 +1680,8 @@ sub _request {
16771680 my $resp ;
16781681 $opts ||= {};
16791682 my $method = lc ($opts -> {method } || ' get' );
1680- if ($payload or $method eq ' post' ) {
1681- $resp = $payload ? $self -> {ua }-> post($url , { headers => $headers , content => $self -> _jws($payload , $url , $opts ) }) :
1683+ if (defined $payload or $method eq ' post' ) {
1684+ $resp = defined $payload ? $self -> {ua }-> post($url , { headers => $headers , content => $self -> _jws($payload , $url , $opts ) }) :
16821685 $self -> {ua }-> post($url , { headers => $headers });
16831686 } else {
16841687 $resp = $self -> {ua }-> $method ($url );
@@ -1713,8 +1716,8 @@ sub _jwk {
17131716sub _jws {
17141717 my $self = shift ;
17151718 my ($obj , $url , $opts ) = @_ ;
1716- return unless ($obj and ref $obj );
1717- my $json = encode_base64url($j -> encode($obj ));
1719+ return unless (defined $obj );
1720+ my $json = ref $obj ? encode_base64url($j -> encode($obj )) : " " ;
17181721 my $protected = { alg => " RS256" , jwk => $self -> {jwk }, nonce => $self -> {nonce } };
17191722 $opts ||= {};
17201723 if ($url and $self -> version() > 1) {
0 commit comments