| 1 | package Crypt::Perl::X509::Extension::acmeValidation_v1; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | =encoding utf-8 | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | See L<Crypt::Perl::X509v3> 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<https://datatracker.ietf.org/doc/draft-ietf-acme-tls-alpn/>. | ||
| 25 | |||
| 26 | =cut | ||
| 27 | |||
| 28 | use parent qw( Crypt::Perl::X509::Extension ); | ||
| 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 | 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 | }; | ||
| 46 | |||
| 47 | my $str_len = 32; | ||
| 48 | |||
| 49 | sub new { | ||
| 50 | my ($class, $octets) = @_; | ||
| 51 | |||
| 52 | if ($str_len != length($octets)) { | ||
| 53 | die sprintf( 'Must have %d bytes, not “%v.02x”!', $str_len, $octets ); | ||
| 54 | } | ||
| 55 | |||
| 56 | return bless \$octets, $class | ||
| 57 | } | ||
| 58 | |||
| 59 | sub _encode_params { | ||
| 60 | return ${ $_[0] }; | ||
| 61 | } | ||
| 62 | |||
| 63 | 1; |