RFC 8555: Automatic Certificate Management Environment (ACME)

  • R. Barnes,  
  • J. Hoffman-Andrews,  
  • D. McCarney,  
  • J. Kasten
Proposed Standard
Internet Engineering Task Force (IETF)                         R. Barnes
Request for Comments: 8555                                         Cisco
Category: Standards Track                             J. Hoffman-Andrews
ISSN: 2070-1721                                                      EFF
                                                             D. McCarney
                                                           Let's Encrypt
                                                               J. Kasten
                                                  University of Michigan
                                                              March 2019


          Automatic Certificate Management Environment (ACME)

Abstract

   Public Key Infrastructure using X.509 (PKIX) certificates are used
   for a number of purposes, the most significant of which is the
   authentication of domain names.  Thus, certification authorities
   (CAs) in the Web PKI are trusted to verify that an applicant for a
   certificate legitimately represents the domain name(s) in the
   certificate.  As of this writing, this verification is done through a
   collection of ad hoc mechanisms.  This document describes a protocol
   that a CA and an applicant can use to automate the process of
   verification and certificate issuance.  The protocol also provides
   facilities for other certificate management functions, such as
   certificate revocation.

Status of This Memo

   This is an Internet Standards Track document.

   This document is a product of the Internet Engineering Task Force
   (IETF).  It represents the consensus of the IETF community.  It has
   received public review and has been approved for publication by the
   Internet Engineering Steering Group (IESG).  Further information on
   Internet Standards is available in .

   Information about the current status of this document, any errata,
   and how to provide feedback on it may be obtained at
   .











Barnes, et al.               Standards Track                    [Page 1]


                          ACME                        March 2019


Copyright Notice

   Copyright (c) 2019 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   (https://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.

Table of Contents

   1. Introduction ....................................................4
   2. Deployment Model and Operator Experience ........................5
   3. Terminology .....................................................7
   4. Protocol Overview ...............................................7
   5. Character Encoding .............................................10
   6. Message Transport ..............................................10
      6.1. HTTPS Requests ............................................10
      6.2. Request Authentication ....................................11
      6.3. GET and POST-as-GET Requests ..............................13
      6.4. Request URL Integrity .....................................13
           6.4.1. "url" (URL) JWS Header Parameter ...................14
      6.5. Replay Protection .........................................14
           6.5.1. Replay-Nonce .......................................15
           6.5.2. "nonce" (Nonce) JWS Header Parameter ...............16
      6.6. Rate Limits ...............................................16
      6.7. Errors ....................................................16
           6.7.1. Subproblems ........................................18
   7. Certificate Management .........................................20
      7.1. Resources .................................................20
           7.1.1. Directory ..........................................23
           7.1.2. Account Objects ....................................24
           7.1.3. Order Objects ......................................26
           7.1.4. Authorization Objects ..............................28
           7.1.5. Challenge Objects ..................................30
           7.1.6. Status Changes .....................................30
      7.2. Getting a Nonce ...........................................34
      7.3. Account Management ........................................34
           7.3.1. Finding an Account URL Given a Key .................36
           7.3.2. Account Update .....................................37
           7.3.3. Changes of Terms of Service ........................38
           7.3.4. External Account Binding ...........................38



Barnes, et al.               Standards Track                    [Page 2]


                          ACME                        March 2019


           7.3.5. Account Key Rollover ...............................40
           7.3.6. Account Deactivation ...............................43
      7.4. Applying for Certificate Issuance .........................44
           7.4.1. Pre-authorization ..................................49
           7.4.2. Downloading the Certificate ........................51
      7.5. Identifier Authorization ..................................53
           7.5.1. Responding to Challenges ...........................54
           7.5.2. Deactivating an Authorization ......................57
      7.6. Certificate Revocation ....................................58
   8. Identifier Validation Challenges ...............................60
      8.1. Key Authorizations ........................................62
      8.2. Retrying Challenges .......................................63
      8.3. HTTP Challenge ............................................63
      8.4. DNS Challenge .............................................66
   9. IANA Considerations ............................................68
      9.1. Media Type: application/pem-certificate-chain .............68
      9.2. Well-Known URI for the HTTP Challenge .....................69
      9.3. Replay-Nonce HTTP Header ..................................69
      9.4. "url" JWS Header Parameter ................................70
      9.5. "nonce" JWS Header Parameter ..............................70
      9.6. URN Sub-namespace for ACME (urn:ietf:params:acme) .........70
      9.7. New Registries ............................................71
           9.7.1. Fields in Account Objects ..........................71
           9.7.2. Fields in Order Objects ............................72
           9.7.3. Fields in Authorization Objects ....................73
           9.7.4. Error Types ........................................74
           9.7.5. Resource Types .....................................74
           9.7.6. Fields in the "meta" Object within a
                  Directory Object ...................................75
           9.7.7. Identifier Types ...................................76
           9.7.8. Validation Methods .................................76
   10. Security Considerations .......................................78
      10.1. Threat Model .............................................78
      10.2. Integrity of Authorizations ..............................80
      10.3. Denial-of-Service Considerations .........................83
      10.4. Server-Side Request Forgery ..............................84
      10.5. CA Policy Considerations .................................84
   11. Operational Considerations ....................................86
      11.1. Key Selection ............................................86
      11.2. DNS Security .............................................87
      11.3. Token Entropy ............................................88
      11.4. Malformed Certificate Chains .............................88
   12. References ....................................................88
      12.1. Normative References .....................................88
      12.2. Informative References ...................................92
   Acknowledgements ..................................................94
   Authors' Addresses ................................................95




Barnes, et al.               Standards Track                    [Page 3]


                          ACME                        March 2019


1.  Introduction

   Certificates [] in the Web PKI are most commonly used to
   authenticate domain names.  Thus, certification authorities (CAs) in
   the Web PKI are trusted to verify that an applicant for a certificate
   legitimately represents the domain name(s) in the certificate.

   Different types of certificates reflect different kinds of CA
   verification of information about the certificate subject.  "Domain
   Validation" (DV) certificates are by far the most common type.  The
   only validation the CA is required to perform in the DV issuance
   process is to verify that the requester has effective control of the
   domain [CABFBR].  The CA is not required to attempt to verify the
   requester's real-world identity.  (This is as opposed to
   "Organization Validation" (OV) and "Extended Validation" (EV)
   certificates, where the process is intended to also verify the real-
   world identity of the requester.)

   Existing Web PKI certification authorities tend to use a set of ad
   hoc protocols for certificate issuance and identity verification.  In
   the case of DV certificates, a typical user experience is something
   like:

   o  Generate a PKCS#10 [] Certificate Signing Request (CSR).

   o  Cut and paste the CSR into a CA's web page.

   o  Prove ownership of the domain(s) in the CSR by one of the
      following methods:

      *  Put a CA-provided challenge at a specific place on the web
         server.

      *  Put a CA-provided challenge in a DNS record corresponding to
         the target domain.

      *  Receive a CA-provided challenge at (hopefully) an
         administrator-controlled email address corresponding to the
         domain, and then respond to it on the CA's web page.

   o  Download the issued certificate and install it on the user's Web
      Server.

   With the exception of the CSR itself and the certificates that are
   issued, these are all completely ad hoc procedures and are
   accomplished by getting the human user to follow interactive natural-
   language instructions from the CA rather than by machine-implemented
   published protocols.  In many cases, the instructions are difficult



Barnes, et al.               Standards Track                    [Page 4]


                          ACME                        March 2019


   to follow and cause significant frustration and confusion.  Informal
   usability tests by the authors indicate that webmasters often need
   1-3 hours to obtain and install a certificate for a domain.  Even in
   the best case, the lack of published, standardized mechanisms
   presents an obstacle to the wide deployment of HTTPS and other PKIX-
   dependent systems because it inhibits mechanization of tasks related
   to certificate issuance, deployment, and revocation.

   This document describes an extensible framework for automating the
   issuance and domain validation procedure, thereby allowing servers
   and infrastructure software to obtain certificates without user
   interaction.  Use of this protocol should radically simplify the
   deployment of HTTPS and the practicality of PKIX-based authentication
   for other protocols based on Transport Layer Security (TLS)
   [].

   It should be noted that while the focus of this document is on
   validating domain names for purposes of issuing certificates in the
   Web PKI, ACME supports extensions for uses with other identifiers in
   other PKI contexts.  For example, as of this writing, there is
   ongoing work to use ACME for issuance of Web PKI certificates
   attesting to IP addresses [ACME-IP] and Secure Telephone Identity
   Revisited (STIR) certificates attesting to telephone numbers
   [ACME-TELEPHONE].

   ACME can also be used to automate some aspects of certificate
   management even where non-automated processes are still needed.  For
   example, the external account binding feature (see Section 7.3.4) can
   allow an ACME account to use authorizations that have been granted to
   an external, non-ACME account.  This allows ACME to address issuance
   scenarios that cannot yet be fully automated, such as the issuance of
   "Extended Validation" certificates.

2.  Deployment Model and Operator Experience

   The guiding use case for ACME is obtaining certificates for websites
   (HTTPS []).  In this case, a web server is intended to speak
   for one or more domains, and the process of certificate issuance is
   intended to verify that this web server actually speaks for the
   domain(s).

   DV certificate validation commonly checks claims about properties
   related to control of a domain name -- properties that can be
   observed by the certificate issuer in an interactive process that can
   be conducted purely online.  That means that under typical
   circumstances, all steps in the request, verification, and issuance
   process can be represented and performed by Internet protocols with
   no out-of-band human intervention.



