line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ACME2::Challenge::http_01; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
112498
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
105
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
110
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
82
|
use parent qw( Net::ACME2::Challenge ); |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
67
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
242
|
use constant _PATH_DIRECTORY => '/.well-known/acme-challenge'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1061
|
|
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( $ACME_OR_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
|
|
|
|
|
|
|
$ACME_OR_AUTHZ is normally a L instance that will be used to |
43
|
|
|
|
|
|
|
compute I’s key authorization. If you already have this authorization |
44
|
|
|
|
|
|
|
(i.e., via I’s C method) you may submit |
45
|
|
|
|
|
|
|
that instead. (Only that key authorization was accepted prior to version |
46
|
|
|
|
|
|
|
0.28 of this distribution.) |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This can simplify the authorization process |
49
|
|
|
|
|
|
|
if you’re on the same server as all of the authorization object’s |
50
|
|
|
|
|
|
|
identifiers’ HTTP document roots. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub create_handler { |
55
|
3
|
|
|
3
|
1
|
858
|
my ($self, $acme_or_key_authz, $docroot) = @_; |
56
|
|
|
|
|
|
|
|
57
|
3
|
50
|
|
|
|
13
|
die 'need Net::ACME2 object or key authz!' if !$acme_or_key_authz; |
58
|
|
|
|
|
|
|
|
59
|
3
|
50
|
|
|
|
7
|
die 'need docroot!' if !length $docroot; |
60
|
|
|
|
|
|
|
|
61
|
3
|
|
|
|
|
4
|
my $class = __PACKAGE__ . '::Handler'; |
62
|
|
|
|
|
|
|
|
63
|
3
|
|
|
|
|
434
|
require Module::Runtime; |
64
|
3
|
|
|
|
|
1512
|
Module::Runtime::use_module($class); |
65
|
|
|
|
|
|
|
|
66
|
3
|
|
|
|
|
99
|
my $key_authz; |
67
|
|
|
|
|
|
|
|
68
|
3
|
100
|
|
|
|
5
|
if (ref $acme_or_key_authz) { |
69
|
1
|
|
|
|
|
5
|
$key_authz = $acme_or_key_authz->make_key_authorization($self); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
2
|
|
|
|
|
5
|
$key_authz = $acme_or_key_authz; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
3
|
|
|
|
|
350
|
return $class->new( |
76
|
|
|
|
|
|
|
key_authorization => $key_authz, |
77
|
|
|
|
|
|
|
challenge => $self, |
78
|
|
|
|
|
|
|
document_root => $docroot, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 I->get_path() |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns the path component of the URL that should serve up the |
87
|
|
|
|
|
|
|
relevant content. This is useful if, for whatever reason, |
88
|
|
|
|
|
|
|
you’re not using C to satisfy this challenge. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Example: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
/.well-known/acme-challenge/LoqXcYV8q5ONbJQxbmR7SCTNo3tiAXDfowyjxAjEuX0 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub get_path { |
97
|
5
|
|
|
5
|
1
|
17
|
my ($self) = @_; |
98
|
|
|
|
|
|
|
|
99
|
5
|
|
|
|
|
28
|
my $token = $self->token(); |
100
|
|
|
|
|
|
|
|
101
|
5
|
|
|
|
|
36
|
return $self->_PATH_DIRECTORY() . "/$token"; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# legacy - a courtesy to early adopters |
105
|
|
|
|
|
|
|
*path = \*get_path; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 I->get_content( $ACME ) |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Accepts a L instance and returns the content that the |
112
|
|
|
|
|
|
|
URL should serve. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Example: |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
q1hcOY6mDLNh7jummITkoQ1PHBpaxwNwyERZEqbADqI._jDy0skz-fuLE9OyLfS2UBa9z9QtS_MZGWq3x2nMx34 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub get_content { |
121
|
0
|
|
|
0
|
1
|
|
my ($self, $acme) = @_; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Errors for the programmer. |
124
|
0
|
0
|
|
|
|
|
if (!$acme) { |
125
|
0
|
|
|
|
|
|
die 'Need “Net::ACME2” instance to compute HTTP content!' |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return $acme->make_key_authorization($self); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |