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   458 use strict;
  1         8  
  1         25  
4 1     1   6 use warnings;
  1         2  
  1         37  
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 extension to use with the experimental ACME TLS ALPN
23             challenge, described at
24             L.
25              
26             =cut
27              
28 1     1   6 use parent qw( Crypt::Perl::X509::Extension );
  1         2  
  1         5  
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             # id-pe-acmeIdentifier-v1 = id-pe-acmeIdentifier 1
37             #
38 1         157 OID => '1.3.6.1.5.5.7.1.30.1',
39              
40             CRITICAL => 1,
41              
42             # This results in an OCTET STRING that nests inside the extension’s
43             # own OCTET STRING. That seems to be what ACME wants.
44             ASN1 => 'acmeValidation_v1 ::= OCTET STRING',
45 1     1   582 };
  1         29  
46              
47             my $str_len = 32;
48              
49             sub new {
50 6     6 0 27 my ($class, $octets) = @_;
51              
52 6 50       21 if ($str_len != length($octets)) {
53 0         0 die sprintf( 'Must have %d bytes, not “%v.02x”!', $str_len, $octets );
54             }
55              
56 6         47 return bless \$octets, $class
57             }
58              
59             sub _encode_params {
60 6     6   14 return ${ $_[0] };
  6         32  
61             }
62              
63             1;