Barnes, et al.               Standards Track                    [Page 5]


                          ACME                        March 2019


   Prior to ACME, when deploying an HTTPS server, a server operator
   typically gets a prompt to generate a self-signed certificate.  If
   the operator were instead deploying an HTTPS server using ACME, the
   experience would be something like this:

   o  The operator's ACME client prompts the operator for the intended
      domain name(s) that the web server is to stand for.

   o  The ACME client presents the operator with a list of CAs from
      which it could get a certificate.  (This list will change over
      time based on the capabilities of CAs and updates to ACME
      configuration.)  The ACME client might prompt the operator for
      payment information at this point.

   o  The operator selects a CA.

   o  In the background, the ACME client contacts the CA and requests
      that it issue a certificate for the intended domain name(s).

   o  The CA verifies that the client controls the requested domain
      name(s) by having the ACME client perform some action(s) that can
      only be done with control of the domain name(s).  For example, the
      CA might require a client requesting example.com to provision a
      DNS record under example.com or an HTTP resource under
      http://example.com.

   o  Once the CA is satisfied, it issues the certificate and the ACME
      client automatically downloads and installs it, potentially
      notifying the operator via email, SMS, etc.

   o  The ACME client periodically contacts the CA to get updated
      certificates, stapled Online Certificate Status Protocol (OCSP)
      responses [], or whatever else would be required to keep
      the web server functional and its credentials up to date.

   In this way, it would be nearly as easy to deploy with a CA-issued
   certificate as with a self-signed certificate.  Furthermore, the
   maintenance of that CA-issued certificate would require minimal
   manual intervention.  Such close integration of ACME with HTTPS
   servers allows the immediate and automated deployment of certificates
   as they are issued, sparing the human administrator from much of the
   time-consuming work described in the previous section.









Barnes, et al.               Standards Track                    [Page 6]


                          ACME                        March 2019


3.  Terminology

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
   "OPTIONAL" in this document are to be interpreted as described in
   BCP 14 [] [] when, and only when, they appear in all
   capitals, as shown here.

   The two main roles in ACME are "client" and "server".  The ACME
   client uses the protocol to request certificate management actions,
   such as issuance or revocation.  An ACME client may run on a web
   server, mail server, or some other server system that requires valid
   X.509 certificates.  Or, it may run on a separate server that does
   not consume the certificate but is authorized to respond to a CA-
   provided challenge.  The ACME server runs at a certification
   authority and responds to client requests, performing the requested
   actions if the client is authorized.

   An ACME client authenticates to the server by means of an "account
   key pair".  The client uses the private key of this key pair to sign
   all messages sent to the server.  The server uses the public key to
   verify the authenticity and integrity of messages from the client.

4.  Protocol Overview

   ACME allows a client to request certificate management actions using
   a set of JavaScript Object Notation (JSON) messages [] carried
   over HTTPS [].  Issuance using ACME resembles a traditional
   CA's issuance process, in which a user creates an account, requests a
   certificate, and proves control of the domain(s) in that certificate
   in order for the CA to issue the requested certificate.

   The first phase of ACME is for the client to request an account with
   the ACME server.  The client generates an asymmetric key pair and
   requests a new account, optionally providing contact information,
   agreeing to terms of service (ToS), and/or associating the account
   with an existing account in another system.  The creation request is
   signed with the generated private key to prove that the client
   controls it.












Barnes, et al.               Standards Track                    [Page 7]


                          ACME                        March 2019


         Client                                                   Server

         [Contact Information]
         [ToS Agreement]
         [Additional Data]
         Signature                     ------->
                                                             Account URL
                                       <-------           Account Object


                   [] Information covered by request signatures

                             Account Creation

   Once an account is registered, there are four major steps the client
   needs to take to get a certificate:

   1.  Submit an order for a certificate to be issued

   2.  Prove control of any identifiers requested in the certificate

   3.  Finalize the order by submitting a CSR

   4.  Await issuance and download the issued certificate

   The client's order for a certificate describes the desired
   identifiers plus a few additional fields that capture semantics that
   are not supported in the CSR format.  If the server is willing to
   consider issuing such a certificate, it responds with a list of
   requirements that the client must satisfy before the certificate will
   be issued.

   For example, in most cases, the server will require the client to
   demonstrate that it controls the identifiers in the requested
   certificate.  Because there are many different ways to validate
   possession of different types of identifiers, the server will choose
   from an extensible set of challenges that are appropriate for the
   identifier being claimed.  The client responds with a set of
   responses that tell the server which challenges the client has
   completed.  The server then validates that the client has completed
   the challenges.

   Once the validation process is complete and the server is satisfied
   that the client has met its requirements, the client finalizes the
   order by submitting a PKCS#10 Certificate Signing Request (CSR).  The
   server will issue the requested certificate and make it available to
   the client.




Barnes, et al.               Standards Track                    [Page 8]


                          ACME                        March 2019


         Client                                                   Server

         [Order]
         Signature                     ------->
                                       <-------  Required Authorizations

         [Responses]
         Signature                     ------->

                             <~~~~~~~~Validation~~~~~~~~>

         [CSR]
         Signature                     ------->
                                       <-------          Acknowledgement

                             <~~~~~~Await issuance~~~~~~>

         [POST-as-GET request]
         Signature                     ------->
                                       <-------              Certificate

                   [] Information covered by request signatures

                           Certificate Issuance

   To revoke a certificate, the client sends a signed revocation request
   indicating the certificate to be revoked:

         Client                                                 Server

         [Revocation request]
         Signature                    -------->

                                      <--------                 Result

                   [] Information covered by request signatures

                          Certificate Revocation

   Note that while ACME is defined with enough flexibility to handle
   different types of identifiers in principle, the primary use case
   addressed by this document is the case where domain names are used as
   identifiers.  For example, all of the identifier validation
   challenges described in Section 8 address validation of domain names.
   The use of ACME for other identifiers will require further
   specification in order to describe how these identifiers are encoded
   in the protocol and what types of validation challenges the server
   might require.



Barnes, et al.               Standards Track                    [Page 9]


                          ACME                        March 2019


5.  Character Encoding

   All requests and responses sent via HTTP by ACME clients, ACME
   servers, and validation servers as well as any inputs for digest
   computations MUST be encoded using the UTF-8 character set [].
   Note that identifiers that appear in certificates may have their own
   encoding considerations (e.g., DNS names containing non-ASCII
   characters are expressed as A-labels rather than U-labels).  Any such
   encoding considerations are to be applied prior to the aforementioned
   UTF-8 encoding.

6.  Message Transport

   Communications between an ACME client and an ACME server are done
   over HTTPS, using JSON Web Signature (JWS) [] to provide some
   additional security properties for messages sent from the client to
   the server.  HTTPS provides server authentication and
   confidentiality.  With some ACME-specific extensions, JWS provides
   authentication of the client's request payloads, anti-replay
   protection, and integrity for the HTTPS request URL.

6.1.  HTTPS Requests

   Each ACME function is accomplished by the client sending a sequence
   of HTTPS requests to the server [], carrying JSON messages
   [].  Use of HTTPS is REQUIRED.  Each subsection of Section 7
   below describes the message formats used by the function and the
   order in which messages are sent.

   In most HTTPS transactions used by ACME, the ACME client is the HTTPS
   client and the ACME server is the HTTPS server.  The ACME server acts
   as a client when validating challenges: an HTTP client when
   validating an 'http-01' challenge, a DNS client with 'dns-01', etc.

   ACME servers SHOULD follow the recommendations of [] when
   configuring their TLS implementations.  ACME servers that support TLS
   1.3 MAY allow clients to send early data (0-RTT).  This is safe
   because the ACME protocol itself includes anti-replay protections
   (see Section 6.5) in all cases where they are required.  For this
   reason, there are no restrictions on what ACME data can be carried in
   0-RTT.

   ACME clients MUST send a User-Agent header field, in accordance with
   [].  This header field SHOULD include the name and version of
   the ACME software in addition to the name and version of the
   underlying HTTP client software.





Barnes, et al.               Standards Track                   [Page 10]


                          ACME                        March 2019


   ACME clients SHOULD send an Accept-Language header field in
   accordance with [] to enable localization of error messages.

   ACME servers that are intended to be generally accessible need to use
   Cross-Origin Resource Sharing (CORS) in order to be accessible from
   browser-based clients [W3C.REC-cors-20140116].  Such servers SHOULD
   set the Access-Control-Allow-Origin header field to the value "*".

   Binary fields in the JSON objects used by ACME are encoded using
   base64url encoding described in  according to
   the profile specified in JSON Web Signature in .  This encoding uses a URL safe character set.  Trailing
   '=' characters MUST be stripped.  Encoded values that include
   trailing '=' characters MUST be rejected as improperly encoded.

6.2.  Request Authentication

   All ACME requests with a non-empty body MUST encapsulate their
   payload in a JSON Web Signature (JWS) [] object, signed using
   the account's private key unless otherwise specified.  The server
   MUST verify the JWS before processing the request.  Encapsulating
   request bodies in JWS provides authentication of requests.

   A JWS object sent as the body of an ACME request MUST meet the
   following additional criteria:

   o  The JWS MUST be in the Flattened JSON Serialization []

   o  The JWS MUST NOT have multiple signatures

   o  The JWS Unencoded Payload Option [] MUST NOT be used

   o  The JWS Unprotected Header [] MUST NOT be used

   o  The JWS Payload MUST NOT be detached

   o  The JWS Protected Header MUST include the following fields:

      *  "alg" (Algorithm)

         +  This field MUST NOT contain "none" or a Message
            Authentication Code (MAC) algorithm (e.g. one in which the
            algorithm registry description mentions MAC/HMAC).

      *  "nonce" (defined in Section 6.5)

      *  "url" (defined in Section 6.4)




Barnes, et al.               Standards Track                   [Page 11]


                          ACME                        March 2019


      *  Either "jwk" (JSON Web Key) or "kid" (Key ID) as specified
         below

   An ACME server MUST implement the "ES256" signature algorithm
   [] and SHOULD implement the "EdDSA" signature algorithm using
   the "Ed25519" variant (indicated by "crv") [].

   The "jwk" and "kid" fields are mutually exclusive.  Servers MUST
   reject requests that contain both.

   For newAccount requests, and for revokeCert requests authenticated by
   a certificate key, there MUST be a "jwk" field.  This field MUST
   contain the public key corresponding to the private key used to sign
   the JWS.

   For all other requests, the request is signed using an existing
   account, and there MUST be a "kid" field.  This field MUST contain
   the account URL received by POSTing to the newAccount resource.

   If the client sends a JWS signed with an algorithm that the server
   does not support, then the server MUST return an error with status
   code 400 (Bad Request) and type
   "urn:ietf:params:acme:error:badSignatureAlgorithm".  The problem
   document returned with the error MUST include an "algorithms" field
   with an array of supported "alg" values.  See Section 6.7 for more
   details on the structure of error responses.

   If the server supports the signature algorithm "alg" but either does
   not support or chooses to reject the public key "jwk", then the
   server MUST return an error with status code 400 (Bad Request) and
   type "urn:ietf:params:acme:error:badPublicKey".  The problem document
   detail SHOULD describe the reason for rejecting the public key; some
   example reasons are:

   o  "alg" is "RS256" but the modulus "n" is too small (e.g., 512-bit)

   o  "alg" is "ES256" but "jwk" does not contain a valid P-256 public
      key

   o  "alg" is "EdDSA" and "crv" is "Ed448", but the server only
      supports "EdDSA" with "Ed25519"

   o  the corresponding private key is known to have been compromised








