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