<?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 ipr="trust200902" category="std" updates="2595, 3207, 3501, 5804"
     docName="draft-ietf-uta-email-tls-certs-04">
  <front>
    <title abbrev="TLS Server Identity Check for Email">
      Updated TLS Server Identity Check Procedure for Email Related Protocols
    </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="2015" />
    
    <keyword>SMTP</keyword>
    <keyword>Submission</keyword>
    <keyword>IMAP</keyword>
    <keyword>POP</keyword>
    <keyword>ManageSieve</keyword>

    <abstract>
      <t>This document describes TLS server identity verification procedure for SMTP Submission,
         IMAP, POP and ManageSieve clients. It replaces Section 2.4 of RFC 2595.
      </t>
    </abstract>
    
  </front>
  <middle>
      
    <section title="Introduction">

<!--////Needs improving, as usual-->

	<t>
   Use of TLS by SMTP Submission, IMAP, POP and ManageSieve clients is described in <xref target="RFC3207"/>,
   <xref target="RFC3501"/>, <xref target="RFC2595"/> and <xref target="RFC5804"/> respectively.
   Each of the documents describes slightly different rules for server certificate identity verification
   (or doesn't define any rules at all). In reality, email client and server developers implement many of
   these protocols at the same time, so it would be good to define modern and consistent rules for verifying
   email server identities using TLS.
	</t>
	
	<t>
	 This document describes the updated TLS server identity verification procedure
	 for SMTP Submission <xref target="RFC6409"/> <xref target="RFC3207"/>, IMAP <xref target="RFC3501"/>,
	 POP <xref target="RFC1939"/> and ManageSieve <xref target="RFC5804"/> clients.
	 It replaces Section 2.4 of RFC 2595.
	</t>
	
	<t>
	 Note that this document doesn't apply to use of TLS in MTA-to-MTA SMTP.
	 <cref>
     Open Issue: This is covered by draft-friedl-uta-smtp-mta-certs,
     or should this be covered in this document instead, just in a separate section?</cref>
	</t>
	
	<t>
	 The main goal of the document is to provide consistent TLS server identity
	 verification procedure across multiple email related protocols.
	 This should make it easier for Certification Authorities and ISPs to deploy TLS
	 for email use, and would enable email client developers to write more secure
	 code.
	</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="Email Server Certificate Verification Rules" anchor="rules">

     <t>
   During a TLS negotiation, an email client (i.e., an SMTP, IMAP, POP3
   or ManageSieve client) MUST check its understanding
   of the server hostname against the server's identity as presented in
   the server Certificate message, in order to prevent man-in-the-middle
   attacks.  Matching is performed according to the rules specified in
   Section 6 of <xref target='RFC6125'/>,
   including "certificate pinning" and the procedure on failure to match.
   The following inputs are used by the verification procedure used in
   <xref target='RFC6125'/>:
   
<list style="numbers">

       <t>
       For DNS-ID and CN-ID identifier types the client MUST use the server hostname it used to open the
       connection as at least one of the values to compare against (*)
       in the server certificate.
<!--///Alternative wording?
       The client MAY also use other hostnames derived in a secure manner (e.g. using DNSSEC)
-->
       The client MUST NOT use any form of the server hostname derived
       from an insecure remote source (e.g., insecure DNS lookup).
       CNAME canonicalization is not done.
     </t>
         
       <t>
       When using email service discovery procedure specified in <xref target="RFC6186"/>
       the client MUST also use the right hand side of the email address as another "reference identifier"
       to compare against in the server certificate.       
       </t>

</list> 

     (*) - "reference identifier" (see the definition in <xref target='RFC6125'/>).
     </t>

	<t>    
   The rules and guidelines defined in <xref target='RFC6125'/>
   apply to an email server certificates, with the following supplemental rules:
   
<list style="numbers">
    
<!--From RFC 2595/3501:
     If a subjectAltName extension of type dNSName is present in the
     certificate, it SHOULD be used as the source of the server's
     identity.
-->
    
      <t>
      Support for the DNS-ID identifier type (subjectAltName of dNSName type <xref target="RFC5280"/>) is REQUIRED
      in Email client software implementations.
      </t>

      <t>
<!--////Downgrade the first "REQUIRED" to "SHOULD"?-->
      Support for the SRV-ID identifier type (subjectAltName of SRVName type <xref target="RFC4985"/>) is REQUIRED for
      email client software implementations that support <xref target="RFC6186"/>.
      List of SRV-ID types for email services is specified in <xref target="RFC6186"/>.
      For the ManageSieve protocol the service name "sieve" is used.
      </t>
    
      <t>URI-ID identifier type (subjectAltName of uniformResourceIdentifier type <xref target="RFC5280"/>) MUST NOT be used by clients for server verification, as
      URI-ID were not historically used for email.</t>

      <t>For backward compatibility with deployed software CN-ID identifier type (CN attribute from the subject name, see <xref target='RFC6125'/>)
         MAY be used for server identity verification.</t>
	  
      <t>Email protocols allow use of certain wilcards in identifiers
      presented by email servers.
      The "*" wildcard character MAY be used as the left-most name
      component of DNS-ID or CN-ID in the certificate.
      For example, a DNS-ID of *.example.com would
      match a.example.com, foo.example.com, etc. but would not match
      example.com.
      Note that the wildcard character MUST NOT be used as a fragment
      of the left-most name component (e.g., *oo.example.com,
      f*o.example.com, or foo*.example.com).
      <cref>Should the rules on "*" only matching one level be relaxed to cope with some existing deployments?</cref>
      </t>
    
</list>
	    
	</t>
	
    </section>


    <section title="Compliance Checklist for Certification Authorities">

      <t>
        <list style="numbers">

          <t>
            CA MUST support issuance of server certificates with DNS-ID identifier type (subjectAltName of dNSName type <xref target="RFC5280"/>).
          </t>

          <t>
            CA MUST support issuance of server certificates with SRV-ID identifier type (subjectAltName of SRVName type <xref target="RFC4985"/>) for each type of email service.
          </t>

          <t>
            For backward compatibility with deployed client base, CA MUST support issuance of server certificates with CN-ID identifier type (CN attribute from the subject name, see <xref target='RFC6125'/>).
          </t>
          
          <t>
            CA MAY allow "*" (wildcard) as the left-most name component of DNS-ID or CN-ID in server certificates it issues.
          </t>

        </list>

      </t>

    </section>

    <section title="Compliance Checklist for Mail Service Providers and Certificate Signing Request generation tools">

<!--///Should Certificate Signing Request generation tools have a separate section, as they effectively
       are REQUIRED to support everything listed below?-->      

      <t>
        <list style="numbers">

          <t>
            SHOULD include the DNS-ID identifier type (subjectAltName of dNSName type <xref target="RFC5280"/>) in
            Certificate Signing Requests for both the right hand side of served email addresses,
            as well as for the host name where the email server(s) are running.
          </t>

          <t>
            If the email services provided are discoverable using DNS SRV as specified in <xref target="RFC6186"/>,
            the Mail Service Provider MUST include the SRV-ID identifier type (subjectAltName of SRVName type <xref target="RFC4985"/>)
            for each type of email service in Certificate Signing Requests.
          </t>

          <t>
            SHOULD include CN-ID identifier type (CN attribute from the subject name, see <xref target='RFC6125'/>)
            for the host name where the email server(s) is running
            in Certificate Signing Requests for backward compatibility with deployed email clients.
            (Note, a certificate can only include a single CN-ID, so if a mail service is running on multiple hosts,
            either each host has to use different certificate with its own CN-ID, a single certificate with multiple
            DNS-IDs, or a single certificate with wildcard in CN-ID can be used).
          </t>

          <t>
            MAY include "*" (wildcard) as the left-most name component of DNS-ID or CN-ID in Certificate Signing Requests.
          </t>

        </list>

      </t>

    </section>


    <section title="Examples">
	
      <t>
   Consider an IMAP-accessible email server which supports both
   IMAP and IMAPS (IMAP-over-TLS) at the host
   "mail.example.net" servicing email addresses of the form
   "user@example.net".
   A certificate for this service needs to include
   DNS-IDs of "example.net" (because it is the right hand side of emails)
   and "mail.example.net" (this is what a user of this server enters manually, if not using <xref target="RFC6186"/>).
   It might also include CN-IDs of "mail.example.net"
   for backward compatibility with deployed infrastructure.
      </t>
      
      <t>
   Consider the IMAP-accessible email server from the previous paragraph
   which is additionally discoverable via DNS SRV lookups
   in domain "example.net" (DNS SRV records "_imap._tcp.example.net"
   and "_imaps._tcp.example.net").  In addition to DNS-ID/CN-ID identity types specified above,
   a certificate for this service also needs to include SRV-IDs of "_imap.example.net" (when STARTTLS is used on the IMAP port)
   and "_imaps.example.net" (when TLS is used on IMAPS port). See <xref target="RFC6186"/> for more details.
   (Note that unlike DNS SRV there is no "_tcp" component in SRV-IDs).
      </t>
	
<!--//From RFC 6125, Section 6.2.2:
   A mail user agent that is connecting via IMAPS to the email service
   at "example.net" (resolved as "mail.example.net") might have five
   reference identifiers: an SRV-ID of "_imaps.example.net" (see
   [EMAIL-SRV]), DNS-IDs of "example.net" and "mail.example.net", and,
   as a fallback, CN-IDs of "example.net" and "mail.example.net".  (A
   legacy email user agent would not support [EMAIL-SRV] and therefore
   would probably be explicitly configured to connect to
   "mail.example.net", whereas an SRV-aware user agent would derive
   "example.net" from an email address of the form "user@example.net"
   but might also accept "mail.example.net" as the DNS domain name
   portion of reference identifiers for the service.)
-->

    <!--////
      <t>TBD: Include an example certificate as shown by OpenSSL or similar.</t>
    -->
      
      <t>
   Consider an SMTP Submission server at the host
   "submit.example.net" servicing email addresses of the form
   "user@example.net" and discoverable via DNS SRV lookups
   in domain "example.net" (DNS SRV records "_submission._tcp.example.net").
   A certificate for this
   service needs to include SRV-IDs of "_submission.example.net"
   (see <xref target="RFC6186"/>) along with DNS-IDs of
   "example.net" and "submit.example.net".  It might also include CN-IDs
   of "submit.example.net" for backward compatibility
   with deployed infrastructure.
      </t>

      <t>
   Consider a host "mail.example.net" servicing email addresses of the form
   "user@example.net" and discoverable via DNS SRV lookups in domain "example.net",
   which runs SMTP Submission, IMAPS and POP3S (POP3-over-TLS) and ManageSieve services.
   Each of the servers can use their own certificate specific to their service
   (see examples above). Alternatively they can all share a single certificate
   that would include SRV-IDs of "_submission.example.net",
   "_imaps.example.net", "_pop3s.example.net" and "_sieve.example.net"
   along with DNS-IDs of "example.net" and "mail.example.net".
   It might also include CN-IDs of "mail.example.net"
   for backward compatibility with deployed infrastructure.
      </t>

    </section>

    <section title="IANA Considerations">
	
      <t>This document doesn't require any action from IANA.</t>
	
    </section>
    
    <section title="Security Considerations" anchor="seccons">

	    <t>The goal of this document is to improve interoperability and
      thus security of email clients wishing to access email servers
      over TLS protected email protocols, by specifying a consistent
      set of rules that email service providers, email client writers
      and Certification Authorities can use when creating server certificates.</t>

      <t>
      TLS Server Identity Check for Email relies on use of trustworthy DNS hostnames
      when constructing "reference identifiers" that are checked against an email server certificate.
      Such trustworthy names are either entered manually (for example if they are advertised on a Mail Service Provider's website),
      explicitly confirmed by the user (e.g. if they are a target of a DNS SRV lookup) or
      derived using a secure third party service (e.g. DNSSEC-protected SRV records
      which are verified by the client or trusted local resolver).
<!--///Actually, this is not true, unless PKIX is also subverted:
      TLS Server Identity Check doesn't protect from compromise of DNS information (such as DNS cache poisoning)
-->
      Future work in this area might benefit from integration with DANE <xref target="RFC6698"/>,
      but it is not covered by this document.
      </t>

 <!--////
  <xref target="RFC6186"/>
 -->

    </section>
    
  </middle>
  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?> <!-- Keywords -->
      <?rfc include="reference.RFC.5321"?> <!-- SMTP -->
      <?rfc include="reference.RFC.6409"?> <!-- Submission protocol -->
      <?rfc include="reference.RFC.3207"?> <!-- SMTP STARTTLS extension -->
      <?rfc include="reference.RFC.3501"?> <!-- IMAP -->
      <?rfc include="reference.RFC.1939"?> <!-- POP3 -->
      <?rfc include="reference.RFC.5804"?> <!-- ManageSieve -->
	
      <?rfc include="reference.RFC.6125"?> <!--TLS Server Identity Check-->
      <?rfc include="reference.RFC.5280"?> <!-- PKIX -->
      <?rfc include="reference.RFC.4985"?> <!-- PKIX-SRV -->
      <?rfc include="reference.RFC.6186"?> <!-- Use of SRV Records for Locating Email Submission/Access Services -->

    </references>

    <references title="Informative References">
	
      <?rfc include="reference.RFC.2595"?> <!-- STARTTLS/STLS in ACAP/IMAP/POP -->
      <?rfc include="reference.RFC.6698"?> <!-- DANE TLSA records -->      

    </references>

    <section title="Acknowledgements">
	
      <t>Thank you to Chris Newman, Viktor Dukhovni and Sean Turner for comments on this document.</t>

      <t>The editor of this document copied lots of text from RFC 2595 and RFC 6125,
      so the hard work of editors of these document is appreciated.</t>
	
    </section>

    <section title="Changes since draft-ietf-uta-email-tls-certs-00">

      <t>[[Note to RFC Editor: Please delete this section before publication]]</t>

      <t>Added another example, clarified that subjectAltName and DNS SRV are using slightly different syntax.</t>
      
      <t>As any certificate can only include one CN-ID, corrected examples.</t>

      <t>Split rules to talk seperately about requirements on MUAs, CAs and MSPs/CSR generation tools.</t>
      
      <t>Updated Introduction section.</t>

    </section>


  </back>
</rfc>