Barnes, et al.               Standards Track                   [Page 12]


                          ACME                        March 2019


   Because client requests in ACME carry JWS objects in the Flattened
   JSON Serialization, they must have the Content-Type header field set
   to "application/jose+json".  If a request does not meet this
   requirement, then the server MUST return a response with status code
   415 (Unsupported Media Type).

6.3.  GET and POST-as-GET Requests

   Note that authentication via signed JWS request bodies implies that
   requests without an entity body are not authenticated, in particular
   GET requests.  Except for the cases described in this section, if the
   server receives a GET request, it MUST return an error with status
   code 405 (Method Not Allowed) and type "malformed".

   If a client wishes to fetch a resource from the server (which would
   otherwise be done with a GET), then it MUST send a POST request with
   a JWS body as described above, where the payload of the JWS is a
   zero-length octet string.  In other words, the "payload" field of the
   JWS object MUST be present and set to the empty string ("").

   We will refer to these as "POST-as-GET" requests.  On receiving a
   request with a zero-length (and thus non-JSON) payload, the server
   MUST authenticate the sender and verify any access control rules.
   Otherwise, the server MUST treat this request as having the same
   semantics as a GET request for the same resource.

   The server MUST allow GET requests for the directory and newNonce
   resources (see Section 7.1), in addition to POST-as-GET requests for
   these resources.  This enables clients to bootstrap into the ACME
   authentication system.

6.4.  Request URL Integrity

   It is common in deployment for the entity terminating TLS for HTTPS
   to be different from the entity operating the logical HTTPS server,
   with a "request routing" layer in the middle.  For example, an ACME
   CA might have a content delivery network terminate TLS connections
   from clients so that it can inspect client requests for denial-of-
   service (DoS) protection.

   These intermediaries can also change values in the request that are
   not signed in the HTTPS request, e.g., the request URL and header
   fields.  ACME uses JWS to provide an integrity mechanism, which
   protects against an intermediary changing the request URL to another
   ACME URL.






Barnes, et al.               Standards Track                   [Page 13]


                          ACME                        March 2019


   As noted in Section 6.2, all ACME request objects carry a "url"
   header parameter in their protected header.  This header parameter
   encodes the URL to which the client is directing the request.  On
   receiving such an object in an HTTP request, the server MUST compare
   the "url" header parameter to the request URL.  If the two do not
   match, then the server MUST reject the request as unauthorized.

   Except for the directory resource, all ACME resources are addressed
   with URLs provided to the client by the server.  In POST requests
   sent to these resources, the client MUST set the "url" header
   parameter to the exact string provided by the server (rather than
   performing any re-encoding on the URL).  The server SHOULD perform
   the corresponding string equality check, configuring each resource
   with the URL string provided to clients and having the resource check
   that requests have the same string in their "url" header parameter.
   The server MUST reject the request as unauthorized if the string
   equality check fails.

6.4.1.  "url" (URL) JWS Header Parameter

   The "url" header parameter specifies the URL [] to which this
   JWS object is directed.  The "url" header parameter MUST be carried
   in the protected header of the JWS.  The value of the "url" header
   parameter MUST be a string representing the target URL.

6.5.  Replay Protection

   In order to protect ACME resources from any possible replay attacks,
   ACME POST requests have a mandatory anti-replay mechanism.  This
   mechanism is based on the server maintaining a list of nonces that it
   has issued, and requiring any signed request from the client to carry
   such a nonce.

   An ACME server provides nonces to clients using the HTTP Replay-Nonce
   header field, as specified in Section 6.5.1.  The server MUST include
   a Replay-Nonce header field in every successful response to a POST
   request and SHOULD provide it in error responses as well.

   Every JWS sent by an ACME client MUST include, in its protected
   header, the "nonce" header parameter, with contents as defined in
   Section 6.5.2.  As part of JWS verification, the ACME server MUST
   verify that the value of the "nonce" header is a value that the
   server previously provided in a Replay-Nonce header field.  Once a
   nonce value has appeared in an ACME request, the server MUST consider
   it invalid, in the same way as a value it had never issued.






Barnes, et al.               Standards Track                   [Page 14]


                          ACME                        March 2019


   When a server rejects a request because its nonce value was
   unacceptable (or not present), it MUST provide HTTP status code 400
   (Bad Request), and indicate the ACME error type
   "urn:ietf:params:acme:error:badNonce".  An error response with the
   "badNonce" error type MUST include a Replay-Nonce header field with a
   fresh nonce that the server will accept in a retry of the original
   query (and possibly in other requests, according to the server's
   nonce scoping policy).  On receiving such a response, a client SHOULD
   retry the request using the new nonce.

   The precise method used to generate and track nonces is up to the
   server.  For example, the server could generate a random 128-bit
   value for each response, keep a list of issued nonces, and strike
   nonces from this list as they are used.

   Other than the constraint above with regard to nonces issued in
   "badNonce" responses, ACME does not constrain how servers scope
   nonces.  Clients MAY assume that nonces have broad scope, e.g., by
   having a single pool of nonces used for all requests.  However, when
   retrying in response to a "badNonce" error, the client MUST use the
   nonce provided in the error response.  Servers should scope nonces
   broadly enough that retries are not needed very often.

6.5.1.  Replay-Nonce

   The Replay-Nonce HTTP header field includes a server-generated value
   that the server can use to detect unauthorized replay in future
   client requests.  The server MUST generate the values provided in
   Replay-Nonce header fields in such a way that they are unique to each
   message, with high probability, and unpredictable to anyone besides
   the server.  For instance, it is acceptable to generate Replay-Nonces
   randomly.

   The value of the Replay-Nonce header field MUST be an octet string
   encoded according to the base64url encoding described in .  Clients MUST ignore invalid Replay-Nonce values.  The
   ABNF [] for the Replay-Nonce header field follows:

     base64url = ALPHA / DIGIT / "-" / "_"

     Replay-Nonce = 1*base64url

   The Replay-Nonce header field SHOULD NOT be included in HTTP request
   messages.







Barnes, et al.               Standards Track                   [Page 15]


                          ACME                        March 2019


6.5.2.  "nonce" (Nonce) JWS Header Parameter

   The "nonce" header parameter provides a unique value that enables the
   verifier of a JWS to recognize when replay has occurred.  The "nonce"
   header parameter MUST be carried in the protected header of the JWS.

   The value of the "nonce" header parameter MUST be an octet string,
   encoded according to the base64url encoding described in .  If the value of a "nonce" header parameter is not valid
   according to this encoding, then the verifier MUST reject the JWS as
   malformed.

6.6.  Rate Limits

   Creation of resources can be rate limited by ACME servers to ensure
   fair usage and prevent abuse.  Once the rate limit is exceeded, the
   server MUST respond with an error with the type
   "urn:ietf:params:acme:error:rateLimited".  Additionally, the server
   SHOULD send a Retry-After header field [] indicating when the
   current request may succeed again.  If multiple rate limits are in
   place, that is the time where all rate limits allow access again for
   the current request with exactly the same parameters.

   In addition to the human-readable "detail" field of the error
   response, the server MAY send one or multiple link relations in the
   Link header field [] pointing to documentation about the
   specific rate limit that was hit, using the "help" link relation
   type.

6.7.  Errors

   Errors can be reported in ACME both at the HTTP layer and within
   challenge objects as defined in Section 8.  ACME servers can return
   responses with an HTTP error response code (4XX or 5XX).  For
   example, if the client submits a request using a method not allowed
   in this document, then the server MAY return status code 405 (Method
   Not Allowed).

   When the server responds with an error status, it SHOULD provide
   additional information using a problem document [].  To
   facilitate automatic response to errors, this document defines the
   following standard tokens for use in the "type" field (within the
   ACME URN namespace "urn:ietf:params:acme:error:"):








Barnes, et al.               Standards Track                   [Page 16]


                          ACME                        March 2019


   +-------------------------+-----------------------------------------+
   | Type                    | Description                             |
   +-------------------------+-----------------------------------------+
   | accountDoesNotExist     | The request specified an account that   |
   |                         | does not exist                          |
   |                         |                                         |
   | alreadyRevoked          | The request specified a certificate to  |
   |                         | be revoked that has already been        |
   |                         | revoked                                 |
   |                         |                                         |
   | badCSR                  | The CSR is unacceptable (e.g., due to a |
   |                         | short key)                              |
   |                         |                                         |
   | badNonce                | The client sent an unacceptable anti-   |
   |                         | replay nonce                            |
   |                         |                                         |
   | badPublicKey            | The JWS was signed by a public key the  |
   |                         | server does not support                 |
   |                         |                                         |
   | badRevocationReason     | The revocation reason provided is not   |
   |                         | allowed by the server                   |
   |                         |                                         |
   | badSignatureAlgorithm   | The JWS was signed with an algorithm    |
   |                         | the server does not support             |
   |                         |                                         |
   | caa                     | Certification Authority Authorization   |
   |                         | (CAA) records forbid the CA from        |
   |                         | issuing a certificate                   |
   |                         |                                         |
   | compound                | Specific error conditions are indicated |
   |                         | in the "subproblems" array              |
   |                         |                                         |
   | connection              | The server could not connect to         |
   |                         | validation target                       |
   |                         |                                         |
   | dns                     | There was a problem with a DNS query    |
   |                         | during identifier validation            |
   |                         |                                         |
   | externalAccountRequired | The request must include a value for    |
   |                         | the "externalAccountBinding" field      |
   |                         |                                         |
   | incorrectResponse       | Response received didn't match the      |
   |                         | challenge's requirements                |
   |                         |                                         |
   | invalidContact          | A contact URL for an account was        |
   |                         | invalid                                 |
   |                         |                                         |
   | malformed               | The request message was malformed       |



