| 1 | package Net::ACME2::Challenge::http_01; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use parent qw( Net::ACME2::ChallengeBase::HasToken ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use constant PATH_DIRECTORY => '/.well-known/acme-challenge'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | =encoding utf-8 | ||||||||||
| 11 | |||||||||||
| 12 | =head1 NAME | ||||||||||
| 13 | |||||||||||
| 14 | Net::ACME2::Challenge::http_01 | ||||||||||
| 15 | |||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||
| 17 | |||||||||||
| 18 | #e.g., “/.well-known/acme-challenge/12341243sdafdewrsvfd” | ||||||||||
| 19 | my $path = $challenge->path(); | ||||||||||
| 20 | |||||||||||
| 21 | { | ||||||||||
| 22 | my $handler = $challenge->create_handler( ... ); | ||||||||||
| 23 | |||||||||||
| 24 | $acme->accept_challenge($challenge); | ||||||||||
| 25 | |||||||||||
| 26 | sleep 1 while !$acme->poll_authorization(); | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | =head1 DESCRIPTION | ||||||||||
| 30 | |||||||||||
| 31 | This module is instantiated by L<Net::ACME2::Authorization> and is a | ||||||||||
| 32 | subclass of L<Net::ACME2::Challenge>. | ||||||||||
| 33 | |||||||||||
| 34 | =head1 METHODS | ||||||||||
| 35 | |||||||||||
| 36 | =head2 I<OBJ>->create_handler( KEY_AUTHZ, DOCROOT ) | ||||||||||
| 37 | |||||||||||
| 38 | Creates a file in the given DOCROOT that will, if served up normally, | ||||||||||
| 39 | satisfy ACME’s requirements for this challenge. The return value is | ||||||||||
| 40 | an object that, when DESTROYed, will remove that file. | ||||||||||
| 41 | |||||||||||
| 42 | (KEY_AUTHZ is the return of the L<Net::ACME2> instance’s | ||||||||||
| 43 | C<make_key_authorization()> method.) | ||||||||||
| 44 | |||||||||||
| 45 | This can simplify the authorization process | ||||||||||
| 46 | if you’re on the same server as all of the authorization object’s | ||||||||||
| 47 | identifiers’ HTTP document roots. | ||||||||||
| 48 | |||||||||||
| 49 | =cut | ||||||||||
| 50 | |||||||||||
| 51 | sub create_handler { | ||||||||||
| 52 | 2 | ▶ | my ($self, $key_authorization, $docroot) = @_; | ||||||||
|
Subroutine
create_handler: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 53 | |||||||||||
| 54 | 2 | ▶ | die 'need key authz!' if !$key_authorization; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 2 | ▶ | die 'need docroot!' if !length $docroot; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | |||||||||||
| 57 | 2 | my $class = (ref $self) . '::Handler'; | |||||||||
| 58 | |||||||||||
| 59 | 2 | require Module::Load; | |||||||||
| 60 | 2 | Module::Load::load($class); | |||||||||
| 61 | |||||||||||
| 62 | 2 | return $class->new( | |||||||||
| 63 | key_authorization => $key_authorization, | ||||||||||
| 64 | challenge => $self, | ||||||||||
| 65 | document_root => $docroot, | ||||||||||
| 66 | ); | ||||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | =head2 I<OBJ>->path() | ||||||||||
| 70 | |||||||||||
| 71 | Returns the URL path that needs to serve up the | ||||||||||
| 72 | key authorization. This is useful if, for whatever reason, you’re not | ||||||||||
| 73 | using C<create_handler()> to satisfy this challenge. | ||||||||||
| 74 | |||||||||||
| 75 | Example: | ||||||||||
| 76 | |||||||||||
| 77 | /.well-known/acme-challenge/LoqXcYV8q5ONbJQxbmR7SCTNo3tiAXDfowyjxAjEuX0 | ||||||||||
| 78 | |||||||||||
| 79 | =cut | ||||||||||
| 80 | |||||||||||
| 81 | sub path { | ||||||||||
| 82 | 4 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 83 | |||||||||||
| 84 | 4 | my $token = $self->token(); | |||||||||
| 85 | |||||||||||
| 86 | 4 | return $self->PATH_DIRECTORY() . "/$token"; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 1 | 1; | |||||||||