Skip to content

Commit 1ec4753

Browse files
committed
CPAN sync for v0.35
1 parent ecb4dd2 commit 1ec4753

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Revision history for Crypt-LE
22

3+
0.35 09 December 2019
4+
- 'Post as get' update for APIv2.
5+
36
0.34 29 August 2019
47
- APIv2 is now default, unless a custom server is used or the API version is specified explicitly.
58
- Registration ID is obtained from the registration path now, since it is not provided in the response anymore.

lib/Crypt/LE.pm

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ use 5.006;
44
use strict;
55
use warnings;
66

7-
our $VERSION = '0.34';
7+
our $VERSION = '0.35';
88

99
=head1 NAME
1010
1111
Crypt::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 {
17131716
sub _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) {

lib/Crypt/LE/Challenge/Simple.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use warnings;
44
use Digest::SHA 'sha256';
55
use MIME::Base64 'encode_base64url';
66

7-
our $VERSION = '0.34';
7+
our $VERSION = '0.35';
88

99
=head1 NAME
1010

lib/Crypt/LE/Complete/Simple.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package Crypt::LE::Complete::Simple;
22
use strict;
33
use warnings;
44

5-
our $VERSION = '0.34';
5+
our $VERSION = '0.35';
66

77
=head1 NAME
88

script/le.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Crypt::LE ':errors', ':keys';
1414
use utf8;
1515

16-
my $VERSION = '0.34';
16+
my $VERSION = '0.35';
1717

1818
exit main();
1919

0 commit comments

Comments
 (0)