line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ACME2::Error; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Net::ACME2::Error - error parsing logic for ACME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Net::ACME2::Error; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $err = Net::ACME2::Error->new( { type => '..', .. } ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This simple module interfaces with ACME2 “error” objects, |
18
|
|
|
|
|
|
|
which are described in the ACME protocol specification. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NOTES |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
ACME’s errors are basically just HTTP API problem detail documents, |
23
|
|
|
|
|
|
|
which are described in more detail at L. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
6
|
|
|
6
|
|
84109
|
use strict; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
155
|
|
28
|
6
|
|
|
6
|
|
27
|
use warnings; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
143
|
|
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
6
|
|
510
|
use parent qw( Net::ACME2::AccessorBase ); |
|
6
|
|
|
|
|
354
|
|
|
6
|
|
|
|
|
27
|
|
31
|
|
|
|
|
|
|
|
32
|
6
|
|
|
6
|
|
1819
|
use Call::Context (); |
|
6
|
|
|
|
|
1326
|
|
|
6
|
|
|
|
|
179
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $URN_PREFIX = 'urn:ietf:params:acme:error:'; |
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
|
|
697
|
use constant _ACCESSORS => qw( |
37
|
|
|
|
|
|
|
detail |
38
|
|
|
|
|
|
|
instance |
39
|
|
|
|
|
|
|
status |
40
|
|
|
|
|
|
|
title |
41
|
|
|
|
|
|
|
type |
42
|
6
|
|
|
6
|
|
31
|
); |
|
6
|
|
|
|
|
9
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#cf. https://ietf-wg-acme.github.io/acme/#errors |
45
|
6
|
|
|
|
|
2202
|
use constant _TYPE_DESCRIPTION => { |
46
|
|
|
|
|
|
|
badCSR => 'The CSR is unacceptable (e.g., due to a short key)', |
47
|
|
|
|
|
|
|
badNonce => 'The client sent an unacceptable anti-replay nonce', |
48
|
|
|
|
|
|
|
badSignatureAlgorithm => 'The JWS was signed with an algorithm the server does not support', |
49
|
|
|
|
|
|
|
invalidContact => 'A contact URL for an account was invalid', |
50
|
|
|
|
|
|
|
unsupportedContact => 'A contact URL for an account used an unsupported protocol scheme', |
51
|
|
|
|
|
|
|
accountDoesNotExist => 'The request specified an account that does not exist', |
52
|
|
|
|
|
|
|
malformed => 'The request message was malformed', |
53
|
|
|
|
|
|
|
rateLimited => 'The request exceeds a rate limit', |
54
|
|
|
|
|
|
|
rejectedIdentifier => 'The server will not issue for the identifier', |
55
|
|
|
|
|
|
|
serverInternal => 'The server experienced an internal error', |
56
|
|
|
|
|
|
|
unauthorized => 'The client lacks sufficient authorization', |
57
|
|
|
|
|
|
|
unsupportedIdentifier => 'Identifier is not supported, but may be in the future', |
58
|
|
|
|
|
|
|
userActionRequired => 'Visit the “instance” URL and take actions specified there', |
59
|
|
|
|
|
|
|
badRevocationReason => 'The revocation reason provided is not allowed by the server', |
60
|
|
|
|
|
|
|
dns => 'There was a problem with a DNS query', |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
connection => 'The server could not connect to a validation target', |
63
|
|
|
|
|
|
|
dnssec => 'The server could not validate a DNSSEC signed domain', |
64
|
|
|
|
|
|
|
caa => 'CAA records forbid the CA from issuing', |
65
|
|
|
|
|
|
|
tls => 'The server received a TLS error during validation', |
66
|
|
|
|
|
|
|
incorrectResponse => 'Response received didn’t match the challenge’s requirements', |
67
|
6
|
|
|
6
|
|
37
|
}; |
|
6
|
|
|
|
|
9
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 ACCESSORS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * C |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * C |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item * C |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * C |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * C - defaults to C |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * C - text description of the C |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * C - list of subproblem objects |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item * C - human-readable description of the error |
88
|
|
|
|
|
|
|
(including subproblems) |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub type { |
95
|
21
|
|
|
21
|
1
|
59
|
my ($self) = @_; |
96
|
|
|
|
|
|
|
|
97
|
21
|
|
100
|
|
|
79
|
return $self->SUPER::type() || 'about:blank'; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub description { |
101
|
10
|
|
|
10
|
1
|
15
|
my ($self) = @_; |
102
|
|
|
|
|
|
|
|
103
|
10
|
|
|
|
|
17
|
my $type = $self->type(); |
104
|
|
|
|
|
|
|
|
105
|
10
|
|
|
|
|
50
|
$type =~ s<\A$URN_PREFIX><>; |
106
|
|
|
|
|
|
|
|
107
|
10
|
|
|
|
|
26
|
return _TYPE_DESCRIPTION()->{$type}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub subproblems { |
111
|
11
|
|
|
11
|
1
|
17
|
my ($self) = @_; |
112
|
|
|
|
|
|
|
|
113
|
11
|
|
|
|
|
30
|
Call::Context::must_be_list(); |
114
|
|
|
|
|
|
|
|
115
|
11
|
100
|
|
|
|
118
|
my $subs_ar = $self->{'_subproblems'} or return; |
116
|
|
|
|
|
|
|
|
117
|
3
|
|
|
|
|
7
|
return map { Net::ACME2::Error::Subproblem->new(%$_) } @$subs_ar; |
|
6
|
|
|
|
|
27
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub to_string { |
121
|
10
|
|
|
10
|
1
|
38
|
my ($self) = @_; |
122
|
|
|
|
|
|
|
|
123
|
10
|
|
|
|
|
46
|
my $str = join( q< >, grep { defined } $self->status(), $self->type() ); |
|
20
|
|
|
|
|
49
|
|
124
|
|
|
|
|
|
|
|
125
|
10
|
|
|
|
|
24
|
for my $attribute ( qw( title description detail instance ) ) { |
126
|
40
|
|
|
|
|
149
|
my $value = $self->$attribute(); |
127
|
40
|
100
|
66
|
|
|
116
|
if ( defined $value && length $value ) { |
128
|
6
|
|
|
|
|
19
|
$str .= " ($value)"; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
10
|
|
|
|
|
23
|
my @subs = $self->subproblems(); |
133
|
10
|
100
|
|
|
|
23
|
if (@subs) { |
134
|
2
|
|
|
|
|
6
|
$str .= ' (' . join(', ', map { $_->to_string() } @subs) . ')'; |
|
4
|
|
|
|
|
10
|
|
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
10
|
|
|
|
|
59
|
return $str; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
package Net::ACME2::Error::Subproblem; |
143
|
|
|
|
|
|
|
|
144
|
6
|
|
|
6
|
|
39
|
use parent qw( Net::ACME2::Error ); |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
27
|
|
145
|
|
|
|
|
|
|
|
146
|
6
|
|
|
|
|
832
|
use constant _ACCESSORS => ( |
147
|
|
|
|
|
|
|
__PACKAGE__->SUPER::_ACCESSORS(), |
148
|
|
|
|
|
|
|
'identifier', |
149
|
6
|
|
|
6
|
|
413
|
); |
|
6
|
|
|
|
|
12
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub to_string { |
152
|
6
|
|
|
6
|
|
7308
|
my ($self) = @_; |
153
|
|
|
|
|
|
|
|
154
|
6
|
|
|
|
|
12
|
my $identifier_str = join('/', @{ $self->identifier() }{'type', 'value'}); |
|
6
|
|
|
|
|
28
|
|
155
|
|
|
|
|
|
|
|
156
|
6
|
|
|
|
|
21
|
return "$identifier_str: " . $self->SUPER::to_string(); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; |