File Coverage

lib/Crypt/Perl/X509/Extension/acmeValidation_v1.pm
Criterion Covered Total %
statement 17 18 94.4
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 24 27 88.8


line stmt bran cond sub pod time code
1             package Crypt::Perl::X509::Extension::acmeValidation_v1;
2              
3 1     1   599 use strict;
  1         14  
  1         38  
4 1     1   5 use warnings;
  1         14  
  1         33  
5              
6             =encoding utf-8
7              
8             =head1 NAME
9              
10             Crypt::Perl::X509::Extension::acmeValidation_v1
11              
12             =head1 SYNOPSIS
13              
14             See L for a more useful syntax for instantiating
15             this extension as part of certificate creation. The following is how
16             to instantiate it directly .. which isn’t very useful per se.
17              
18             my $extn = Crypt::Perl::X509::Extension::acmeValidation_v1->new(
19             $string_of_32_octets,
20             );
21              
22             =head1 DESCRIPTION
23              
24             This is the X.509 extension to use when creating validation certificates
25             for use with the experimental ACME TLS ALPN challenge, described at
26             L.
27              
28             =cut
29              
30 1     1   6 use parent qw( Crypt::Perl::X509::Extension );
  1         9  
  1         10  
31              
32             use constant {
33              
34             # https://www.ietf.org/rfc/rfc7299.txt
35             # id-pkix = 1.3.6.1.5.5.7
36             # id-pe = id-pkix 1
37             # id-pe-acmeIdentifier = id-pe 31
38             #
39 1         214 OID => '1.3.6.1.5.5.7.1.31',
40              
41             CRITICAL => 1,
42              
43             # This results in an OCTET STRING that nests inside the extension’s
44             # own OCTET STRING. That seems to be what ACME wants.
45             ASN1 => 'acmeValidation_v1 ::= OCTET STRING',
46 1     1   74 };
  1         4  
47              
48             my $str_len = 32;
49              
50             sub new {
51 6     6 0 44 my ($class, $octets) = @_;
52              
53 6 50       39 if ($str_len != length($octets)) {
54 0         0 die sprintf( 'Must have %d bytes, not “%v.02x”!', $str_len, $octets );
55             }
56              
57 6         66 return bless \$octets, $class
58             }
59              
60             sub _encode_params {
61 6     6   20 return ${ $_[0] };
  6         35  
62             }
63              
64             1;