<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc rfcedstyle="yes"?>
<?rfc subcompact="no"?>
<?rfc symrefs="yes"?>
<?rfc comments="yes" ?>
<?rfc inline="yes" ?>

<rfc ipr="trust200902" category="info" docName='draft-ietf-acme-email-smime-09'>
  <front>
    <title abbrev="ACME for S/MIME">
      Extensions to Automatic Certificate Management Environment for end-user S/MIME certificates
    </title>
    <author initials="A." surname="Melnikov" fullname="Alexey Melnikov">
      <organization>Isode Ltd</organization>
      <address>
        <postal>
	        <street>14 Castle Mews</street>
	        <city>Hampton</city>
	        <region>Middlesex</region>
	        <code>TW12 2NP</code>
	        <country>UK</country>
        </postal>
	      <email>alexey.melnikov@isode.com</email>
      </address>
    </author>

    <date year="2020" />

    <keyword>ACME</keyword>
    <keyword>S/MIME</keyword>

    <abstract>

    <t>
    This document specifies identifiers and challenges required to enable
    the Automated Certificate Management Environment (ACME) to issue
    certificates for use by email users
    that want to use S/MIME.
    </t>
	
    </abstract>
    
  </front>
  <middle>

    <section title="Introduction">

        <t>
        ACME <xref target="RFC8555"/> is a mechanism for automating certificate
        management on the Internet.  It enables administrative entities to
        prove effective control over resources like domain names, and
        automates the process of generating and issuing certificates.
        </t>
      
        <t>
        This document describes an extension to ACME for use by S/MIME.
        <xref target="smime"/> defines extensions for issuing end-user S/MIME <xref target="RFC8550"/> certificates.
        </t>

      <!--
        <t>
        </t>
        -->
      
    </section>
    
    <section title="Conventions Used in This Document">
      
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
	    "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in
	    this document are to be interpreted as described in
	    <xref target="RFC2119"/>.</t>

    </section>

    <section title="Use of ACME for issuing end-user S/MIME certificates" anchor="smime">

      <t>
      ACME <xref target="RFC8555"/> defines a "dns" Identifier Type that is used to verify that a particular entity
      has control over a domain or specific service associated with the domain.
      In order to be able to issue end-user S/MIME certificates, ACME needs a new Identifier Type that
      proves ownership of an email address.
      </t>

      <t>
      This document defines a new Identifier Type "email" which corresponds to   
      an (all ASCII) email address <xref target="RFC5321"/> or Internationalized Email addresses <xref target="RFC6531"/>.
      (When Internationalized Email addresses are used, both U-labels and A-labels <xref target="RFC5890"/> are allowed in the domain part.)
      This can be used with S/MIME or other similar service that requires possession of a certificate tied to an email address.
      </t>

      <t>
      Any identifier of type "email" in a newOrder request MUST NOT have a wildcard ("*") character in its value.
      </t>

      <t>
      A new challenge type "email-reply-00" is used with "email" Identifier Type,
      which provides proof that an ACME client has control over an email address:
      
        <list style='numbers'>

          <t>An end-user initiates issuance of an S/MIME certificate for one of her email addresses.
          This might be done using email client UI (and might use some HTTP API underneath), by
          visiting a Certificate Authority web page or by sending an email to a well known
          Certificate Authority's email address. This document doesn't prescribe how exactly
          S/MIME certificate issuance is initiated.</t>

          <t>
          The ACME server (run by the Certificate Authority or their authorized third party)
          generates a "challenge" email message with the subject "ACME: &lt;token-part1&gt;",
          where &lt;token-part1&gt; is the base64url encoded <xref target="RFC4648"/> first part of the token,
          which contains at least 64 bits of entropy. (ACME server MUST generate token afresh for each
          S/MIME issuance request.) The challenge email message structure
          is described in more details in <xref target="acme-smime-challenge-email"/>.
          The second part of the token (token-part2,
          which also contains at least 64 bits of entropy) is returned over HTTPS <xref target="RFC2818"/> to the ACME client.
          </t>
          
          <t>
          The ACME client concatenates "token-part1" and "token-part2" to create "token", calculates
          keyAuthorization (as per Section 8.1 of <xref target="RFC8555"/>),
          then includes the base64url encoded SHA-256 digest <xref target="FIPS180-4"/>
          of the key authorization in the body of a response email message containing
          a single text/plain MIME body part <xref target="RFC2045"/>.
          The response email message structure
          is described in more details in <xref target="acme-smime-response-email"/>.
          </t>

        </list>
      </t>

      <t>
      For an identifier of type "email", the PKCS#10 <xref target="RFC2986"/>
      Certificate Signing Request (CSR) MUST contain the requested email address <!--either in the commonName
      portion of the requested subject name, or--> in an extensionRequest
      attribute <xref target="RFC2985"/> requesting a subjectAltName extension.
      </t>