Barnes, et al.               Standards Track                   [Page 17]


                          ACME                        March 2019


   |                         |                                         |
   | orderNotReady           | The request attempted to finalize an    |
   |                         | order that is not ready to be finalized |
   |                         |                                         |
   | rateLimited             | The request exceeds a rate limit        |
   |                         |                                         |
   | rejectedIdentifier      | The server will not issue certificates  |
   |                         | for the identifier                      |
   |                         |                                         |
   | serverInternal          | The server experienced an internal      |
   |                         | error                                   |
   |                         |                                         |
   | tls                     | The server received a TLS error during  |
   |                         | validation                              |
   |                         |                                         |
   | unauthorized            | The client lacks sufficient             |
   |                         | authorization                           |
   |                         |                                         |
   | unsupportedContact      | A contact URL for an account used an    |
   |                         | unsupported protocol scheme             |
   |                         |                                         |
   | unsupportedIdentifier   | An identifier is of an unsupported type |
   |                         |                                         |
   | userActionRequired      | Visit the "instance" URL and take       |
   |                         | actions specified there                 |
   +-------------------------+-----------------------------------------+

   This list is not exhaustive.  The server MAY return errors whose
   "type" field is set to a URI other than those defined above.  Servers
   MUST NOT use the ACME URN namespace for errors not listed in the
   appropriate IANA registry (see Section 9.6).  Clients SHOULD display
   the "detail" field of all errors.

   In the remainder of this document, we use the tokens in the table
   above to refer to error types, rather than the full URNs.  For
   example, an "error of type 'badCSR'" refers to an error document with
   "type" value "urn:ietf:params:acme:error:badCSR".

6.7.1.  Subproblems

   Sometimes a CA may need to return multiple errors in response to a
   request.  Additionally, the CA may need to attribute errors to
   specific identifiers.  For instance, a newOrder request may contain
   multiple identifiers for which the CA cannot issue certificates.  In
   this situation, an ACME problem document MAY contain the
   "subproblems" field, containing a JSON array of problem documents,
   each of which MAY contain an "identifier" field.  If present, the
   "identifier" field MUST contain an ACME identifier (Section 9.7.7).



Barnes, et al.               Standards Track                   [Page 18]


                          ACME                        March 2019


   The "identifier" field MUST NOT be present at the top level in ACME
   problem documents.  It can only be present in subproblems.
   Subproblems need not all have the same type, and they do not need to
   match the top level type.

   ACME clients may choose to use the "identifier" field of a subproblem
   as a hint that an operation would succeed if that identifier were
   omitted.  For instance, if an order contains ten DNS identifiers, and
   the newOrder request returns a problem document with two subproblems
   (referencing two of those identifiers), the ACME client may choose to
   submit another order containing only the eight identifiers not listed
   in the problem document.

HTTP/1.1 403 Forbidden
Content-Type: application/problem+json
Link: <https://example.com/acme/directory>;rel="index"

{
    "type": "urn:ietf:params:acme:error:malformed",
    "detail": "Some of the identifiers requested were rejected",
    "subproblems": [
        {
            "type": "urn:ietf:params:acme:error:malformed",
            "detail": "Invalid underscore in DNS name \"_example.org\"",
            "identifier": {
                "type": "dns",
                "value": "_example.org"
            }
        },
        {
            "type": "urn:ietf:params:acme:error:rejectedIdentifier",
            "detail": "This CA will not issue for \"example.net\"",
            "identifier": {
                "type": "dns",
                "value": "example.net"
            }
        }
    ]
}












Barnes, et al.               Standards Track                   [Page 19]


                          ACME                        March 2019


7.  Certificate Management

   In this section, we describe the certificate management functions
   that ACME enables:

   o  Account Creation

   o  Ordering a Certificate

   o  Identifier Authorization

   o  Certificate Issuance

   o  Certificate Revocation

7.1.  Resources

   ACME is structured as an HTTP-based application with the following
   types of resources:

   o  Account resources, representing information about an account
      (Section 7.1.2, Section 7.3)

   o  Order resources, representing an account's requests to issue
      certificates (Section 7.1.3)

   o  Authorization resources, representing an account's authorization
      to act for an identifier (Section 7.1.4)

   o  Challenge resources, representing a challenge to prove control of
      an identifier (Section 7.5, Section 8)

   o  Certificate resources, representing issued certificates
      (Section 7.4.2)

   o  A "directory" resource (Section 7.1.1)

   o  A "newNonce" resource (Section 7.2)

   o  A "newAccount" resource (Section 7.3)

   o  A "newOrder" resource (Section 7.4)

   o  A "revokeCert" resource (Section 7.6)

   o  A "keyChange" resource (Section 7.3.5)

   The server MUST provide "directory" and "newNonce" resources.



Barnes, et al.               Standards Track                   [Page 20]


                          ACME                        March 2019


   ACME uses different URLs for different management functions.  Each
   function is listed in a directory along with its corresponding URL,
   so clients only need to be configured with the directory URL.  These
   URLs are connected by a few different link relations [].

   The "up" link relation is used with challenge resources to indicate
   the authorization resource to which a challenge belongs.  It is also
   used, with some media types, from certificate resources to indicate a
   resource from which the client may fetch a chain of CA certificates
   that could be used to validate the certificate in the original
   resource.

   The "index" link relation is present on all resources other than the
   directory and indicates the URL of the directory.

   The following diagram illustrates the relations between resources on
   an ACME server.  For the most part, these relations are expressed by
   URLs provided as strings in the resources' JSON representations.
   Lines with labels in quotes indicate HTTP link relations.

                                  directory
                                      |
                                      +--> newNonce
                                      |
          +----------+----------+-----+-----+------------+
          |          |          |           |            |
          |          |          |           |            |
          V          V          V           V            V
     newAccount   newAuthz   newOrder   revokeCert   keyChange
          |          |          |
          |          |          |
          V          |          V
       account       |        order --+--> finalize
                     |          |     |
                     |          |     +--> cert
                     |          V
                     +---> authorization
                               | ^
                               | | "up"
                               V |
                             challenge

                     ACME Resources and Relationships








Barnes, et al.               Standards Track                   [Page 21]


                          ACME                        March 2019


   The following table illustrates a typical sequence of requests
   required to establish a new account with the server, prove control of
   an identifier, issue a certificate, and fetch an updated certificate
   some time after issuance.  The "->" is a mnemonic for a Location
   header field pointing to a created resource.

   +-------------------+--------------------------------+--------------+
   | Action            | Request                        | Response     |
   +-------------------+--------------------------------+--------------+
   | Get directory     | GET  directory                 | 200          |
   |                   |                                |              |
   | Get nonce         | HEAD newNonce                  | 200          |
   |                   |                                |              |
   | Create account    | POST newAccount                | 201 ->       |
   |                   |                                | account      |
   |                   |                                |              |
   | Submit order      | POST newOrder                  | 201 -> order |
   |                   |                                |              |
   | Fetch challenges  | POST-as-GET order's            | 200          |
   |                   | authorization urls             |              |
   |                   |                                |              |
   | Respond to        | POST authorization challenge   | 200          |
   | challenges        | urls                           |              |
   |                   |                                |              |
   | Poll for status   | POST-as-GET order              | 200          |
   |                   |                                |              |
   | Finalize order    | POST order's finalize url      | 200          |
   |                   |                                |              |
   | Poll for status   | POST-as-GET order              | 200          |
   |                   |                                |              |
   | Download          | POST-as-GET order's            | 200          |
   | certificate       | certificate url                |              |
   +-------------------+--------------------------------+--------------+

   The remainder of this section provides the details of how these
   resources are structured and how the ACME protocol makes use of them.















Barnes, et al.               Standards Track                   [Page 22]


                          ACME                        March 2019


7.1.1.  Directory

   In order to help clients configure themselves with the right URLs for
   each ACME operation, ACME servers provide a directory object.  This
   should be the only URL needed to configure clients.  It is a JSON
   object, whose field names are drawn from the resource registry
   (Section 9.7.5) and whose values are the corresponding URLs.

                    +------------+--------------------+
                    | Field      | URL in Value       |
                    +------------+--------------------+
                    | newNonce   | New nonce          |
                    |            |                    |
                    | newAccount | New account        |
                    |            |                    |
                    | newOrder   | New order          |
                    |            |                    |
                    | newAuthz   | New authorization  |
                    |            |                    |
                    | revokeCert | Revoke certificate |
                    |            |                    |
                    | keyChange  | Key change         |
                    +------------+--------------------+

   There is no constraint on the URL of the directory except that it
   should be different from the other ACME server resources' URLs, and
   that it should not clash with other services.  For instance:

   o  a host that functions as both an ACME and a Web server may want to
      keep the root path "/" for an HTML "front page" and place the ACME
      directory under the path "/acme".

   o  a host that only functions as an ACME server could place the
      directory under the path "/".

   If the ACME server does not implement pre-authorization
   (Section 7.4.1), it MUST omit the "newAuthz" field of the directory.

   The object MAY additionally contain a "meta" field.  If present, it
   MUST be a JSON object; each field in the object is an item of
   metadata relating to the service provided by the ACME server.

   The following metadata items are defined (Section 9.7.6), all of
   which are OPTIONAL:

   termsOfService (optional, string):  A URL identifying the current
      terms of service.




Barnes, et al.               Standards Track                   [Page 23]


                          ACME                        March 2019


   website (optional, string):  An HTTP or HTTPS URL locating a website
      providing more information about the ACME server.

   caaIdentities (optional, array of string):  The hostnames that the
      ACME server recognizes as referring to itself for the purposes of
      CAA record validation as defined in [].  Each string MUST
      represent the same sequence of ASCII code points that the server
      will expect to see as the "Issuer Domain Name" in a CAA issue or
      issuewild property tag.  This allows clients to determine the
      correct issuer domain name to use when configuring CAA records.

   externalAccountRequired (optional, boolean):  If this field is
      present and set to "true", then the CA requires that all
      newAccount requests include an "externalAccountBinding" field
      associating the new account with an external account.

   Clients access the directory by sending a GET request to the
   directory URL.

   HTTP/1.1 200 OK
   Content-Type: application/json

   {
     "newNonce": "https://example.com/acme/new-nonce",
     "newAccount": "https://example.com/acme/new-account",
     "newOrder": "https://example.com/acme/new-order",
     "newAuthz": "https://example.com/acme/new-authz",
     "revokeCert": "https://example.com/acme/revoke-cert",
     "keyChange": "https://example.com/acme/key-change",
     "meta": {
       "termsOfService": "https://example.com/acme/terms/2017-5-30",
       "website": "https://www.example.com/",
       "caaIdentities": ["example.com"],
       "externalAccountRequired": false
     }
   }

