.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Protocol::ACME 3pm" .TH Protocol::ACME 3pm "2018-05-18" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Protocol::ACME \- Interface to the Let's Encrypt ACME API .SH "VERSION" .IX Header "VERSION" Version 1.01 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Protocol::ACME; \& \& my @names = qw( www.example.com cloud.example.com ); \& \& my $challenges = { \& \*(Aqwww.example.com\*(Aq => Protocol::ACME::Challenge::SimpleSSH\->new( \& { ssh_host => "host1", www_root => "~/www" } \& ), \& \*(Aqcloud.example.com\*(Aq => Protocol::ACME::Challenge::SimpleSSH\->new( \& { ssh_host => "home2", www_root => "/opt/local/www/htdocs" } \& ) \& }; \& \& eval \& { \& my $acme = Protocol::ACME\->new( host => $host, \& account_key => $account_key_pem_or_der, \& ); \& \& $acme\->directory(); \& $acme\->register(); \& $acme\->accept_tos(); \& \& for my $domain ( @names ) \& { \& $acme\->authz( $domain ); \& $acme\->handle_challenge( $challenges\->{$domain} ); \& $acme\->check_challenge(); \& $acme\->cleanup_challenge( $challenges\->{$domain} ); \& } \& \& my $cert = $acme\->sign( $csr_file ); \& }; \& if ( $@ ) \& { \& die if !UNIVERSAL::isa($@, \*(AqProtocol::ACME::Exception\*(Aq); \& die "Error occurred: Status: $@\->{status}, \& Detail: $@\->{detail}, \& Type: $@\->{type}\en"; \& } \& else \& { \& # do something appropriate with the DER encoded cert \& print "Success\en"; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`Protocol::ACME\*(C'\fR is a class implementing an interface for the Let's Encrypt \s-1ACME API.\s0 .PP The class handles the protocol details behind provisioning a Let's Encrypt certificate. .SH "CONSTRUCTOR METHODS" .IX Header "CONSTRUCTOR METHODS" The following constructor methods are available: .ie n .IP "$acme = Protcol::ACME\->new( %options )" 4 .el .IP "\f(CW$acme\fR = Protcol::ACME\->new( \f(CW%options\fR )" 4 .IX Item "$acme = Protcol::ACME->new( %options )" This method constructs a new \f(CW\*(C`Protocl::ACME\*(C'\fR object and returns it. Key/value pair arguments may be provided to set up the initial state. The may be passed in as a hash or a hashref. The following options correspond to attribute methods described below. Items marked with a * are required. .Sp .Vb 9 \& KEY DEFAULT \& \-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& *host undef \& account_key undef \& openssl undef \& ua HTTP::Tiny\->new() \& loglevel error \& debug 0 \& mailto undef .Ve .Sp \&\fBhost\fR: The \s-1API\s0 end point to connect to. This will generally be acme\-staging.api.letsencrypt.org or acme\-v01.api.letsencrypt.org .Sp \&\fBaccount_key\fR: The account private key in a scalar ref or filename. See \f(CW\*(C`$self\-\*(C'\fRaccount_key> for details on this argument. .Sp \&\fBopenssl\fR: The path to openssl. If this option is used a local version of the openssl binary will be used for crypto operations rather than \f(CW\*(C`Crypt::OpenSSL::RSA\*(C'\fR. .Sp \&\fBua\fR: An HTTP::Tiny object customized as you see fit .Sp \&\fBloglevel\fR: Set the loglevel to one of the \f(CW\*(C`Log::Any\*(C'\fR values. .Sp \&\fBdebug\fR: If set to non-zero this is a shortcut for \f(CW\*(C`loglevel =\*(C'\fR debug> .Sp \&\fBmailto\fR: This should be the email address that you want associated with your account. This is used my Let's Encrypt for expiration notification. .SS "\s-1METHODS\s0" .IX Subsection "METHODS" .ie n .IP "account_key( $key_filename )" 4 .el .IP "account_key( \f(CW$key_filename\fR )" 4 .IX Item "account_key( $key_filename )" .PD 0 .IP "account_key( \e$buffer )" 4 .IX Item "account_key( $buffer )" .IP "account_key( \e%explicit_args )" 4 .IX Item "account_key( %explicit_args )" .PD \&\f(CW\*(C`account_key\*(C'\fR will load a the private account key if it was not already loaded when the \f(CW\*(C`pProtocol::ACME\*(C'\fR object was constructed. There are three ways to call this: .Sp If the arg is a \fB\s-1SCALAR\s0\fR it is assumed to be the filename of the key. \f(CW\*(C`account_key\*(C'\fR will throw an error if there are problems reading the file. .Sp If the arg is a \fB\s-1SCALAR\s0\fR reference it is assumed to be a buffer that contains the \s-1KEY.\s0 .Sp If the arg is a \fB\s-1HASH\s0\fR reference it contains named arguments. The arguments are: .Sp .Vb 5 \& KEY DEFAUL DESC \& \-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& filename undef The key Filename \& buffer undef Buffer containing the key \& format undef Explicitly state the format ( DER | PEM ) .Ve .Sp If both \f(CW\*(C`filename\*(C'\fR and \f(CW\*(C`buffer\*(C'\fR are set the \f(CW\*(C`buffer\*(C'\fR argument will be ignored. .Sp If the format is not explcitly set \f(CW\*(C`Protocol::ACME\*(C'\fR will look at the key and try and determine what the format it. .ie n .IP "load_key_from_disk( $key_path )" 4 .el .IP "load_key_from_disk( \f(CW$key_path\fR )" 4 .IX Item "load_key_from_disk( $key_path )" \&\fB\s-1DEPRECATED\s0\fR .Sp Load a key from disk. Currently the key needs to be unencrypted. Callbacks for handling password protected keys are still to come. .IP "\fIdirectory()\fR" 4 .IX Item "directory()" Loads the directory from the \s-1ACME\s0 host. This call must be made first before any other calls to the \s-1API\s0 in order the bootstrap the \s-1API\s0 resource list. .ie n .IP "register( %args )" 4 .el .IP "register( \f(CW%args\fR )" 4 .IX Item "register( %args )" Call the new-reg resource and create an account associated with the loaded account key. If that key has already been registered this method will gracefully and silently handle that. .Sp Arguments that can be passed in: .Sp .Vb 3 \& KEY DEFAULT \& \-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& mailto undef .Ve .Sp \&\fBmailto\fR: See \f(CW\*(C`new\*(C'\fR for a desciption. This will override the value passed to new if any. .IP "\fIaccept_tos()\fR" 4 .IX Item "accept_tos()" In order to use the Let's Encrypt service, the account needs to accept the Terms of Service. This is provided in a link header in response to the new-reg ( or reg ) resource call. If the \s-1TOS\s0 have already been accepted as indicated by the reg structure returned by the \s-1API\s0 this call will be a noop. .ie n .IP "authz( $domain )" 4 .el .IP "authz( \f(CW$domain\fR )" 4 .IX Item "authz( $domain )" \&\f(CW\*(C`authz\*(C'\fR needs to be called for each domain ( called identifiers in \&\s-1ACME\s0 speak ) in the certificate. This included the domain in the subject as well as the Subject Alternate Name (\s-1SAN\s0) fields. Each call to \&\f(CW\*(C`authz\*(C'\fR will result in a challenge being issued from Let's Encrypt. These challenges need to be handled individually. .ie n .IP "handle_challenge( $challenge_object )" 4 .el .IP "handle_challenge( \f(CW$challenge_object\fR )" 4 .IX Item "handle_challenge( $challenge_object )" \&\f(CW\*(C`handle_challenge\*(C'\fR is called for each challenge issued by \f(CW\*(C`authz\*(C'\fR. The challenge object must be a subclass of \f(CW\*(C`Protocol::ACME::Challenge\*(C'\fR which implements a 'handle' method. This objects handle method will be passed three arguments and is expected to fulfill the preconditions for the chosen challenge. The three areguments are: .Sp .Vb 3 \& fingerprint: the sha256 hex digest of the account key \& token: the challenge token \& url: the url returned by the challenge .Ve .Sp Fully describing how to handle every challenge type of out of the scope of this documentation ( at least for now ). Two challenge classes have been included for reference: .Sp \&\f(CW\*(C`Protocol::ACME::Challenge::SimpleSSH\*(C'\fR is initialized with the ssh host name and the www root for the web server for the http\-01 challenge. It will ssh to the host and create the file in the correct location for challenge fulfillment. .Sp \&\f(CW\*(C`Protocol::ACME::Challenge::LocalFile\*(C'\fR is initialized with just the www root for the web server for the http\-01 challenge. It will simply create the challenge file in the correct place on the local filesystem. .Sp \&\f(CW\*(C`Protocol::ACME::Challenge::Manual\*(C'\fR is intended to be run in an interactive manner and will stop and prompt the user with the relevant information so they can fulfill the challenge manually. .Sp but below is an example for handling the simpleHTTP ( http\-01 ) challenge. .IP "\fIcheck_challenge()\fR" 4 .IX Item "check_challenge()" Called after \f(CW\*(C`handle_challenge\*(C'\fR. This will poll the challenge status resource and will return when the state changes from 'pending'. .IP "\fIcleanup_challenge()\fR" 4 .IX Item "cleanup_challenge()" Called after \f(CW\*(C`check_challenge\*(C'\fR to remove the challenge files. .ie n .IP "$cert = sign( $csr_filename )" 4 .el .IP "\f(CW$cert\fR = sign( \f(CW$csr_filename\fR )" 4 .IX Item "$cert = sign( $csr_filename )" .PD 0 .ie n .IP "$cert = sign( \e$buffer )" 4 .el .IP "\f(CW$cert\fR = sign( \e$buffer )" 4 .IX Item "$cert = sign( $buffer )" .ie n .IP "$cert = sign( \e%explicit_args )" 4 .el .IP "\f(CW$cert\fR = sign( \e%explicit_args )" 4 .IX Item "$cert = sign( %explicit_args )" .PD Call \f(CW\*(C`sign\*(C'\fR after the challenge for each domain ( itentifier ) has been fulfilled. There are three ways to call this: .Sp If the arg is a \fB\s-1SCALAR\s0\fR it is assumed to be the filename of the \&\s-1CSR.\s0 \f(CW\*(C`sign\*(C'\fR will throw an error if there are problems reading the file. .Sp If the arg is a \fB\s-1SCALAR\s0\fR reference it is assumed to be a buffer that contains the \s-1CSR.\s0 .Sp If the arg is a \fB\s-1HASH\s0\fR reference it contains named arguments. The arguments are: .Sp .Vb 5 \& KEY DEFAUL DESC \& \-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& filename undef The CSR Filename \& buffer undef Buffer containing the CSR \& format undef Explicitly state the format ( DER | PEM ) .Ve .Sp If both \f(CW\*(C`filename\*(C'\fR and \f(CW\*(C`buffer\*(C'\fR are set the \f(CW\*(C`buffer\*(C'\fR argument will be ignored. .Sp If the format is not explcitly set Protocol::ACME will look at the \s-1CSR\s0 and try and determine what the format it. .Sp On success \f(CW\*(C`Protocol::ACME\*(C'\fR will return the \s-1DER\s0 encoded signed certificate. .ie n .IP "$cert_chain = \fIchain()\fR" 4 .el .IP "\f(CW$cert_chain\fR = \fIchain()\fR" 4 .IX Item "$cert_chain = chain()" After \f(CW\*(C`sign\*(C'\fR has been called and a cert successfully created, \f(CW\*(C`chain\*(C'\fR will fetch and return the \s-1DER\s0 encoded certificate issuer. .ie n .IP "revoke( $certfile )" 4 .el .IP "revoke( \f(CW$certfile\fR )" 4 .IX Item "revoke( $certfile )" Call \f(CW\*(C`revoke\*(C'\fR to revoke an already issued certificate. \f(CW$certfile\fR must point the a \s-1DER\s0 encoded form of the certificate. .IP "\fIrecovery_key()\fR" 4 .IX Item "recovery_key()" \&\s-1LE\s0 does not yet support recovery keys. This method will die when called. .SH "AUTHOR" .IX Header "AUTHOR" Stephen Ludin, \f(CW\*(C`\*(C'\fR .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \f(CW\*(C`bug\-protocol\-acme at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "REPOSITORY" .IX Header "REPOSITORY" https://github.com/sludin/Protocol\-ACME .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Protocol::ACME .Ve .PP You can also look for information at: .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker (report bugs here) .Sp .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" Felipe Gasper, \f(CW\*(C`\*(C'\fR .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright 2015 Stephen Ludin. .PP This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at: .PP .PP Any use, modification, and distribution of the Standard or Modified Version 1.01 distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. .PP If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. .PP This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. .PP This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. .PP Disclaimer of Warranty: \s-1THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS\s0' \s-1AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\s0 NON-INFRINGEMENT \s-1ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0