<!--
      On receiving a response, the server constructs and stores the key
      authorization from the challenge "token" value and the current client
      account key.

      To validate a DNS challenge, the server performs the following steps:

      1.  Compute the SHA-256 digest [FIPS180-4] of the stored key
      authorization

      2.  Query for TXT records for the validation domain name

      3.  Verify that the contents of one of the TXT records match the
      digest value

      If all of the above verifications succeed, then the validation is
      successful.  If no DNS record is found, or DNS record and response
      payload do not pass these checks, then the validation fails.
-->

      <!--      
      <figure title="Figure 1">
        <preamble>
          For example, if the ACME client were to respond to the "email-reply-00" challenge,
          it would send the following request to the ACME server:
        </preamble>
<artwork><![CDATA[
   POST /acme/authz/asdf/0 HTTP/1.1
   Host: example.com
   Content-Type: application/jose+json

   {
     "protected": base64url({
       "alg": "ES256",
       "kid": "https://example.com/acme/acct/1",
       "nonce": "Q_s3MWoqT05TrdkM2MTDcw",
       "url": "https://example.com/acme/authz/asdf/0"
     }),
     "payload": base64url({
       "type": "email-reply-00",
       "keyAuthorization": "IlirfxKKXA...vb29HhjjLPSggQiE"
     }),
     "signature": "7cbg5JO1Gf5YLjjF...SpkUfcdPai9uVYYU"
   }
]]></artwork>
        <postamble></postamble>
      </figure>
-->

      <section title="ACME challenge email" anchor="acme-smime-challenge-email">

        <t>
          A "challenge" email message MUST have the following structure:

          <list style='numbers'>
            <t>
            The message Subject header field has the following syntax: "ACME: &lt;token-part1&gt;",
            where the prefix "ACME:" is followed by folding white space (FWS, see <xref target='RFC5322'/>)
            and then by &lt;token-part1&gt;, which is the base64url encoded first part of the ACME token
            that MUST be at least 64 bits long after decoding.
			
        <!--Alternative to allow for arbitrary prefix, if needed:
            The message Subject header field has the following syntax: "&lt;prefix&gt;ACME: &lt;token-part1&gt;",
            where the optional prefix &lt;prefix&gt; contain any text (it SHOULD be omitted), which is then
            followed by the literal string "ACME:", which in turn is followed by a folding white space (FWS, see <xref target='RFC5322'/>)
            and then by &lt;token-part1&gt; is the base64url encoded first part of the ACME token
            that MUST be at least 64 bits long after decoding.
          -->
			
            Due to the recommended 78-octet line length limit
            in <xref target='RFC5322'/>, the subject line can be folded, so whitespaces (if any) within
            the &lt;token-part1&gt; MUST be ignored. <xref target='RFC2231'/> encoding of the message Subject header field MUST be supported,
            but when used, only "UTF-8" and "US-ASCII" charsets MUST be used (i.e. other charsets MUST NOT be used).
            </t>

            <t>
            The To header field MUST be the email address of the entity that requested the S/MIME certificate to be generated.</t>

            <t>The message MAY contain a Reply-To header field.</t>
            
            <t>
            The message MUST include the "Auto-Submitted: auto-generated" header field <xref target="RFC3834"/>.
            The "Auto-Submitted" header field SHOULD include the "type=acme" parameter.
            It MAY include other optional parameters as allowed by the syntax of the Auto-Submitted header field.</t>

            <t>
            In order to prove authenticity of a challenge message, it MUST be either DKIM <xref target="RFC6376"/>
            signed or S/MIME <xref target="RFC8551"/> signed.
            <!--Alexey: James suggested that PGP/MIME can also be used here. This might be introduced in a later version,
            but for simplicity there are only 2 options right now.-->
            If DKIM signing is used, the resulting DKIM-Signature header field MUST contain the "h=" tag that includes
            at least "From", "Sender", "Reply-To", "To", "CC", "Subject", "Date", "In-Reply-To", "References",
            "Message-ID", "Content-Type", and "Content-Transfer-Encoding" header fields.
            The message MUST also pass DMARC validation <xref target="RFC7489"/>, which implies DKIM and SPF validation <xref target="RFC7208"/>.
            </t>

            <t>
            The body of the challenge message is not used for automated processing, so it can be any media type.
            (However there are extra requirements on S/MIME signing, if used. See below.)
            Typically it is text/plain or text/html containing a human-readable explanation of the purpose of the message.
            If S/MIME signing is used to prove authenticity of the challenge message,
            then the multipart/signed or "application/pkcs7-mime; smime-type=signed-data;" media type should be used.
            Either way, it MUST use S/MIME header protection. <!--/////Add a ref in the future-->
            </t>
            
        </list>

        </t>

      <figure title="Figure 1">
        <preamble>
          An example ACME "challenge" email (note that DKIM related header fields are not included for simplicity).
        </preamble>