7.1.2.  Account Objects

   An ACME account resource represents a set of metadata associated with
   an account.  Account resources have the following structure:

   status (required, string):  The status of this account.  Possible
      values are "valid", "deactivated", and "revoked".  The value
      "deactivated" should be used to indicate client-initiated
      deactivation whereas "revoked" should be used to indicate server-
      initiated deactivation.  See Section 7.1.6.




Barnes, et al.               Standards Track                   [Page 24]


                          ACME                        March 2019


   contact (optional, array of string):  An array of URLs that the
      server can use to contact the client for issues related to this
      account.  For example, the server may wish to notify the client
      about server-initiated revocation or certificate expiration.  For
      information on supported URL schemes, see Section 7.3.

   termsOfServiceAgreed (optional, boolean):  Including this field in a
      newAccount request, with a value of true, indicates the client's
      agreement with the terms of service.  This field cannot be updated
      by the client.

   externalAccountBinding (optional, object):  Including this field in a
      newAccount request indicates approval by the holder of an existing
      non-ACME account to bind that account to this ACME account.  This
      field is not updateable by the client (see Section 7.3.4).

   orders (required, string):  A URL from which a list of orders
      submitted by this account can be fetched via a POST-as-GET
      request, as described in Section 7.1.2.1.

   {
     "status": "valid",
     "contact": [
       "mailto:cert-admin@example.org",
       "mailto:admin@example.org"
     ],
     "termsOfServiceAgreed": true,
     "orders": "https://example.com/acme/orders/rzGoeA"
   }

7.1.2.1.  Orders List

   Each account object includes an "orders" URL from which a list of
   orders created by the account can be fetched via POST-as-GET request.
   The result of the request MUST be a JSON object whose "orders" field
   is an array of URLs, each identifying an order belonging to the
   account.  The server SHOULD include pending orders and SHOULD NOT
   include orders that are invalid in the array of URLs.  The server MAY
   return an incomplete list, along with a Link header field with a
   "next" link relation indicating where further entries can be
   acquired.










Barnes, et al.               Standards Track                   [Page 25]


                          ACME                        March 2019


   HTTP/1.1 200 OK
   Content-Type: application/json
   Link: <https://example.com/acme/directory>;rel="index"
   Link: <https://example.com/acme/orders/rzGoeA?cursor=2>;rel="next"

   {
     "orders": [
       "https://example.com/acme/order/TOlocE8rfgo",
       "https://example.com/acme/order/4E16bbL5iSw",
       /* more URLs not shown for example brevity */
       "https://example.com/acme/order/neBHYLfw0mg"
     ]
   }

7.1.3.  Order Objects

   An ACME order object represents a client's request for a certificate
   and is used to track the progress of that order through to issuance.
   Thus, the object contains information about the requested
   certificate, the authorizations that the server requires the client
   to complete, and any certificates that have resulted from this order.

   status (required, string):  The status of this order.  Possible
      values are "pending", "ready", "processing", "valid", and
      "invalid".  See Section 7.1.6.

   expires (optional, string):  The timestamp after which the server
      will consider this order invalid, encoded in the format specified
      in [].  This field is REQUIRED for objects with "pending"
      or "valid" in the status field.

   identifiers (required, array of object):  An array of identifier
      objects that the order pertains to.

      type (required, string):  The type of identifier.  This document
         defines the "dns" identifier type.  See the registry defined in
         Section 9.7.7 for any others.

      value (required, string):  The identifier itself.

   notBefore (optional, string):  The requested value of the notBefore
      field in the certificate, in the date format defined in [].

   notAfter (optional, string):  The requested value of the notAfter
      field in the certificate, in the date format defined in [].






Barnes, et al.               Standards Track                   [Page 26]


                          ACME                        March 2019


   error (optional, object):  The error that occurred while processing
      the order, if any.  This field is structured as a problem document
      [].

   authorizations (required, array of string):  For pending orders, the
      authorizations that the client needs to complete before the
      requested certificate can be issued (see Section 7.5), including
      unexpired authorizations that the client has completed in the past
      for identifiers specified in the order.  The authorizations
      required are dictated by server policy; there may not be a 1:1
      relationship between the order identifiers and the authorizations
      required.  For final orders (in the "valid" or "invalid" state),
      the authorizations that were completed.  Each entry is a URL from
      which an authorization can be fetched with a POST-as-GET request.

   finalize (required, string):  A URL that a CSR must be POSTed to once
      all of the order's authorizations are satisfied to finalize the
      order.  The result of a successful finalization will be the
      population of the certificate URL for the order.

   certificate (optional, string):  A URL for the certificate that has
      been issued in response to this order.

   {
     "status": "valid",
     "expires": "2016-01-20T14:09:07.99Z",

     "identifiers": [
       { "type": "dns", "value": "www.example.org" },
       { "type": "dns", "value": "example.org" }
     ],

     "notBefore": "2016-01-01T00:00:00Z",
     "notAfter": "2016-01-08T00:00:00Z",

     "authorizations": [
       "https://example.com/acme/authz/PAniVnsZcis",
       "https://example.com/acme/authz/r4HqLzrSrpI"
     ],

     "finalize": "https://example.com/acme/order/TOlocE8rfgo/finalize",

     "certificate": "https://example.com/acme/cert/mAt3xBGaobw"
   }

   Any identifier of type "dns" in a newOrder request MAY have a
   wildcard domain name as its value.  A wildcard domain name consists
   of a single asterisk character followed by a single full stop



Barnes, et al.               Standards Track                   [Page 27]


                          ACME                        March 2019


   character ("*.") followed by a domain name as defined for use in the
   Subject Alternate Name Extension by [].  An authorization
   returned by the server for a wildcard domain name identifier MUST NOT
   include the asterisk and full stop ("*.") prefix in the authorization
   identifier value.  The returned authorization MUST include the
   optional "wildcard" field, with a value of true.

   The elements of the "authorizations" and "identifiers" arrays are
   immutable once set.  The server MUST NOT change the contents of
   either array after they are created.  If a client observes a change
   in the contents of either array, then it SHOULD consider the order
   invalid.

   The "authorizations" array of the order SHOULD reflect all
   authorizations that the CA takes into account in deciding to issue,
   even if some authorizations were fulfilled in earlier orders or in
   pre-authorization transactions.  For example, if a CA allows multiple
   orders to be fulfilled based on a single authorization transaction,
   then it SHOULD reflect that authorization in all of the orders.

   Note that just because an authorization URL is listed in the
   "authorizations" array of an order object doesn't mean that the
   client is required to take action.  There are several reasons that
   the referenced authorizations may already be valid:

   o  The client completed the authorization as part of a previous order

   o  The client previously pre-authorized the identifier (see
      Section 7.4.1)

   o  The server granted the client authorization based on an external
      account

   Clients SHOULD check the "status" field of an order to determine
   whether they need to take any action.

7.1.4.  Authorization Objects

   An ACME authorization object represents a server's authorization for
   an account to represent an identifier.  In addition to the
   identifier, an authorization includes several metadata fields, such
   as the status of the authorization (e.g., "pending", "valid", or
   "revoked") and which challenges were used to validate possession of
   the identifier.







Barnes, et al.               Standards Track                   [Page 28]


                          ACME                        March 2019


   The structure of an ACME authorization resource is as follows:

   identifier (required, object):  The identifier that the account is
      authorized to represent.

      type (required, string):  The type of identifier (see below and
         Section 9.7.7).

      value (required, string):  The identifier itself.

   status (required, string):  The status of this authorization.
      Possible values are "pending", "valid", "invalid", "deactivated",
      "expired", and "revoked".  See Section 7.1.6.

   expires (optional, string):  The timestamp after which the server
      will consider this authorization invalid, encoded in the format
      specified in [].  This field is REQUIRED for objects with
      "valid" in the "status" field.

   challenges (required, array of objects):  For pending authorizations,
      the challenges that the client can fulfill in order to prove
      possession of the identifier.  For valid authorizations, the
      challenge that was validated.  For invalid authorizations, the
      challenge that was attempted and failed.  Each array entry is an
      object with parameters required to validate the challenge.  A
      client should attempt to fulfill one of these challenges, and a
      server should consider any one of the challenges sufficient to
      make the authorization valid.

   wildcard (optional, boolean):  This field MUST be present and true
      for authorizations created as a result of a newOrder request
      containing a DNS identifier with a value that was a wildcard
      domain name.  For other authorizations, it MUST be absent.
      Wildcard domain names are described in Section 7.1.3.

   The only type of identifier defined by this specification is a fully
   qualified domain name (type: "dns").  The domain name MUST be encoded
   in the form in which it would appear in a certificate.  That is, it
   MUST be encoded according to the rules in .
   Servers MUST verify any identifier values that begin with the ASCII-
   Compatible Encoding prefix "xn--" as defined in [] are
   properly encoded.  Wildcard domain names (with "*" as the first
   label) MUST NOT be included in authorization objects.  If an
   authorization object conveys authorization for the base domain of a
   newOrder DNS identifier containing a wildcard domain name, then the
   optional authorizations "wildcard" field MUST be present with a value
   of true.




Barnes, et al.               Standards Track                   [Page 29]


                          ACME                        March 2019


   Section 8 describes a set of challenges for domain name validation.

   {
     "status": "valid",
     "expires": "2015-03-01T14:09:07.99Z",

     "identifier": {
       "type": "dns",
       "value": "www.example.org"
     },

     "challenges": [
       {
         "url": "https://example.com/acme/chall/prV_B7yEyA4",
         "type": "http-01",
         "status": "valid",
         "token": "DGyRejmCefe7v4NfDGDKfA",
         "validated": "2014-12-01T12:05:58.16Z"
       }
     ],

     "wildcard": false
   }

7.1.5.  Challenge Objects

   An ACME challenge object represents a server's offer to validate a
   client's possession of an identifier in a specific way.  Unlike the
   other objects listed above, there is not a single standard structure
   for a challenge object.  The contents of a challenge object depend on
   the validation method being used.  The general structure of challenge
   objects and an initial set of validation methods are described in
   Section 8.

