<?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="std" docName='draft-ietf-jmap-smime-06'>
  <front>
    <title abbrev="JMAP extension for S/MIME">
      S/MIME signature verification extension to JMAP 
    </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="2021" />
    
    <keyword>JMAP</keyword>
    <keyword>S/MIME</keyword>

    <abstract>

    <t>
    This document specifies an extension to JMAP for returning S/MIME signature verification status.
    </t>
	
    </abstract>
    
  </front>
  <middle>

    <section title="Introduction">

        <t>
        <xref target="RFC8621"/> is a JSON based application protocol for synchronising email data
        between a client and a server.

<!--
   JMAP [RFC8620] is a generic protocol for synchronising
   data, such as mail, calendars or contacts, between a client and a
   server.  It is optimised for mobile and web environments, and aims to
   provide a consistent interface to different data types.
   [RFC8621] builds on top of JMAP and defines how to perform
   email synchronization.
-->
        </t>
      
        <t>
        This document describes an extension to JMAP for returning S/MIME <xref target="RFC8551"/> signature verification status,
        without requiring a JMAP client to download the signature body part and all signed body parts (when multipart/signed media type is used)
        or to download and decode CMS (when application/pkcs7-mime media type is used).
        </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>

      <t>
      Type signatures, examples, and property descriptions in this document
      follow the conventions established in Section 1.1 of <xref target="RFC8620"/>.
      Data types defined in the core specification are also used in this document.
      </t>

    </section>

    <section title="Addition to the capabilities object">

      <t>
        The capabilities object is returned as part of the standard JMAP
        Session object; see the JMAP spec.  Servers supporting _this_
        specification MUST add a property called
        "urn:ietf:params:jmap:smimeverify" to the capabilities object.
      </t>

      <t>
        The value of this property is an empty object in both the JMAP
        session _capabilities_ property and an account's
        _accountCapabilities_ property.
      </t>

    </section>

    <section title="Extension to Email/get for S/MIME signature verification" anchor="smime">

      <t>
      <xref target="RFC8621"/> defines Email/get method for retrieving message specific information.
        This document defines the following pseudo values in the _properties_ argument:<vspace/>

        o *smimeStatus*: If "smimeStatus" is included in the list of requested
        properties, it MUST be interpreted by the server as a request to
        return "smimeStatus" response property.<vspace/>

        o *smimeErrors*: If "smimeErrors" is included in the list of requested
        properties, it MUST be interpreted by the server as a request to
        return "smimeErrors" response property.<vspace/>

        <!--///Rename "smimeVerifiedAt" to "smimeValidatedAt" everywhere?-->
        o *smimeVerifiedAt*: If "smimeVerifiedAt" is included in the list of requested
        properties, it MUST be interpreted by the server as a request to
        return "smimeVerifiedAt" response property.<vspace/>

        o *smimeStatusAtDelivery*: If "smimeStatusAtDelivery" is included in the list of requested
        properties, it MUST be interpreted by the server as a request to
        return "smimeStatusAtDelivery" response property. (It effectively the same as "smimeStatus"
        value calculated at the date/time of deliver, as specified by "receivedAt".)
      </t>

      <t>The "smimeStatus" response property is defined as follows:</t>
      
      <t>
        smimeStatus: "String|null". null signifies that the message doesn't
        contain any signature. This property contains the S/MIME signature
        and certificate verification status calculated according to
        <xref target="RFC8551"/> and <xref target="RFC8550"/><!--and RFC 5280 that the latter depends on -->.
        Possible string values of the property are
        listed below.  Servers MAY return other values not defined below.
        Client MUST treat unrecognized values as "unknown" or "signed/failed".
        Note that the value of this property might change over time.

        <list style="hanging">
          <t hangText="unknown">
            S/MIME message, but it is neither signed, nor encrypted.
            This can also be returned for a multipart/signed message which
            contains unrecognized signing protocol (for example OpenPGP).
          </t>
          
          <t hangText="signed">
            S/MIME signed message, but the signature was not yet
            verified.  Some servers might not attempt to verify signature
            until a particular message is requested by the client.
            JMAP servers compliant with this document SHOULD return
            "signed/verified" or "signed/failed" instead of this signature
            status.
          </t>
          
          <t hangText="signed/verified">
            S/MIME signed message and the sender's signature
            was successfully verified, sender matches the From header field
            and the sender's certificate (and the certificate chain) is
            trusted for signing.
          </t>
          
          <t hangText="signed/failed">
            S/MIME signed message, but the signature failed to
            verify.  This might be a policy related decision (message signer
            doesn't match the From header field), message was modified,
            the signer's certificate has expired or was revoked, etc.
          </t>
        </list>
      </t>


      <t>The "smimeStatusAtDelivery" response property
      has the same syntax as "smimeStatus", but calculated at the "receivedAt"
      date/time. Unlike "smimeStatus", the "smimeStatusAtDelivery" response property
      value is immutable. "smimeStatusAtDelivery" allows clients to compare S/MIME
      signature verification status at delivery with the current status as returned
      by "smimeStatus", for example it helps to answer questions like
      "was the signature valid at the time of delivery?".
      </t>

      <t>The "smimeErrors" response property is defined as follows:</t>
      
      <t>
        smimeErrors: "String[]|null". null signifies that the message doesn't
        contain any signature or that there were no errors when verifying
        S/MIME signature. (I.e. this property is non null only
        when the corresponding "smimeStatus" response property value
        is "signed/failed".)
        Each string in the array is a human readable description
        (in the language specified in Content-Language header field, if any)
        of a problem with the signature or the signing certificate.
        (See Section 3.8 of <xref target="RFC8620"/> in regards to how this is affected
        by the language selection.)
        For example, the signing certificate might be expired
        and the message From email address might not correspond to any of the email
        addresses in the signing certificate.
        Or the certificate might be expired and the JMAP server might be unable
        to retrieve CRL for the certificate.
        In both of these cases there would be 2 elements in the array.
      </t>

      <t>The "smimeVerifiedAt" response property is defined as follows:</t>

      <t>
        smimeVerifiedAt: "UTCDate|null" (server-set). null signifies that the message doesn't
        contain any S/MIME signature or that there is a signature, but there was no attempt
        to verify it<!--///Is use of null to signal "not verified" a good idea at all, especially considering the addition of "smimeStatusAtDelivery"?-->.
        In all other cases it is set to the date and time of when S/MIME signature
        was most recently verified.
        <!--///Remove the following, if use of null for "not verified" is going to be removed:-->
        Note that a request to fetch "smimeStatus" and/or "smimeErrors" would force this response
        property to be set to a non null value, if S/MIME signature exists.
      </t>

      <t>"smimeStatus" and "smimeErrors" values are calculated at the time the corresponding JMAP
      request was processed (but see below about result caching),
      not at the time when the message was generated (according to it's
      Date header field value). In all cases "smimeVerifiedAt" is set to time when
      "smimeStatus" and "smimeErrors" were last updated.
      As recalculating these values is expensive for the server
      <!--///The same value is also mentioned in "Security Considerations"-->
      they MAY be cached for up to 10 minutes from the moment when they were calculated.
      <!--/////Is this a sensible time limit?-->
      </t>

      <figure title="Example 1:">
        <preamble>
        </preamble>
<artwork><![CDATA[
      ["Email/get", {
      "ids": [ "f123u987" ],
      "properties": [ "mailboxIds", "from", "subject", "date",
       "smimeStatusAtDelivery", "receivedAt" ]
      }, "#1"]
      
This will result in the following response:

      [["Email/get", {
         "accountId": "abc",
         "state": "41234123231",
         "list": [
           {
             "id": "f123u457",
             "mailboxIds": { "f123": true },
             "from": [{"name": "Joe Bloggs", "email": "joe@bloggs.example.net"}],
             "subject": "Dinner tonight?",
             "date": "2020-07-07T14:12:00Z",
             "smimeStatusAtDelivery": "signed/verified",
             "receivedAt": "2020-07-07T14:15:18Z"
           }
         ]
      }, "#1"]]
]]></artwork>
        <postamble>
        </postamble>
      </figure>

      <figure title="Example 2:">
        <preamble>
        </preamble>
<artwork><![CDATA[
      ["Email/get", {
      "ids": [ "af123u123" ],
      "properties": [ "mailboxIds", "from", "subject", "date",
       "smimeStatus", "smimeErrors", "smimeVerifiedAt" ]
      }, "#1"]
      
This will result in the following response:

      [["Email/get", {
         "accountId": "abc",
         "state": "41234123231",
         "list": [
           {
             "id": "af123u123",
             "mailboxIds": { "f123": true },
             "from": [{"name": "Jane Doe",
                     "email": "jdoe@example.com"}],
             "subject": "Company takeover",
             "date": "2020-01-31T23:00:00Z",
             "smimeStatus": "signed/failed",
             "smimeErrors": [
               "From email address doesn't match the certificate",
               "Can't retrieve CRL from the CRL URL"],
             "smimeVerifiedAt": "2020-03-01T12:11:19Z"
           }
         ]
      }, "#1"]]
]]></artwork>
        <postamble>
        </postamble>
      </figure>

      <t>
        <xref target="RFC8621"/> defines Email/query method for searching for messages with specific properties.
        This document defines the following properties of the *FilterCondition* object:<vspace/>

        o *hasSmime*: "Boolean". If "hasSmime" has the value true, only messages with "smimeStatus" other than null match the condition.
        If "hasSmime" has the value false, only messages with "smimeStatus" equal to null match the condition.<vspace/>

        o *hasVerifiedSmime*: "Boolean". If "hasVerifiedSmime" has the value true, only messages with "smimeStatus" equal
        to "signed/verified" match the condition. If "hasVerifiedSmime" has the value false, only messages with "smimeStatus" not equal
        to "signed/verified" (including the value null) match the condition.
      </t>

    </section>

      
    <section title="IANA Considerations">

      <section title='JMAP capability registration for "smimeverify"'>

        <t>
          IANA is requested to register the "smime" JMAP Capability as follows:
        </t>

        <t>
          Capability Name: "urn:ietf:params:jmap:smimeverify"
        </t>

        <t>
          Specification document: this document
        </t>

        <t>
          Intended use: common
        </t>

        <t>
          Change Controller: IETF
        </t>

        <t>
          Security and privacy considerations: this document, <xref target="seccons"/>
        </t>

      </section>
      
    </section>

    <section title="Security Considerations" anchor="seccons">

      <t>Server side S/MIME signature verification requires the client to trust server verification code
      and configuration to perform S/MIME signature verification. For example, if the server is not configured
      with some Trust Anchors, some messages will have "signed/failed" status instead of "signed/verified".</t>

      <t>Constant recalculation of S/MIME signature status can result in Denial-of-Service condition.
      For that reason it is RECOMMENDED to cache results of signature verification for 10 minutes.</t>

      <!--
      <t>TBD. Server that lie?</t>
      -->

    </section>
    
  </middle>
  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?> <!-- Keywords -->
      <?rfc include="reference.RFC.8550"?> <!-- S/MIME Certificate Handling -->
      <?rfc include="reference.RFC.8551"?> <!-- S/MIME Message Format -->
      <?rfc include="reference.RFC.8620"?> <!-- JMAP Core -->
      <?rfc include="reference.RFC.8621"?> <!-- JMAP Mail -->      
    </references>

<!--    
    <references title="Informative References">
    </references>
-->

<!--
    <section title="Acknowledgements">
	
      <t>Thank you to Steve Kille and David Wilson for suggestions, comments and corrections on this document.</t>

      <t>David Wilson came up with the idea of defining a new Content-Type header field parameter to distinguish
      forwarded messages from inner header field protection constructs.</t>
      
    </section>
-->    
    
  </back>
</rfc>
