| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::ACME::Utils; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Net::ACME::Utils - utilities for C |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Net::ACME::Utils::verify_token('blah/blah'); #dies |
|
12
|
|
|
|
|
|
|
Net::ACME::Utils::verify_token('blah-blah'); #succeeds |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This module is a home for “miscellaneous” functions that just aren’t |
|
17
|
|
|
|
|
|
|
in other modules. Think carefully before expanding this module; it’s |
|
18
|
|
|
|
|
|
|
probably better, if possible, to put new functionality into more |
|
19
|
|
|
|
|
|
|
topic-specific modules rather than this “catch-all” one. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
13
|
|
|
13
|
|
120077
|
use strict; |
|
|
13
|
|
|
|
|
35
|
|
|
|
13
|
|
|
|
|
377
|
|
|
24
|
13
|
|
|
13
|
|
61
|
use warnings; |
|
|
13
|
|
|
|
|
26
|
|
|
|
13
|
|
|
|
|
314
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
13
|
|
|
13
|
|
1436
|
use MIME::Base64 (); |
|
|
13
|
|
|
|
|
2135
|
|
|
|
13
|
|
|
|
|
400
|
|
|
27
|
|
|
|
|
|
|
*_to_base64url = \&MIME::Base64::encode_base64url; |
|
28
|
|
|
|
|
|
|
|
|
29
|
13
|
|
|
13
|
|
1198
|
use Net::ACME::Crypt (); |
|
|
13
|
|
|
|
|
31
|
|
|
|
13
|
|
|
|
|
267
|
|
|
30
|
13
|
|
|
13
|
|
72
|
use Net::ACME::X (); |
|
|
13
|
|
|
|
|
27
|
|
|
|
13
|
|
|
|
|
4118
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %KEY_OBJ_CACHE; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#Clear out the cache prior to global destruction. |
|
35
|
|
|
|
|
|
|
END { |
|
36
|
13
|
|
|
13
|
|
1321303
|
%KEY_OBJ_CACHE = (); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub verify_token { |
|
40
|
9
|
|
|
9
|
0
|
2158
|
my ($token) = @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#cf. eval_bug.readme |
|
43
|
9
|
|
|
|
|
23
|
my $eval_err = $@; |
|
44
|
|
|
|
|
|
|
|
|
45
|
9
|
|
|
|
|
17
|
eval { |
|
46
|
|
|
|
|
|
|
|
|
47
|
9
|
50
|
33
|
|
|
71
|
die Net::ACME::X::create('Empty') if !defined $token || !length $token; |
|
48
|
9
|
50
|
|
|
|
63
|
die Net::ACME::X::create('Empty') if $token =~ m<\A\s*\z>; |
|
49
|
|
|
|
|
|
|
|
|
50
|
9
|
100
|
|
|
|
44
|
if ( $token =~ m<[^0-9a-zA-Z_-]> ) { |
|
51
|
1
|
|
|
|
|
7
|
die Net::ACME::X::create( 'InvalidCharacters', "“$token” contains invalid Base64-URL characters.", { value => $token } ); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
9
|
100
|
|
|
|
71
|
if ($@) { |
|
57
|
1
|
|
|
|
|
4
|
my $message = $@->to_string(); |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
6
|
die Net::ACME::X::create( 'InvalidParameter', "“$token” is not a valid ACME token. ($message)" ); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
8
|
|
|
|
|
18
|
$@ = $eval_err; |
|
63
|
|
|
|
|
|
|
|
|
64
|
8
|
|
|
|
|
22
|
return; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#Use this to avoid a Try::Tiny dependency. |
|
68
|
|
|
|
|
|
|
sub thing_isa { |
|
69
|
8
|
|
|
8
|
0
|
20
|
my ($thing, $class) = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#cf. eval_bug.readme |
|
72
|
8
|
|
|
|
|
17
|
my $eval_err = $@; |
|
73
|
|
|
|
|
|
|
|
|
74
|
8
|
|
|
|
|
13
|
my $isa = eval { $thing->isa($class) }; |
|
|
8
|
|
|
|
|
57
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
8
|
|
|
|
|
15
|
$@ = $eval_err; |
|
77
|
|
|
|
|
|
|
|
|
78
|
8
|
|
|
|
|
37
|
return $isa; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |