| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Protocol::ACME::Challenge::SimpleSSH; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Protocol::ACME::Challenge::SimpleSSH - Challenge handler for simpleHttp via SSH |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Protocol::ACME::Challenge::SimpleSSH; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $args = { 'www_root' => "/path/to/htdocs/or/equivalent", |
|
12
|
|
|
|
|
|
|
'ssh_host' => "ssh.example.com" }; |
|
13
|
|
|
|
|
|
|
my $challenge = Protocol::ACME::Challenge::SimpleSSH->new( $args ); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
... |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$acme->handle_challenge( $challenges->{$domain} ); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
The C class is a handler intended |
|
22
|
|
|
|
|
|
|
to be run when the ACME script is run on a different machine than the |
|
23
|
|
|
|
|
|
|
web server. It will create the challenge file in the designated location |
|
24
|
|
|
|
|
|
|
via SSH. Note that there is no attempt to escalate privleges so the |
|
25
|
|
|
|
|
|
|
location will need to be writabel by the ssh user. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 CONSTRUCTOR METHODS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The following constructor methods are available: |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=over 4 |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item $acme = Protcol::ACME::Challenge::SimpleSSH->new( %options ) |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This method constructs a new C object |
|
36
|
|
|
|
|
|
|
and returns it. Key/value pair arguments may be provided to set up the |
|
37
|
|
|
|
|
|
|
initial state. The may be passed in as a hash or a hashref. The following options |
|
38
|
|
|
|
|
|
|
correspond to attribute methods described below. Items markes with |
|
39
|
|
|
|
|
|
|
a * are required. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
KEY DEFAULT |
|
42
|
|
|
|
|
|
|
----------- -------------------- |
|
43
|
|
|
|
|
|
|
*www_root Path to web root that will handle the HTTP |
|
44
|
|
|
|
|
|
|
challenge |
|
45
|
|
|
|
|
|
|
*ssh_host Hostname of the web server for ssh access |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=back |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 METHODS |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=over |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item handle( $challenge, $fingerprint ) |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This is intended to be called indirectly via the ACME driver class. |
|
56
|
|
|
|
|
|
|
C will take care of all of the conditions necessary to satisfy |
|
57
|
|
|
|
|
|
|
the challenge sent by Let's Encrypt. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item cleanup |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
C will remove the challenge file. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
1
|
|
|
1
|
|
926
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
68
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
1
|
|
|
1
|
|
7
|
use parent qw ( Protocol::ACME::Challenge ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
71
|
1
|
|
|
1
|
|
63
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
488
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub new |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
78
|
0
|
|
|
|
|
|
my $self = {}; |
|
79
|
0
|
|
|
|
|
|
bless $self, $class; |
|
80
|
0
|
|
|
|
|
|
$self->_init( @_ ); |
|
81
|
0
|
|
|
|
|
|
return $self; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _init |
|
85
|
|
|
|
|
|
|
{ |
|
86
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
87
|
0
|
|
|
|
|
|
my $args; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
if ( @_ == 1 ) |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
0
|
|
|
|
|
|
$args = shift; |
|
92
|
0
|
0
|
|
|
|
|
if ( ref $args ne "HASH" ) |
|
93
|
|
|
|
|
|
|
{ |
|
94
|
0
|
|
|
|
|
|
croak "Must pass a hash or hashref to challenge constructor"; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
else |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
0
|
|
|
|
|
|
$args = \%_; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
for my $required_arg ( qw ( ssh_host www_root ) ) |
|
103
|
|
|
|
|
|
|
{ |
|
104
|
0
|
0
|
|
|
|
|
if ( ! exists $args->{$required_arg} ) |
|
105
|
|
|
|
|
|
|
{ |
|
106
|
0
|
|
|
|
|
|
croak "Require arg $required_arg missing from chalenge constructor"; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
else |
|
109
|
|
|
|
|
|
|
{ |
|
110
|
0
|
|
|
|
|
|
$self->{$required_arg} = $args->{$required_arg}; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$self->{filename} = undef; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub handle |
|
119
|
|
|
|
|
|
|
{ |
|
120
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
121
|
0
|
|
|
|
|
|
my $challenge = shift; |
|
122
|
0
|
|
|
|
|
|
my $fingerprint = shift; |
|
123
|
0
|
|
|
|
|
|
my $dir = "$self->{www_root}/.well-known/acme-challenge"; |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my $filename = "$dir/$challenge"; |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my @cmd = ('ssh', '-q', $self->{ssh_host}, "mkdir -p '$dir' && echo '$challenge.$fingerprint' > '$filename'"); |
|
128
|
0
|
|
|
|
|
|
system @cmd; |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
my $ret = $?; |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
$self->{filename} = $filename; |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
return $ret == 0 ? 0 : 1; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub cleanup |
|
138
|
|
|
|
|
|
|
{ |
|
139
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
140
|
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
my @cmd = ('ssh', '-q', $self->{ssh_host}, "rm -f '$self->{filename}'"); |
|
142
|
0
|
|
|
|
|
|
system @cmd; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Stephen Ludin, C<< >> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 BUGS |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
153
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
154
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Copyright 2015 Stephen Ludin. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
167
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
|
168
|
|
|
|
|
|
|
copy of the full license at: |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
L |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
|
173
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
|
174
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
|
175
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
|
178
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
|
179
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
|
182
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
|
185
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
|
186
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
|
187
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
|
188
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
|
189
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
|
190
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
|
191
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
|
194
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
|
195
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
196
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
|
197
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
|
198
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
|
199
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
|
200
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; |