7.1.6.  Status Changes

   Each ACME object type goes through a simple state machine over its
   lifetime.  The "status" field of the object indicates which state the
   object is currently in.

   Challenge objects are created in the "pending" state.  They
   transition to the "processing" state when the client responds to the
   challenge (see Section 7.5.1) and the server begins attempting to
   validate that the client has completed the challenge.  Note that
   within the "processing" state, the server may attempt to validate the
   challenge multiple times (see Section 8.2).  Likewise, client





Barnes, et al.               Standards Track                   [Page 30]


                          ACME                        March 2019


   requests for retries do not cause a state change.  If validation is
   successful, the challenge moves to the "valid" state; if there is an
   error, the challenge moves to the "invalid" state.

            pending
               |
               | Receive
               | response
               V
           processing <-+
               |   |    | Server retry or
               |   |    | client retry request
               |   +----+
               |
               |
   Successful  |   Failed
   validation  |   validation
     +---------+---------+
     |                   |
     V                   V
   valid              invalid

                  State Transitions for Challenge Objects

   Authorization objects are created in the "pending" state.  If one of
   the challenges listed in the authorization transitions to the "valid"
   state, then the authorization also changes to the "valid" state.  If
   the client attempts to fulfill a challenge and fails, or if there is
   an error while the authorization is still pending, then the
   authorization transitions to the "invalid" state.  Once the
   authorization is in the "valid" state, it can expire ("expired"), be
   deactivated by the client ("deactivated", see Section 7.5.2), or
   revoked by the server ("revoked").


















Barnes, et al.               Standards Track                   [Page 31]


                          ACME                        March 2019


                      pending --------------------+
                         |                        |
       Challenge failure |                        |
              or         |                        |
             Error       |  Challenge valid       |
               +---------+---------+              |
               |                   |              |
               V                   V              |
            invalid              valid            |
                                   |              |
                                   |              |
                                   |              |
                    +--------------+--------------+
                    |              |              |
                    |              |              |
             Server |       Client |   Time after |
             revoke |   deactivate |    "expires" |
                    V              V              V
                 revoked      deactivated      expired

                State Transitions for Authorization Objects

   Order objects are created in the "pending" state.  Once all of the
   authorizations listed in the order object are in the "valid" state,
   the order transitions to the "ready" state.  The order moves to the
   "processing" state after the client submits a request to the order's
   "finalize" URL and the CA begins the issuance process for the
   certificate.  Once the certificate is issued, the order enters the
   "valid" state.  If an error occurs at any of these stages, the order
   moves to the "invalid" state.  The order also moves to the "invalid"
   state if it expires or one of its authorizations enters a final state
   other than "valid" ("expired", "revoked", or "deactivated").



















Barnes, et al.               Standards Track                   [Page 32]


                          ACME                        March 2019


    pending --------------+
       |                  |
       | All authz        |
       | "valid"          |
       V                  |
     ready ---------------+
       |                  |
       | Receive          |
       | finalize         |
       | request          |
       V                  |
   processing ------------+
       |                  |
       | Certificate      | Error or
       | issued           | Authorization failure
       V                  V
     valid             invalid

                    State Transitions for Order Objects

   Account objects are created in the "valid" state, since no further
   action is required to create an account after a successful newAccount
   request.  If the account is deactivated by the client or revoked by
   the server, it moves to the corresponding state.

                     valid
                       |
                       |
           +-----------+-----------+
    Client |                Server |
   deactiv.|                revoke |
           V                       V
      deactivated               revoked

                   State Transitions for Account Objects

   Note that some of these states may not ever appear in a "status"
   field, depending on server behavior.  For example, a server that
   issues synchronously will never show an order in the "processing"
   state.  A server that deletes expired authorizations immediately will
   never show an authorization in the "expired" state.










Barnes, et al.               Standards Track                   [Page 33]


                          ACME                        March 2019


7.2.  Getting a Nonce

   Before sending a POST request to the server, an ACME client needs to
   have a fresh anti-replay nonce to put in the "nonce" header of the
   JWS.  In most cases, the client will have gotten a nonce from a
   previous request.  However, the client might sometimes need to get a
   new nonce, e.g., on its first request to the server or if an existing
   nonce is no longer valid.

   To get a fresh nonce, the client sends a HEAD request to the newNonce
   resource on the server.  The server's response MUST include a Replay-
   Nonce header field containing a fresh nonce and SHOULD have status
   code 200 (OK).  The server MUST also respond to GET requests for this
   resource, returning an empty body (while still providing a Replay-
   Nonce header) with a status code of 204 (No Content).

   HEAD /acme/new-nonce HTTP/1.1
   Host: example.com

   HTTP/1.1 200 OK
   Replay-Nonce: oFvnlFP1wIhRlYS2jTaXbA
   Cache-Control: no-store
   Link: <https://example.com/acme/directory>;rel="index"

   Proxy caching of responses from the newNonce resource can cause
   clients to receive the same nonce repeatedly, leading to "badNonce"
   errors.  The server MUST include a Cache-Control header field with
   the "no-store" directive in responses for the newNonce resource, in
   order to prevent caching of this resource.

7.3.  Account Management

   In this section, we describe how an ACME client can create an account
   on an ACME server and perform some modifications to the account after
   it has been created.

   A client creates a new account with the server by sending a POST
   request to the server's newAccount URL.  The body of the request is a
   stub account object containing some subset of the following fields:

   contact (optional, array of string):  Same meaning as the
      corresponding server field defined in Section 7.1.2.

   termsOfServiceAgreed (optional, boolean):  Same meaning as the
      corresponding server field defined in Section 7.1.2.






Barnes, et al.               Standards Track                   [Page 34]


                          ACME                        March 2019


   onlyReturnExisting (optional, boolean):  If this field is present
      with the value "true", then the server MUST NOT create a new
      account if one does not already exist.  This allows a client to
      look up an account URL based on an account key (see
      Section 7.3.1).

   externalAccountBinding (optional, object):  Same meaning as the
      corresponding server field defined in Section 7.1.2

   POST /acme/new-account HTTP/1.1
   Host: example.com
   Content-Type: application/jose+json

   {
     "protected": base64url({
       "alg": "ES256",
       "jwk": {...},
       "nonce": "6S8IqOGY7eL2lsGoTZYifg",
       "url": "https://example.com/acme/new-account"
     }),
     "payload": base64url({
       "termsOfServiceAgreed": true,
       "contact": [
         "mailto:cert-admin@example.org",
         "mailto:admin@example.org"
       ]
     }),
     "signature": "RZPOnYoPs1PhjszF...-nh6X1qtOFPB519I"
   }

   The server MUST ignore any values provided in the "orders" fields in
   account objects sent by the client, as well as any other fields that
   it does not recognize.  If new fields are specified in the future,
   the specification of those fields MUST describe whether they can be
   provided by the client.  The server MUST NOT reflect the
   "onlyReturnExisting" field or any unrecognized fields in the
   resulting account object.  This allows clients to detect when servers
   do not support an extension field.

   The server SHOULD validate that the contact URLs in the "contact"
   field are valid and supported by the server.  If the server validates
   contact URLs, it MUST support the "mailto" scheme.  Clients MUST NOT
   provide a "mailto" URL in the "contact" field that contains "hfields"
   [] or more than one "addr-spec" in the "to" component.  If a
   server encounters a "mailto" contact URL that does not meet these
   criteria, then it SHOULD reject it as invalid.





Barnes, et al.               Standards Track                   [Page 35]


                          ACME                        March 2019


   If the server rejects a contact URL for using an unsupported scheme,
   it MUST return an error of type "unsupportedContact", with a
   description of the error and what types of contact URLs the server
   considers acceptable.  If the server rejects a contact URL for using
   a supported scheme but an invalid value, then the server MUST return
   an error of type "invalidContact".

   If the server wishes to require the client to agree to terms under
   which the ACME service is to be used, it MUST indicate the URL where
   such terms can be accessed in the "termsOfService" subfield of the
   "meta" field in the directory object, and the server MUST reject
   newAccount requests that do not have the "termsOfServiceAgreed" field
   set to "true".  Clients SHOULD NOT automatically agree to terms by
   default.  Rather, they SHOULD require some user interaction for
   agreement to terms.

   The server creates an account and stores the public key used to
   verify the JWS (i.e., the "jwk" element of the JWS header) to
   authenticate future requests from the account.  The server returns
   this account object in a 201 (Created) response, with the account URL
   in a Location header field.  The account URL is used as the "kid"
   value in the JWS authenticating subsequent requests by this account
   (see Section 6.2).  The account URL is also used for requests for
   management actions on this account, as described below.

   HTTP/1.1 201 Created
   Content-Type: application/json
   Replay-Nonce: D8s4D2mLs8Vn-goWuPQeKA
   Link: <https://example.com/acme/directory>;rel="index"
   Location: https://example.com/acme/acct/evOfKhNU60wg

   {
     "status": "valid",

     "contact": [
       "mailto:cert-admin@example.org",
       "mailto:admin@example.org"
     ],

     "orders": "https://example.com/acme/acct/evOfKhNU60wg/orders"
   }

7.3.1.  Finding an Account URL Given a Key

   If the server receives a newAccount request signed with a key for
   which it already has an account registered with the provided account
   key, then it MUST return a response with status code 200 (OK) and
   provide the URL of that account in the Location header field.  The



Barnes, et al.               Standards Track                   [Page 36]


                          ACME                        March 2019


   body of this response represents the account object as it existed on
   the server before this request; any fields in the request object MUST
   be ignored.  This allows a client that has an account key but not the
   corresponding account URL to recover the account URL.

   If a client wishes to find the URL for an existing account and does
   not want an account to be created if one does not already exist, then
   it SHOULD do so by sending a POST request to the newAccount URL with
   a JWS whose payload has an "onlyReturnExisting" field set to "true"
   ({"onlyReturnExisting": true}).  If a client sends such a request and
   an account does not exist, then the server MUST return an error
   response with status code 400 (Bad Request) and type
   "urn:ietf:params:acme:error:accountDoesNotExist".

7.3.2.  Account Update

   If the client wishes to update this information in the future, it
   sends a POST request with updated information to the account URL.
   The server MUST ignore any updates to the "orders" field,
   "termsOfServiceAgreed" field (see Section 7.3.3), the "status" field
   (except as allowed by Section 7.3.6), or any other fields it does not
   recognize.  If the server accepts the update, it MUST return a
   response with a 200 (OK) status code and the resulting account
   object.

   For example, to update the contact information in the above account,
   the client could send the following request:

   POST /acme/acct/evOfKhNU60wg HTTP/1.1
   Host: example.com
   Content-Type: application/jose+json

   {
     "protected": base64url({
       "alg": "ES256",
       "kid": "https://example.com/acme/acct/evOfKhNU60wg",
       "nonce": "ax5RnthDqp_Yf4_HZnFLmA",
       "url": "https://example.com/acme/acct/evOfKhNU60wg"
     }),
     "payload": base64url({
       "contact": [
         "mailto:certificates@example.org",
         "mailto:admin@example.org"
       ]
     }),
     "signature": "hDXzvcj8T6fbFbmn...rDzXzzvzpRy64N0o"
   }




Barnes, et al.               Standards Track                   [Page 37]


                          ACME                        March 2019


7.3.3.  Changes of Terms of Service

   As described above, a client can indicate its agreement with the CA's
   terms of service by setting the "termsOfServiceAgreed" field in its
   account object to "true".

   If the server has changed its terms of service since a client
   initially agreed, and the server is unwilling to process a request
   without explicit agreement to the new terms, then it MUST return an
   error response with status code 403 (Forbidden) and type
   "urn:ietf:params:acme:error:userActionRequired".  This response MUST
   include a Link header field with link relation "terms-of-service" and
   the latest terms-of-service URL.

   The problem document returned with the error MUST also include an
   "instance" field, indicating a URL that the client should direct a
   human user to visit in order for instructions on how to agree to the
   terms.

 HTTP/1.1 403 Forbidden
 Replay-Nonce: T81bdZroZ2ITWSondpTmAw
 Link: <https://example.com/acme/directory>;rel="index"
 Link: <https://example.com/acme/terms/2017-6-02>;rel="terms-of-service"
 Content-Type: application/problem+json
 Content-Language: en

 {
   "type": "urn:ietf:params:acme:error:userActionRequired",
   "detail": "Terms of service have changed",
   "instance": "https://example.com/acme/agreement/?token=W8Ih3PswD-8"
 }

7.3.4.  External Account Binding

   The server MAY require a value for the "externalAccountBinding" field
   to be present in "newAccount" requests.  This can be used to
   associate an ACME account with an existing account in a non-ACME
   system, such as a CA customer database.

   To enable ACME account binding, the CA operating the ACME server
   needs to provide the ACME client with a MAC key and a key identifier,
   using some mechanism outside of ACME.  The key identifier MUST be an
   ASCII string.  The MAC key SHOULD be provided in base64url-encoded
   form, to maximize compatibility between non-ACME provisioning systems
   and ACME clients.






Barnes, et al.               Standards Track                   [Page 38]


                          ACME                        March 2019


   The ACME client then computes a binding JWS to indicate the external
   account holder's approval of the ACME account key.  The payload of
   this JWS is the ACME account key being registered, in JWK form.  The
   protected header of the JWS MUST meet the following criteria:

   o  The "alg" field MUST indicate a MAC-based algorithm

   o  The "kid" field MUST contain the key identifier provided by the CA

   o  The "nonce" field MUST NOT be present

   o  The "url" field MUST be set to the same value as the outer JWS

   The "signature" field of the JWS will contain the MAC value computed
   with the MAC key provided by the CA.

   POST /acme/new-account HTTP/1.1
   Host: example.com
   Content-Type: application/jose+json

   {
     "protected": base64url({
       "alg": "ES256",
       "jwk": /* account key */,
       "nonce": "K60BWPrMQG9SDxBDS_xtSw",
       "url": "https://example.com/acme/new-account"
     }),
     "payload": base64url({
       "contact": [
         "mailto:cert-admin@example.org",
         "mailto:admin@example.org"
       ],
       "termsOfServiceAgreed": true,

       "externalAccountBinding": {
         "protected": base64url({
           "alg": "HS256",
           "kid": /* key identifier from CA */,
           "url": "https://example.com/acme/new-account"
         }),
         "payload": base64url(/* same as in "jwk" above */),
         "signature": /* MAC using MAC key from CA */
       }
     }),
     "signature": "5TWiqIYQfIDfALQv...x9C2mg8JGPxl5bI4"
   }





Barnes, et al.               Standards Track                   [Page 39]


                          ACME                        March 2019


   If such a CA requires that newAccount requests contain an
   "externalAccountBinding" field, then it MUST provide the value "true"
   in the "externalAccountRequired" subfield of the "meta" field in the
   directory object.  If the CA receives a newAccount request without an
   "externalAccountBinding" field, then it SHOULD reply with an error of
   type "externalAccountRequired".

   When a CA receives a newAccount request containing an
   "externalAccountBinding" field, it decides whether or not to verify
   the binding.  If the CA does not verify the binding, then it MUST NOT
   reflect the "externalAccountBinding" field in the resulting account
   object (if any).  To verify the account binding, the CA MUST take the
   following steps:

   1.  Verify that the value of the field is a well-formed JWS

   2.  Verify that the JWS protected field meets the above criteria

   3.  Retrieve the MAC key corresponding to the key identifier in the
       "kid" field

   4.  Verify that the MAC on the JWS verifies using that MAC key

   5.  Verify that the payload of the JWS represents the same key as was
       used to verify the outer JWS (i.e., the "jwk" field of the outer
       JWS)

   If all of these checks pass and the CA creates a new account, then
   the CA may consider the new account associated with the external
   account corresponding to the MAC key.  The account object the CA
   returns MUST include an "externalAccountBinding" field with the same
   value as the field in the request.  If any of these checks fail, then
   the CA MUST reject the newAccount request.

7.3.5.  Account Key Rollover

   A client may wish to change the public key that is associated with an
   account in order to recover from a key compromise or proactively
   mitigate the impact of an unnoticed key compromise.

   To change the key associated with an account, the client sends a
   request to the server containing signatures by both the old and new
   keys.  The signature by the new key covers the account URL and the
   old key, signifying a request by the new key holder to take over the
   account from the old key holder.  The signature by the old key covers
   this request and its signature, and indicates the old key holder's
   assent to the rollover request.




Barnes, et al.               Standards Track                   [Page 40]


                          ACME                        March 2019


   To create this request object, the client first constructs a
   keyChange object describing the account to be updated and its account
   key:

   account (required, string):  The URL for the account being modified.
      The content of this field MUST be the exact string provided in the
      Location header field in response to the newAccount request that
      created the account.

   oldKey (required, JWK):  The JWK representation of the old key.

   The client then encapsulates the keyChange object in an "inner" JWS,
   signed with the requested new account key.  This "inner" JWS becomes
   the payload for the "outer" JWS that is the body of the ACME request.

   The outer JWS MUST meet the normal requirements for an ACME JWS
   request body (see Section 6.2).  The inner JWS MUST meet the normal
   requirements, with the following differences:

   o  The inner JWS MUST have a "jwk" header parameter, containing the
      public key of the new key pair.

   o  The inner JWS MUST have the same "url" header parameter as the
      outer JWS.

   o  The inner JWS MUST omit the "nonce" header parameter.

   This transaction has signatures from both the old and new keys so
   that the server can verify that the holders of the two keys both
   agree to the change.  The signatures are nested to preserve the
   property that all signatures on POST messages are signed by exactly
   one key.  The "inner" JWS effectively represents a request by the
   holder of the new key to take over the account form the holder of the
   old key.  The "outer" JWS represents the current account holder's
   assent to this request.
















Barnes, et al.               Standards Track                   [Page 41]


                          ACME                        March 2019


   POST /acme/key-change HTTP/1.1
   Host: example.com
   Content-Type: application/jose+json

   {
     "protected": base64url({
       "alg": "ES256",
       "kid": "https://example.com/acme/acct/evOfKhNU60wg",
       "nonce": "S9XaOcxP5McpnTcWPIhYuB",
       "url": "https://example.com/acme/key-change"
     }),
     "payload": base64url({
       "protected": base64url({
         "alg": "ES256",
         "jwk": /* new key */,
         "url": "https://example.com/acme/key-change"
       }),
       "payload": base64url({
         "account": "https://example.com/acme/acct/evOfKhNU60wg",
         "oldKey": /* old key */
       }),
       "signature": "Xe8B94RD30Azj2ea...8BmZIRtcSKPSd8gU"
     }),
     "signature": "5TWiqIYQfIDfALQv...x9C2mg8JGPxl5bI4"
   }

   On receiving a keyChange request, the server MUST perform the
   following steps in addition to the typical JWS validation:

   1.  Validate the POST request belongs to a currently active account,
       as described in Section 6.

   2.  Check that the payload of the JWS is a well-formed JWS object
       (the "inner JWS").

   3.  Check that the JWS protected header of the inner JWS has a "jwk"
       field.

   4.  Check that the inner JWS verifies using the key in its "jwk"
       field.

   5.  Check that the payload of the inner JWS is a well-formed
       keyChange object (as described above).

   6.  Check that the "url" parameters of the inner and outer JWSs are
       the same.





Barnes, et al.               Standards Track                   [Page 42]


                          ACME                        March 2019


   7.  Check that the "account" field of the keyChange object contains
       the URL for the account matching the old key (i.e., the "kid"
       field in the outer JWS).

   8.  Check that the "oldKey" field of the keyChange object is the same
       as the account key for the account in question.

   9.  Check that no account exists whose account key is the same as the
       key in the "jwk" header parameter of the inner JWS.

   If all of these checks pass, then the server updates the
   corresponding account by replacing the old account key with the new
   public key and returns status code 200 (OK).  Otherwise, the server
   responds with an error status code and a problem document describing
   the error.  If there is an existing account with the new key
   provided, then the server SHOULD use status code 409 (Conflict) and
   provide the URL of that account in the Location header field.

   Note that changing the account key for an account SHOULD NOT have any
   other impact on the account.  For example, the server MUST NOT
   invalidate pending orders or authorization transactions based on a
   change of account key.

7.3.6.  Account Deactivation

   A client can deactivate an account by posting a signed update to the
   account URL with a status field of "deactivated".  Clients may wish
   to do this when the account key is compromised or decommissioned.  A
   deactivated account can no longer request certificate issuance or
   access resources related to the account, such as orders or
   authorizations.  If a server receives a POST or POST-as-GET from a
   deactivated account, it MUST return an error response with status
   code 401 (Unauthorized) and type
   "urn:ietf:params:acme:error:unauthorized".

















Barnes, et al.               Standards Track                   [Page 43]


                          ACME                        March 2019


   POST /acme/acct/evOfKhNU60wg HTTP/1.1
   Host: example.com
   Content-Type: application/jose+json

   {
     "protected": base64url({
       "alg": "ES256",
       "kid": "https://example.com/acme/acct/evOfKhNU60wg",
       "nonce": "ntuJWWSic4WVNSqeUmshgg",
       "url": "https://example.com/acme/acct/evOfKhNU60wg"
     }),
     "payload": base64url({
       "status": "deactivated"
     }),
     "signature": "earzVLd3m5M4xJzR...bVTqn7R08AKOVf3Y"
   }

   The server MUST verify that the request is signed by the account key.
   If the server accepts the deactivation request, it replies with a 200
   (OK) status code and the current contents of the account object.

   Once an account is deactivated, the server MUST NOT accept further
   requests authorized by that account's key.  The server SHOULD cancel
   any pending operations authorized by the account's key, such as
   certificate orders.  A server may take a variety of actions in
   response to an account deactivation, e.g., deleting data related to
   that account or sending mail to the account's contacts.  Servers
   SHOULD NOT revoke certificates issued by the deactivated account,
   since this could cause operational disruption for servers using these
   certificates.  ACME does not provide a way to reactivate a
   deactivated account.

7.4.  Applying for Certificate Issuance

   The client begins the certificate issuance process by sending a POST
   request to the server's newOrder resource.  The body of the POST is a
   JWS object whose JSON payload is a subset of the order object defined
   in Section 7.1.3, containing the fields that describe the certificate
   to be issued:

   identifiers (required, array of object):  An array of identifier
      objects that the client wishes to submit an order for.

      type (required, string):  The type of identifier.

      value (required, string):  The identifier itself.





Barnes, et al.               Standards Track                   [Page 44]


                          ACME                        March 2019


   notBefore (optional, string):  The requested value of the notBefore
      field in the certificate, in the date format defined in [].

   notAfter (optional, string):  The requested value of the notAfter
      field in the certificate, in the date format defined in [].

   POST /acme/new-order HTTP/1.1
   Host: example.com
   Content-Type: application/jose+json

   {
     "protected": base64url({
       "alg": "ES256",
       "kid": "https://example.com/acme/acct/evOfKhNU60wg",
       "nonce": "5XJ1L3lEkMG7tR6pA00clA",
       "url": "https://example.com/acme/new-order"
     }),
     "payload": base64url({
       "identifiers": [
         { "type": "dns", "value": "www.example.org" },
         { "type": "dns", "value": "example.org" }
       ],
       "notBefore": "2016-01-01T00:04:00+04:00",
       "notAfter": "2016-01-08T00:04:00+04:00"
     }),
     "signature": "H6ZXtGjTZyUnPeKn...wEA4TklBdh3e454g"
   }

   The server MUST return an error if it cannot fulfill the request as
   specified, and it MUST NOT issue a certificate with contents other
   than those requested.  If the server requires the request to be
   modified in a certain way, it should indicate the required changes
   using an appropriate error type and description.

   If the server is willing to issue the requested certificate, it
   responds with a 201 (Created) response.  The body of this response is
   an order object reflecting the client's request and any
   authorizations the client must complete before the certificate will
   be issued.












Barnes, et al.               Standards Track                   [Page 45]


                          ACME                        March 2019


   HTTP/1.1 201 Created
   Replay-Nonce: MYAuvOpaoIiywTezizk5vw
   Link: <https://example.com/acme/directory>;rel="index"
   Location: https://example.com/acme/order/TOlocE8rfgo

   {
     "status": "pending",
     "expires": "2016-01-05T14:09:07.99Z",

     "notBefore": "2016-01-01T00:00:00Z",
     "notAfter": "2016-01-08T00:00:00Z",

     "identifiers": [
       { "type": "dns", "value": "www.example.org" },
       { "type": "dns", "value": "example.org" }
     ],

     "authorizations": [
       "https://example.com/acme/authz/PAniVnsZcis",
       "https://example.com/acme/authz/r4HqLzrSrpI"
     ],

     "finalize": "https://example.com/acme/order/TOlocE8rfgo/finalize"
   }

   The order object returned by the server represents a promise that if
   the client fulfills the server's requirements before the "expires"
   time, then the server will be willing to finalize the order upon
   request and issue the requested certificate.  In the order object,
   any authorization referenced in the "authorizations" array whose
   status is "pending" represents an authorization transaction that the
   client must complete before the server will issue the certificate
   (see Section 7.5).  If the client fails to complete the required
   actions before the "expires" time, then the server SHOULD change the
   status of the order to "invalid" and MAY delete the order resource.
   Clients MUST NOT make any assumptions about the sort order of
   "identifiers" or "authorizations" elements in the returned order
   object.













Barnes, et al.               Standards Track                   [Page 46]


                          ACME                        March 2019


   Once the client believes it has fulfilled the server's requirements,
   it should send a POST request to the order resource's finalize URL.
   The POST body MUST include a CSR:

   csr (required, string):  A CSR encoding the parameters for the
      certificate being requested [].  The CSR is sent in the
      base64url-encoded version of the DER format.  (Note: Because this
      field uses base64url, and does not include headers, it is
      different from PEM.)

   POST /acme/order/TOlocE8rfgo/finalize HTTP/1.1
   Host: example.com
   Content-Type: application/jose+json

   {
     "protected": base64url({
       "alg": "ES256",
       "kid": "https://example.com/acme/acct/evOfKhNU60wg",
       "nonce": "MSF2j2nawWHPxxkE3ZJtKQ",
       "url": "https://example.com/acme/order/TOlocE8rfgo/finalize"
     }),
     "payload": base64url({
       "csr": "MIIBPTCBxAIBADBFMQ...FS6aKdZeGsysoCo4H9P",
     }),
     "signature": "uOrUfIIk5RyQ...nw62Ay1cl6AB"
   }

   The CSR encodes the client's requests with regard to the content of
   the certificate to be issued.  The CSR MUST indicate the exact same
   set of requested identifiers as the initial newOrder request.
   Identifiers of type "dns" MUST appear either in the commonName
   portion of the requested subject name or in an extensionRequest
   attribute [] requesting a subjectAltName extension, or both.
   (These identifiers may appear in any sort order.)  Specifications
   that define new identifier types must specify where in the
   certificate signing request these identifiers can appear.

   A request to finalize an order will result in an error if the CA is
   unwilling to issue a certificate corresponding to the submitted CSR.
   For example:

   o  If the CSR and order identifiers differ

   o  If the account is not authorized for the identifiers indicated in
      the CSR

   o  If the CSR requests extensions that the CA is not willing to
      include



Barnes, et al.               Standards Track                   [Page 47]


                          ACME                        March 2019


   In such cases, the problem document returned by the server SHOULD use
   error code "badCSR" and describe specific reasons the CSR was
   rejected in its "detail" field.  After returning such an error, the
   server SHOULD leave the order in the "ready" state, to allow the
   client to submit a new finalize request with an amended CSR.

   A request to finalize an order will result in error if the order is
   not in the "ready" state.  In such cases, the server MUST return a
   403 (Forbidden) error with a problem document of type
   "orderNotReady".  The client should then send a POST-as-GET request
   to the order resource to obtain its current state.  The status of the
   order will indicate what action the client should take (see below).

   If a request to finalize an order is successful, the server will
   return a 200 (OK) with an updated order object.  The status of the
   order will indicate what action the client should take:

   o  "invalid": The certificate will not be issued.  Consider this
      order process abandoned.

   o  "pending": The server does not believe that the client has
      fulfilled the requirements.  Check the "authorizations" array for
      entries that are still pending.

   o  "ready": The server agrees that the requirements have been
      fulfilled, and is awaiting finalization.  Submit a finalization
      request.

   o  "processing": The certificate is being issued.  Send a POST-as-GET
      request after the time given in the Retry-After header field of
      the response, if any.

   o  "valid": The server has issued the certificate and provisioned its
      URL to the "certificate" field of the order.  Download the
      certificate.
















Barnes, et al.               Standards Track                   [Page 48]


                          ACME                        March 2019


   HTTP/1.1 200 OK
   Replay-Nonce: CGf81JWBsq8QyIgPCi9Q9X
   Link: <https://example.com/acme/directory>;rel="index"
   Location: https://example.com/acme/order/TOlocE8rfgo

   {
     "status": "valid",
     "expires": "2016-01-20T14:09:07.99Z",

     "notBefore": "2016-01-01T00:00:00Z",
     "notAfter": "2016-01-08T00:00:00Z",

     "identifiers": [
       { "type": "dns", "value": "www.example.org" },
       { "type": "dns", "value": "example.org" }
     ],

     "authorizations": [
       "https://example.com/acme/authz/PAniVnsZcis",
       "https://example.com/acme/authz/r4HqLzrSrpI"
     ],

     "finalize": "https://example.com/acme/order/TOlocE8rfgo/finalize",

     "certificate": "https://example.com/acme/cert/mAt3xBGaobw"
   }

7.4.1.  Pre-authorization

   The order process described above presumes that authorization objects
   are created reactively, in response to a certificate order.  Some
   servers may also wish to enable clients to obtain authorization for
   an identifier proactively, outside of the context of a specific
   issuance.  For example, a client hosting virtual servers for a
   collection of names might wish to obtain authorization before any
   virtual servers are created and only create a certificate when a
   virtual server starts up.

   In some cases, a CA running an ACME server might have a completely
   external, non-ACME process for authorizing a client to issue
   certificates for an identifier.  In these cases, the CA should
   provision its ACME server with authorization objects corresponding to
   these authorizations and reflect them as already valid in any orders
   submitted by the client.

   If a CA wishes to allow pre-authorization within ACME, it can offer a
   "new authorization" resource in its directory by adding the field
   "newAuthz" with a URL for the newAuthz resource.



Barnes, et al.               Standards Track                   [Page 49]