line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ACME2::Challenge::http_01; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
143821
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
120
|
|
4
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
123
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
22
|
use parent qw( Net::ACME2::Challenge ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
21
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
312
|
use constant _PATH_DIRECTORY => '/.well-known/acme-challenge'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1127
|
|
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
|
1042
|
my ($self, $key_authorization, $docroot) = @_; |
53
|
|
|
|
|
|
|
|
54
|
2
|
50
|
|
|
|
9
|
die 'need key authz!' if !$key_authorization; |
55
|
2
|
50
|
|
|
|
8
|
die 'need docroot!' if !length $docroot; |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
7
|
my $class = (ref $self) . '::Handler'; |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
553
|
require Module::Load; |
60
|
2
|
|
|
|
|
1140
|
Module::Load::load($class); |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
202
|
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
|
18
|
my ($self) = @_; |
85
|
|
|
|
|
|
|
|
86
|
4
|
|
|
|
|
32
|
my $token = $self->token(); |
87
|
|
|
|
|
|
|
|
88
|
4
|
|
|
|
|
40
|
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; |