| 1 | package Net::ACME2::HTTP; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Net::ACME2::HTTP - transport logic for C<Net::ACME2>. | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | This module handles communication with an ACME server at the HTTP level. | ||||||||||||||||||||||||||||
| 12 | It wraps POSTs in JWSes (JSON Web Signatures) as needed. | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | There should be no reason to interact with this class in production. | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use JSON (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Net::ACME2::Error (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Net::ACME2::HTTP_Tiny (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use Net::ACME2::HTTP::Response (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use Net::ACME2::X (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use constant _CONTENT_TYPE => 'application/jose+json'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | #accessed from tests | ||||||||||||||||||||||||||||
| 31 | 1 | our $_NONCE_HEADER = 'replay-nonce'; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | #Used in testing | ||||||||||||||||||||||||||||
| 34 | 1 | our $verify_SSL = 1; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | #NB: “key” isn’t needed if we’re just doing GETs. | ||||||||||||||||||||||||||||
| 37 | sub new { | ||||||||||||||||||||||||||||
| 38 | 1 | ▶ | my ( $class, %opts ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=8.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 1 | ▶ | die Net::ACME2::X->create('Generic', 'need “key”!') if !$opts{'key'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | my $ua = Net::ACME2::HTTP_Tiny->new( verify_SSL => $verify_SSL ); | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | my $self = bless { | ||||||||||||||||||||||||||||
| 45 | _ua => $ua, | ||||||||||||||||||||||||||||
| 46 | _acme_key => $opts{'key'}, | ||||||||||||||||||||||||||||
| 47 | _key_id => $opts{'key_id'}, | ||||||||||||||||||||||||||||
| 48 | 0 | _jws_format => $opts{'jws_format'}, | |||||||||||||||||||||||||||
| 49 | }, $class; | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | return bless $self, $class; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub set_key_id { | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my ($self, $key_id) = @_; | ||||||||||||||||||||||||||
|
Subroutine
set_key_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | $self->{'_key_id'} = $key_id; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | return $self; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub set_new_nonce_url { | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my ($self, $url) = @_; | ||||||||||||||||||||||||||
|
Subroutine
set_new_nonce_url: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | $self->{'_nonce_url'} = $url; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | return $self; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | #GETs submit no data and thus are not signed. | ||||||||||||||||||||||||||||
| 71 | sub get { | ||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my ( $self, $url ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | return $self->_request( 'GET', $url ); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # ACME spec 6.2: for all requests not signed using an existing account, | ||||||||||||||||||||||||||||
| 78 | # e.g., newAccount | ||||||||||||||||||||||||||||
| 79 | sub post_full_jwt { | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
post_full_jwt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | return $self->_post( 'create_full_jws', @_ ); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | # ACME spec 6.2: for all requests signed using an existing account | ||||||||||||||||||||||||||||
| 86 | sub post_key_id { | ||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
post_key_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | return $self->_post( | |||||||||||||||||||||||||||
| 90 | 'create_key_id_jws', | ||||||||||||||||||||||||||||
| 91 | @_, | ||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | #POSTs are signed. | ||||||||||||||||||||||||||||
| 98 | sub _post { | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my ( $self, $jwt_method, $url, $data, $opts_hr ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_post: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | # Shouldn’t be needed because the constructor requires “key”, | ||||||||||||||||||||||||||||
| 102 | # but just in case. | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | die "Constructor needed “key” to do POST! ($url)" if !$self->{'_acme_key'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | my $jws = $self->_create_jwt( $jwt_method, $url, $data ); | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | local $opts_hr->{'headers'}{'Content-Type'} = 'application/jose+json'; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return $self->_request_and_set_last_nonce( | ||||||||||||||||||||||||||
|
Condition0%0/3
$opts_hr || ()
MC/DC0%0/2
$opts_hr || ()
$opts_hr
()
Truth table0%0/3
A || B
A= $opts_hrB= ()
| |||||||||||||||||||||||||||||
| 110 | 'POST', | ||||||||||||||||||||||||||||
| 111 | $url, | ||||||||||||||||||||||||||||
| 112 | { | ||||||||||||||||||||||||||||
| 113 | content => $jws, | ||||||||||||||||||||||||||||
| 114 | headers => { | ||||||||||||||||||||||||||||
| 115 | 'content-type' => _CONTENT_TYPE, | ||||||||||||||||||||||||||||
| 116 | }, | ||||||||||||||||||||||||||||
| 117 | }, | ||||||||||||||||||||||||||||
| 118 | $opts_hr || (), | ||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | sub _ua_request { | ||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my ( $self, $type, @args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_ua_request: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | return $self->{'_ua'}->request( $type, @args ); | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | #overridden in tests | ||||||||||||||||||||||||||||
| 129 | sub _request { | ||||||||||||||||||||||||||||
| 130 | 0 | ▶ | my ( $self, $type, @args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_request: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | my $resp; | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | #cf. eval_bug.readme | ||||||||||||||||||||||||||||
| 135 | 0 | my $eval_err = $@; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | eval { $resp = $self->_ua_request( $type, @args ); }; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | # Check ref() first to avoid potentially running overload.pm’s | ||||||||||||||||||||||||||||
| 140 | # stringification. | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if (ref($@) || $@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $@ or $@
MC/DC0%0/2
ref $@ or $@
ref $@
$@
Truth table0%0/3
A or B
A= ref $@B= $@
| |||||||||||||||||||||||||||||
| 142 | 0 | my $exc = $@; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ( eval { $exc->isa('Net::ACME2::X::HTTP::Protocol') } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 0 | my $_nonce_header_lc = $_NONCE_HEADER; | |||||||||||||||||||||||||||
| 146 | 0 | $_nonce_header_lc =~ tr<A-Z><a-z>; | |||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | my $nonce = $exc->get('headers')->{$_nonce_header_lc}; | |||||||||||||||||||||||||||
| 149 | 0 | ▶ | $self->{'_last_nonce'} = $nonce if $nonce; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | #If the exception is able to be made into a Net::ACME2::Error, | ||||||||||||||||||||||||||||
| 152 | #then do so to get a nicer error message. | ||||||||||||||||||||||||||||
| 153 | 0 | my $acme_error = eval { | |||||||||||||||||||||||||||
| 154 | Net::ACME2::Error->new( | ||||||||||||||||||||||||||||
| 155 | 0 | %{ JSON::decode_json( $exc->get('content') ) }, | |||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||
| 157 | }; | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if ($acme_error) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 0 | die Net::ACME2::X->create( | |||||||||||||||||||||||||||
| 161 | 'ACME', | ||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||
| 163 | http => $exc, | ||||||||||||||||||||||||||||
| 164 | acme => $acme_error, | ||||||||||||||||||||||||||||
| 165 | }, | ||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 0 | $@ = $exc; | |||||||||||||||||||||||||||
| 171 | 0 | die; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | $@ = $eval_err; | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | return Net::ACME2::HTTP::Response->new($resp); | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | sub _request_and_set_last_nonce { | ||||||||||||||||||||||||||||
| 180 | 0 | ▶ | my ( $self, $type, $url, @args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_request_and_set_last_nonce: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 0 | my $resp = $self->_request( $type, $url, @args ); | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | #NB: ACME’s replay protection works thus: | ||||||||||||||||||||||||||||
| 185 | # - each server response includes a nonce | ||||||||||||||||||||||||||||
| 186 | # - each request must include ONE of the nonces that have been sent | ||||||||||||||||||||||||||||
| 187 | # - once used, a nonce can’t be reused | ||||||||||||||||||||||||||||
| 188 | # | ||||||||||||||||||||||||||||
| 189 | #This is subtly different from what was originally in mind (i.e., that | ||||||||||||||||||||||||||||
| 190 | #each request must use the most recently sent nonce). It implies that GETs | ||||||||||||||||||||||||||||
| 191 | #do not need to send nonces, though each GET will *receive* a nonce that | ||||||||||||||||||||||||||||
| 192 | #may be used. | ||||||||||||||||||||||||||||
| 193 | 0 | ▶ | $self->{'_last_nonce'} = $resp->header($_NONCE_HEADER) or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 0 | die Net::ACME2::X->create('Generic', "Received no $_NONCE_HEADER from $url!"); | |||||||||||||||||||||||||||
| 195 | }; | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | return $resp; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | sub _get_first_nonce { | ||||||||||||||||||||||||||||
| 201 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_get_first_nonce: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | my $url = $self->{'_nonce_url'} or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | # Shouldn’t happen unless there’s an errant refactor. | ||||||||||||||||||||||||||||
| 206 | 0 | die Net::ACME2::X->create('Set newNonce URL first!'); | |||||||||||||||||||||||||||
| 207 | }; | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 0 | $self->_request_and_set_last_nonce( 'HEAD', $url ); | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | return; | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | sub _create_jwt { | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | my ( $self, $jwt_method, $url, $data ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_create_jwt: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | ▶ | $self->_get_first_nonce() if !$self->{'_last_nonce'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $self->{'_jwt_maker'} ||= do { | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_jwt_maker"} ||= do {
my $class;
if ($self->{"_acme_key"}->isa("Crypt::Perl::RSA::PrivateKey")) {
$class = "Net::ACME2::JWTMaker::RSA";
}
elsif ($self->{"_acme_key"}->isa("Crypt::Perl::ECDSA::PrivateKey")) {
$class = "Net::ACME2::JWTMaker::ECC";
}
else {
die "Net::ACME2::X"->create("Generic", qq[Unrecognized key type: $self->{"_acme_key"}]);
};
unless ($class->can("new")) {
require Module::Load;
&Module::Load::load($class);
};
$class->new("key", $self->{"_acme_key"}, "format", $self->{"_jws_format"})
}
MC/DC0%0/2
$self->{"_jwt_maker"} ||= do {
my $class;
if ($self->{"_acme_key"}->isa("Crypt::Perl::RSA::PrivateKey")) {
$class = "Net::ACME2::JWTMaker::RSA";
}
elsif ($self->{"_acme_key"}->isa("Crypt::Perl::ECDSA::PrivateKey")) {
$class = "Net::ACME2::JWTMaker::ECC";
}
else {
die "Net::ACME2::X"->create("Generic", qq[Unrecognized key type: $self->{"_acme_key"}]);
};
unless ($class->can("new")) {
require Module::Load;
&Module::Load::load($class);
};
$class->new("key", $self->{"_acme_key"}, "format", $self->{"_jws_format"})
}
$self->{"_jwt_maker"}
do {
my $class;
if ($self->{"_acme_key"}->isa("Crypt::Perl::RSA::PrivateKey")) {
$class = "Net::ACME2::JWTMaker::RSA";
}
elsif ($self->{"_acme_key"}->isa("Crypt::Perl::ECDSA::PrivateKey")) {
$class = "Net::ACME2::JWTMaker::ECC";
}
else {
die "Net::ACME2::X"->create("Generic", qq[Unrecognized key type: $self->{"_acme_key"}]);
};
unless ($class->can("new")) {
require Module::Load;
&Module::Load::load($class);
};
$class->new("key", $self->{"_acme_key"}, "format", $self->{"_jws_format"})
}
Truth table0%0/3
A ||= B
A= $self->{"_jwt_maker"}B= do {
my $class;
if ($self->{"_acme_key"}->isa("Crypt::Perl::RSA::PrivateKey")) {
$class = "Net::ACME2::JWTMaker::RSA";
}
elsif ($self->{"_acme_key"}->isa("Crypt::Perl::ECDSA::PrivateKey")) {
$class = "Net::ACME2::JWTMaker::ECC";
}
else {
die "Net::ACME2::X"->create("Generic", qq[Unrecognized key type: $self->{"_acme_key"}]);
};
unless ($class->can("new")) {
require Module::Load;
&Module::Load::load($class);
};
$class->new("key", $self->{"_acme_key"}, "format", $self->{"_jws_format"})
}
| |||||||||||||||||||||||||||||
| 220 | 0 | my $class; | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ($self->{'_acme_key'}->isa('Crypt::Perl::RSA::PrivateKey')) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 223 | 0 | $class = 'Net::ACME2::JWTMaker::RSA'; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | elsif ($self->{'_acme_key'}->isa('Crypt::Perl::ECDSA::PrivateKey')) { | ||||||||||||||||||||||||||||
| 226 | 0 | $class = 'Net::ACME2::JWTMaker::ECC'; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | else { | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | # As of this writing, Crypt::Perl only does RSA and ECDSA keys. | ||||||||||||||||||||||||||||
| 231 | # If we get here, it’s possible that Crypt::Perl now supports | ||||||||||||||||||||||||||||
| 232 | # an additional key type that this library doesn’t recognize. | ||||||||||||||||||||||||||||
| 233 | 0 | die Net::ACME2::X->create('Generic', "Unrecognized key type: $self->{'_acme_key'}"); | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if (!$class->can('new')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 0 | require Module::Load; | |||||||||||||||||||||||||||
| 238 | 0 | Module::Load::load($class); | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | $class->new( | ||||||||||||||||||||||||||||
| 242 | key => $self->{'_acme_key'}, | ||||||||||||||||||||||||||||
| 243 | 0 | format => $self->{'_jws_format'}, | |||||||||||||||||||||||||||
| 244 | ); | ||||||||||||||||||||||||||||
| 245 | }; | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | return $self->{'_jwt_maker'}->$jwt_method( | ||||||||||||||||||||||||||||
| 248 | key_id => $self->{'_key_id'}, | ||||||||||||||||||||||||||||
| 249 | payload => $data, | ||||||||||||||||||||||||||||
| 250 | extra_headers => { | ||||||||||||||||||||||||||||
| 251 | 0 | nonce => $self->{'_last_nonce'}, | |||||||||||||||||||||||||||
| 252 | url => $url, | ||||||||||||||||||||||||||||
| 253 | }, | ||||||||||||||||||||||||||||
| 254 | ); | ||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 1 | 1; | |||||||||||||||||||||||||||