<artwork>
  <![CDATA[
  Auto-Submitted: auto-generated; type=acme
  Date: Sat, 1 Sep 2018 10:08:55 +0100
  Message-ID: <A2299BB.FF7788@example.org>
  From: acme-generator@example.org
  To: alexey@example.com
  Subject: ACME: <base64url-encoded-token-with-64-bits-of-entropy>
  Content-Type: text/plain
  MIME-Version: 1.0
   
  This is an automatically generated ACME challenge for email address
  "alexey@example.com". If you haven't requested an S/MIME
  certificate generation for this email address, be very afraid.
  If you did request it, your email client might be able to process
  this request automatically, or you might have to paste the first
  token part into an external program.
]]></artwork>
        <postamble></postamble>
      </figure>

      </section>

      <section title="ACME response email" anchor="acme-smime-response-email">

        <t>
          A valid "response" email message MUST have the following structure:

          <list style='numbers'>
            <t>
            The message Subject header field has the following syntax: "&lt;Reply-prefix&gt; ACME: &lt;token-part1&gt;",
            where &lt;Reply-prefix&gt; is typically the reply prefix "Re:" and
            the string "ACME:" is preceded and followed by folding white space (FWS, see <xref target='RFC5322'/>)
            and then by &lt;token-part1&gt;. &lt;token-part1&gt; is the base64url encoded first part of the ACME token
            (as received in the ACME challenge) that MUST be at least 64 bits long after decoding. Due to recommended 78 octet line length limit
            in <xref target='RFC5322'/>, the subject line can be folded, so whitespaces (if any) within
            the &lt;token-part1&gt; MUST be ignored. <xref target='RFC2231'/> encoding of the Subject header field MUST be supported,
            but when used, only "UTF-8" and "US-ASCII" charsets MUST be used (i.e. other charsets MUST NOT be used).
            When parsing subjects, ACME servers must decode <xref target='RFC2231'/> encoding (if any) and
            then they can ignore any prefix before the "ACME:" label.
            </t>

			      <t>The From: header field contains the email address of the user that is requesting S/MIME certificate issuance.</t>
            
            <t>The To: header field of the response contains the value from the Reply-To: header field from the challenge message (if set)
            or from the From: header field of the challenge message otherwise.</t>
			
            <t>The Cc: header field is ignored if present in the "response" email message.</t>

            <t>The In-Reply-To: header field SHOULD be set to the Message-ID header field of the challenge message
            according to rules in Section 3.6.4 of <xref target="RFC5322"/>.</t>

            <t>List-* header fields <xref target="RFC4021"/><xref target="RFC8058"/> MUST be absent (i.e., the reply can't come from a mailing list)</t>

            <!--Alexey: not needed, as the message might not be generated automatically:
            <t>
            The message MAY include the "Auto-Submitted: auto-generated" header field <xref target="RFC3834"/>.
            It MAY include optional parameters as allowed by syntax of Auto-Submitted header field.</t>
            -->
            
            <t>
            <!--////Should we allow either new MIME type or text/plain?-->
            The media type of the "response" email message is either text/plain or multipart/alternative containing
            text/plain as one of the alternatives.
            
            The text/plain body part (whether or not it is inside multipart/alternative)
            MUST contain a block of lines starting with the line "-----BEGIN ACME RESPONSE-----", followed by one
            or more line containing the base64url-encoded SHA-256 digest <xref target="FIPS180-4"/>
            of the key authorization, calculated from concatenated token-part1 (received over email)
            and token-part2 (received over HTTPS). See the 3rd bullet point in <xref target="smime"/> for more details.
            (Note that due to historical line length limitations
            in email, line endings (CRLFs) can be freely inserted in the middle of the encoded digest,
            so they MUST be ignored when processing it.) The final line of the encoded digest
            is followed by a line containing "-----END ACME RESPONSE-----".
            Any text before and after this block is ignored. For example such text might explain what
            to do with it for ACME-unaware clients.
            </t>
			
			      <t>There is no need to use any Content-Transfer-Encoding other than 7bit for the text/plain body part,
			      however use of Quoted-Printable or base64 is not prohibited in a "response" email message.</t>

            <t>
            <!--Can't use S/MIME signing here, as the whole point is to issue an S/MIME certificate for the user.-->
            In order to prove authenticity of a response message, it MUST be DKIM <xref target="RFC6376"/>
            signed. The resulting DKIM-Signature header field MUST contain the "h=" tag that includes
            at least "From", "Sender", "Reply-To", "To", "CC", "Subject", "Date", "In-Reply-To", "References",
            "Message-ID", "Content-Type", and "Content-Transfer-Encoding" header fields.
            The message MUST also pass DMARC validation <xref target="RFC7489"/>,
            which implies DKIM and SPF validation <xref target="RFC7208"/>.
            </t>

          </list>

        </t>

      <figure title="Figure 2">
        <preamble>
          Example ACME "response" email (note that DKIM related header fields are not included for simplicity).
        </preamble>
<artwork>
  <![CDATA[
   Date: Sat, 1 Sep 2018 11:12:00 +0100
   Message-ID: <111-22222-3333333@example.com>
   From: alexey@example.com
   To: acme-generator@example.org
   Subject: Re: ACME: <base64url-encoded-token-with-enough-entropy>
   Content-Type: text/plain
   MIME-Version: 1.0
   
   -----BEGIN ACME RESPONSE-----
   LoqXcYV8q5ONbJQxbmR7SCTNo3tiAXDfowy
   jxAjEuX0.9jg46WB3rR_AHD-EBXdN7cBkH1WOu0tA3M9
   fm21mqTI
   -----END ACME RESPONSE-----
]]></artwork>
        <postamble></postamble>
      </figure>

      </section>      
      
    </section>

    <section title="Internationalization Considerations">
      <t>
      <xref target="RFC8616"/> updated/clarified use of DKIM/SPF/DMARC with Internationalized Email addresses <xref target="RFC6531"/>.
        Please consult RFC 8616 in regards to any changes that need to be implemented.
      </t>

      <t>
        Use of non ASCII characters in left hand sides of Internationalized Email addresses requires putting
        Internationalized Email Addresses in X.509 Certificates <xref target="RFC8398"/>.
      </t>

    </section>

    <section title="IANA Considerations">

      <section title="ACME Identifier Type">

        <t>
        IANA is requested to register a new Identifier type in the "ACME Identifier Types" registry
        defined in Section 9.7.7 of <xref target="RFC8555"/> with Label "email" and a Reference to [RFCXXXX],
        <xref target="RFC5321"/> and <xref target="RFC6531"/>.
        The new Identifier Type corresponds to an (all ASCII) email address <xref target="RFC5321"/>
        or Internationalized Email addresses <xref target="RFC6531"/>.
        </t>

      </section>

      <section title="ACME Challenge Type">

        <t>
          IANA is also requested to register a new entry in the "ACME Validation Methods" registry
          defined in Section 9.7.8 of <xref target="RFC8555"/>.
          This entry is as follows:
        </t>
        
        <texttable>
          <!--
          <preamble></preamble>
          -->

          <ttcol align='center'>Label</ttcol>
          <ttcol align='center'>Identifier Type</ttcol>
          <ttcol align='center'>ACME</ttcol>
          <ttcol align='center'>Reference</ttcol>

          <c>email-reply-00</c>
          <c>email</c>
          <c>Y</c>
          <c>[RFCXXXX]</c>

          <!--<postamble></postamble>-->
        </texttable>

      </section>

    </section>

    <section title="Security Considerations" anchor="seccons">

      <t>
        Please see Security Considerations of <xref target="RFC8555"/> for general security considerations
        related to use of ACME. This challenge/response protocol demonstrates that an entity that controls
        the private key (corresponding to the public key in the certificate) also controls the named email
        account. Any claims about the correctness or fitness-for-purpose of the email address must be
        otherwise assured. I.e. ACME server is only vouching that the requested email address seem to belong
        to the entity that requested the certificate.
      </t>

      <t>
        The security of the "email-reply-00" challenge type depends on the security of the email system.
        A third party that can read and reply to user's email messages (by possessing a user's password
        or a secret derived from it that can give read and reply access, such as "password equivalent" information;
        or by being given permissions to act on a user's behalf using email delegation feature common
        in some email systems) can request S/MIME certificates using the protocol specified in this document
        and is indistinguishable from the email account owner.
        This has several possible implications:
        
        <list style='numbers'>

          <t>an entity that compromised an email account would be able to request S/MIME certificates
          using the protocol specified in this document and such entity couldn't be distinguished from
          the legitimate email account owner (unless some external sources of information are consulted);</t>

          <t>for email addresses with legitimate shared access/control by multiple users, any such user
          would be able to request S/MIME certificates using the protocol specified in this document
          and such requests can't be attributed to a specific user without consulting external systems
          (such as IMAP/SMTP access logs);</t>

          <t>protocol specified in this document is not suitable for use with email addresses
          associated with mailing lists <xref target="RFC5321"/>.</t>

        </list>

      </t>

      <t>
        An email system in its turn depends on DNS. A third party that can manipulate DNS MX records
        for a domain might be able to redirect email and can get (at least temporary) read and reply access to it.
        Similar considerations apply to SPF and DMARC TXT records in DNS.
        Use of DNSSEC by email system administrators is recommended to avoid easy spoofing
        of DNS records affecting email system.
      </t>

    </section>
    
  </middle>
  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2045"?> <!-- MIME, part 1 -->
      <?rfc include="reference.RFC.2119"?> <!-- Keywords -->
      <?rfc include="reference.RFC.2231"?> <!-- RFC 2231 parameter encoding -->
      <?rfc include="reference.RFC.2818"?> <!-- HTTPS -->
      <?rfc include="reference.RFC.2985"?> <!-- PKCS #9: Selected Object Classes and Attribute Types Version 2.0 -->
      <?rfc include="reference.RFC.2986"?> <!-- PKCS #10: Certification Request Syntax Specification -->
      <?rfc include="reference.RFC.3834"?> <!-- Auto-Submitted header field -->
      <?rfc include="reference.RFC.4021"?> <!-- Registration of Mail and MIME Header Fields -->
      <?rfc include="reference.RFC.4648"?> <!-- base64url -->
      <?rfc include="reference.RFC.5321"?> <!-- SMTP -->
      <?rfc include="reference.RFC.5322"?> <!-- Email Format -->
      <?rfc include="reference.RFC.5890"?> <!-- IDNA -->
      <?rfc include="reference.RFC.6376"?> <!-- DKIM -->
      <?rfc include="reference.RFC.6531"?> <!-- Internationalized Email Addresses (SMTP Extension) -->
      <?rfc include="reference.RFC.7208"?> <!-- SPF -->
      <?rfc include="reference.RFC.7489"?> <!-- DMARC -->
      <?rfc include="reference.RFC.8058"?> <!-- Signaling One-Click Functionality for List Email Headers -->
      <?rfc include="reference.RFC.8398"?> <!-- Internationalized Email Addresses in X.509 Certificates -->
      <?rfc include="reference.RFC.8550"?> <!-- S/MIME Certificate Handling -->
      <?rfc include="reference.RFC.8551"?> <!-- S/MIME Message Format -->
      <?rfc include="reference.RFC.8555"?> <!-- ACME -->
      <?rfc include="reference.RFC.8616"?> <!-- Email Authentication for Internationalized Mail -->

      <reference anchor="FIPS180-4" target="https://csrc.nist.gov/publications/detail/fips/180/4/final">
        <front>
          <title>Secure Hash Standard (SHS)</title>
          <author>
            <organization>National Institute of Standards and Technology</organization>
          </author>
          <date month="August" year="2015"/>
        </front>
        <seriesInfo name="FIPS" value="PUB 180-4"/>
      </reference>
      
    </references>

<!--    
    <references title="Informative References">
    </references>
-->

    <section title="Acknowledgements">
	
      <t>Thank you to Andreas Schulze, Gerd v. Egidy, James A. Baker, Ben Schwartz,
      Peter Yee and Michael Jenkins for suggestions, comments, and corrections on this document.</t>
      
    </section>
    
  </back>
</rfc>
