| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::ACME2::Challenge::http_01; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
118426
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
53
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
60
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
37
|
use parent qw( Net::ACME2::ChallengeBase::HasToken ); |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
71
|
use constant _PATH_DIRECTORY => '/.well-known/acme-challenge'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
420
|
|
|
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 and is a |
|
32
|
|
|
|
|
|
|
subclass of L. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 I->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 instance’s |
|
43
|
|
|
|
|
|
|
C 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
|
|
|
2
|
1
|
866
|
my ($self, $key_authorization, $docroot) = @_; |
|
53
|
|
|
|
|
|
|
|
|
54
|
2
|
50
|
|
|
|
6
|
die 'need key authz!' if !$key_authorization; |
|
55
|
2
|
50
|
|
|
|
5
|
die 'need docroot!' if !length $docroot; |
|
56
|
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
7
|
my $class = (ref $self) . '::Handler'; |
|
58
|
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
10
|
require Module::Load; |
|
60
|
2
|
|
|
|
|
8
|
Module::Load::load($class); |
|
61
|
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
163
|
return $class->new( |
|
63
|
|
|
|
|
|
|
key_authorization => $key_authorization, |
|
64
|
|
|
|
|
|
|
challenge => $self, |
|
65
|
|
|
|
|
|
|
document_root => $docroot, |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 I->get_path() |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns the path component of the URL that should serve up the |
|
74
|
|
|
|
|
|
|
relevant content. This is useful if, for whatever reason, |
|
75
|
|
|
|
|
|
|
you’re not using C to satisfy this challenge. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Example: |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
/.well-known/acme-challenge/LoqXcYV8q5ONbJQxbmR7SCTNo3tiAXDfowyjxAjEuX0 |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_path { |
|
84
|
4
|
|
|
4
|
1
|
14
|
my ($self) = @_; |
|
85
|
|
|
|
|
|
|
|
|
86
|
4
|
|
|
|
|
23
|
my $token = $self->token(); |
|
87
|
|
|
|
|
|
|
|
|
88
|
4
|
|
|
|
|
31
|
return $self->_PATH_DIRECTORY() . "/$token"; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# legacy - a courtesy to early adopters |
|
92
|
|
|
|
|
|
|
*path = \*get_path; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 I->get_content( $ACME ) |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Accepts a L instance and returns the content that the |
|
99
|
|
|
|
|
|
|
URL should serve. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Example: |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
q1hcOY6mDLNh7jummITkoQ1PHBpaxwNwyERZEqbADqI._jDy0skz-fuLE9OyLfS2UBa9z9QtS_MZGWq3x2nMx34 |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub get_content { |
|
108
|
0
|
|
|
0
|
1
|
|
my ($self, $acme) = @_; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Errors for the programmer. |
|
111
|
0
|
0
|
|
|
|
|
if (!$acme) { |
|
112
|
0
|
|
|
|
|
|
die 'Need “Net::ACME2” instance to compute HTTP content!' |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
return $acme->make_key_authorization($self); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |