<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>

<rfc xmlns:xi="http://www.w3.org/2001/XInclude" submissionType="IETF" category="std" consensus="true" docName="draft-ietf-ace-cmpv2-coap-transport-10" number="9482" ipr="trust200902" obsoletes="" updates="" xml:lang="en" tocInclude="true" symRefs="true" sortRefs="true"  version="3">

  
  <!-- xml2rfc v2v3 conversion 3.17.1 -->
  <front>
    <title abbrev="CoAP Transfer for CMP">Constrained Application Protocol (CoAP) Transfer for the Certificate Management Protocol</title>
    <seriesInfo name="RFC" value="9482"/>
    <author fullname="Mohit Sahni" initials="M" role="editor" surname="Sahni">
      <organization>Palo Alto Networks</organization>
      <address>
        <postal>
          <street>3000 Tannery Way</street>
          <city>Santa Clara</city>
          <region>CA</region>
          <code>95054</code>
          <country>United States of America</country>
        </postal>
        <email>msahni@paloaltonetworks.com</email>
      </address>
    </author>
    <author fullname="Saurabh Tripathi" initials="S" role="editor" surname="Tripathi">
      <organization>Palo Alto Networks</organization>
      <address>
        <postal>
          <street>3000 Tannery Way</street>
          <city>Santa Clara</city>
          <region>CA</region>
          <code>95054</code>
          <country>United States of America</country>
        </postal>
        <email>stripathi@paloaltonetworks.com</email>
      </address>
    </author>
    <date year="2023" month="November"/>
    <area>sec</area>
    <workgroup>ace</workgroup>
		<abstract>
      <t>
					This document specifies the use of the Constrained Application Protocol (CoAP) as a transfer mechanism for the Certificate Management Protocol (CMP). CMP defines the interaction between various PKI entities for the purpose of certificate creation and management. CoAP is an HTTP-like client-server protocol used by various constrained devices in the Internet of Things space. 
      </t>
    </abstract>
  </front>
  <middle>
    <section anchor="sect-1" numbered="true" toc="default">
      <name>Introduction</name>
      <t>
				The Certificate Management Protocol (CMP)
				<xref target="RFC4210" format="default"/>
				is used by the PKI entities for the generation and management of certificates. One of the requirements of CMP is to be independent of the transport protocol in use. CMP has mechanisms to take care of required transactions, error reporting, and protection of messages.
      </t>
      <t>
				The Constrained Application Protocol (CoAP) defined in <xref target="RFC7252" format="default"/>, <xref target="RFC7959" format="default"/>, and <xref target="RFC8323" format="default"/> is a client-server protocol like HTTP. It is designed to be used by constrained devices over constrained networks. The recommended transport for CoAP is UDP; however, <xref target="RFC8323" format="default"/> specifies the support of CoAP over TCP, TLS, and WebSockets.
      </t>
      <t>
				This document specifies the use of CoAP over UDP as a transport medium for
				<xref target="RFC4210" format="default">CMP version 2</xref>, <xref target="RFC9480" format="default"> CMP version 3 </xref> (designated as CMP in this document), and the <xref target="RFC9483" format="default">Lightweight CMP Profile</xref>. In general, this document follows the HTTP transfer for CMP specifications defined in <xref target="RFC6712" format="default"/> and specifies the requirements for using CoAP as a transfer mechanism for CMP.
      </t>
      <t>
This document also provides guidance on how to use a "CoAP-to-HTTP" proxy to ease adoption of a CoAP transfer mechanism by enabling the interconnection with existing PKI entities already providing CMP over HTTP.
      </t>
      <section numbered="true" toc="default">
        <name>Requirements Language</name>
	        <t>
    The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
    NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
    "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
    described in BCP&nbsp;14 <xref target="RFC2119"/> <xref target="RFC8174"/> 
    when, and only when, they appear in all capitals, as shown here.
        </t>
      </section>
    </section>
    <section anchor="sect-2" numbered="true" toc="default">
      <name>CoAP Transfer Mechanism for CMP</name>
      <t>
				A CMP transaction consists of exchanging PKIMessages
				<xref target="RFC4210" format="default"/>
				between PKI end entities (EEs), registration authorities (RAs), and certification authorities (CAs). If the EEs are constrained devices, then they may prefer, as a CMP client, the use of CoAP instead of HTTP as the transfer mechanism. 
				In general, the RAs and CAs are not constrained and can support both CoAP and HTTP client and server implementations. 
				This section specifies how to use CoAP as the transfer mechanism for CMP.
      </t>
      <section anchor="sect-2.1" numbered="true" toc="default">
        <name>CoAP URI Format</name>
        <t>
					The CoAP URI format is described in <xref target="RFC7252" section="6" sectionFormat="of" format="default"/>. The CoAP endpoints <bcp14>MUST</bcp14> support use of the path prefix "/.well-known/" as defined in
					<xref target="RFC8615" format="default"/>
					and the registered name "cmp" to help with endpoint discovery and interoperability. Optional path segments <bcp14>MAY</bcp14> be added after the registered application name (i.e., after "/.well-known/cmp") to provide distinction. The path
					segment 'p' followed by an arbitraryLabel  &lt;name&gt; could, for example, support the differentiation of specific CAs or certificate profiles. Further path segments, for example, as specified in <xref target="RFC9483">Lightweight CMP Profile</xref>, could indicate PKI management operations using an operationLabel &lt;operation&gt;. A valid full CMP URI can look like this:
        </t>
        <artwork name="" type="" align="left" alt=""><![CDATA[				
    coap://www.example.com/.well-known/cmp
    coap://www.example.com/.well-known/cmp/<operation>
    coap://www.example.com/.well-known/cmp/p/<profileLabel>
    coap://www.example.com/.well-known/cmp/p/<profileLabel>/<operation>
					]]></artwork>
      </section>
      <section anchor="sect-2.2" numbered="true" toc="default">
        <name>Discovery of CMP RA/CA</name>
        <t>
					The EEs can be configured with enough information to form the CMP server URI. The minimum information that can be configured is the scheme, i.e., "coap:" or "coaps:", and the authority portion of the URI, e.g., "example.com:5683". If the port number is not specified in the authority, then the default port numbers <bcp14>MUST</bcp14> be assumed for the "coap:" and "coaps:" scheme URIs. The default port for "coap:" scheme URIs is 5683 and the default port for "coaps:" scheme URIs is 5684 <xref target="RFC7252" format="default"/>.
        </t>
        <t>
					Optionally, in the environments where a Local RA or CA is deployed, EEs can also use the CoAP service discovery mechanism	<xref target="RFC7252" format="default"/> to discover the URI of the Local RA or CA. The CoAP CMP endpoints supporting service discovery <bcp14>MUST</bcp14> also support resource discovery in the Constrained RESTful Environments (CoRE) Link Format, as described in <xref target="RFC6690" format="default"/>. The link <bcp14>MUST</bcp14> include the 'ct' attribute defined in <xref target="RFC7252" section="7.2.1" sectionFormat="of" format="default"/> with the value of "application/pkixcmp", as defined in the "CoAP Content-Formats" IANA registry.
        </t>
      </section>
      <section anchor="sect-2.3" numbered="true" toc="default">
        <name>CoAP Request Format</name>
        <t>
					The CMP PKIMessages <bcp14>MUST</bcp14> be DER encoded and sent as the body of the CoAP POST request. A CMP client <bcp14>MUST</bcp14> send each CoAP request marked as a Confirmable message <xref target="RFC7252" format="default"/>. If the CoAP request is successful, then the CMP RA or CA <bcp14>MUST</bcp14> return a Success 2.xx response code; otherwise, the CMP RA or CA <bcp14>MUST</bcp14> return an appropriate Client Error 4.xx or Server Error 5.xx response code. A CMP RA or CA may choose to send a piggybacked response <xref target="RFC7252" format="default"/> to the client, or it <bcp14>MAY</bcp14> send a separate response <xref target="RFC7252" format="default"/> in case it takes some time for the RA or CA to process the CMP transaction.
        </t>
        <t>
		            When transferring CMP PKIMessage over CoAP, the content-format "application/pkixcmp" <bcp14>MUST</bcp14> be used. 
        </t>
      </section>
      <section anchor="sect-2.4" numbered="true" toc="default">
        <name>CoAP Block-Wise Transfer Mode</name>
        <t>
					A CMP PKIMessage consists of a header, body, protection, and extraCerts structure, which may contain many optional and potentially large fields. Thus, a CMP message can be much larger than the Maximum Transmission Unit (MTU) of the outgoing interface of the device. The EEs and RAs or CAs <bcp14>MUST</bcp14> use the block-wise transfer mode
					<xref target="RFC7959" format="default"/> to transfer such large messages instead of relying on IP fragmentation.
        </t>
        <t>
					If a CoAP-to-HTTP proxy is in the path between EEs and an RA or EEs and a CA and if the server supports, then it <bcp14>MUST</bcp14> use the chunked transfer encoding <xref target="RFC9112" format="default"/> to send data over the HTTP transport. The proxy <bcp14>MUST</bcp14> try to reduce the number of packets sent by using an optimal chunk length for the HTTP transport.
        </t>
      </section>
      <section anchor="sect-2.5" numbered="true" toc="default">
        <name>Multicast CoAP</name>
        <t>
		    CMP PKIMessages sent over CoAP <bcp14>MUST NOT</bcp14> use a Multicast destination address.
        </t>
      </section>
      <section anchor="sect-2.6" numbered="true" toc="default">
        <name>Announcement PKIMessage</name>
        <t>
					A CMP server may publish announcements that can be  triggered by an event or periodically for the other PKI entities. 
					Here is the list of CMP announcement messages prefixed by their respective ASN.1 identifier (see <xref target="RFC4210" format="default" sectionFormat="of" section="5.1.2"/>):
        </t>
        <artwork name="" type="" align="left" alt=""><![CDATA[
      [15] CA Key Update Announcement
      [16] Certificate Announcement
      [17] Revocation Announcement
      [18] CRL Announcement
					]]></artwork>
        <t>
					An EE <bcp14>MAY</bcp14> use the CoAP Observe Option <xref target="RFC7641" format="default"/> to register itself to get any announcement messages from the RA or CA. The EE can send a GET request to the server's URI suffixed by "/ann". For example, a path to register for announcement messages may look like this:
        </t>
        <artwork name="" type="" align="left" alt=""><![CDATA[
    coap://www.example.com/.well-known/cmp/ann
    coap://www.example.com/.well-known/cmp/p/<profileLabel>/ann
						]]></artwork>
        <t>
					If the server supports CMP announcement messages, then it <bcp14>MUST</bcp14> send an appropriate Success 2.xx response code; otherwise, it <bcp14>MUST</bcp14> send an appropriate Client Error 4.xx or Server Error 5.xx response code. If for some reason the server cannot add the client to its list of observers for the announcements, it can omit the Observe Option <xref target="RFC7641" format="default"/> in the response to the client. Upon receiving a Success 2.xx response without the Observe Option <xref target="RFC7641" format="default"/>, after some time, a client <bcp14>MAY</bcp14> try to register again for announcements from the CMP server. Since a server can remove the EE from the list of observers for announcement messages, an EE <bcp14>SHOULD</bcp14> periodically reregister itself for announcement messages.
        </t>
        <t>
                    Alternatively, an EE <bcp14>MAY</bcp14> periodically poll for the current status of the CA via the "PKI Information Request" message; see <xref target="RFC4210" section="6.5" sectionFormat="of" format="default"/>. If supported, EEs <bcp14>MAY</bcp14> also use "support messages" defined in <xref target="RFC9483" section="4.3" sectionFormat="of" format="default">Lightweight CMP Profile</xref> to get information about the CA status.
					These mechanisms will help constrained devices that are acting as EEs to conserve resources by eliminating the need to create an endpoint for receiving notifications from the RA or CA. It will also simplify the implementation of a CoAP-to-HTTP proxy.
        </t>
      </section>
    </section>
    <section anchor="sect-3" numbered="true" toc="default">
      <name>Proxy Support</name>
      <t>
				This section provides guidance on using a CoAP-to-HTTP proxy between EEs and RAs or CAs in order to avoid changes to the existing PKI implementation. </t>
      <t>
				 Since the CMP payload is the same over CoAP and HTTP transfer mechanisms, a CoAP-to-HTTP cross-protocol proxy can be implemented based on <xref target="RFC7252" section="10" sectionFormat="of" format="default"/>. The CoAP-to-HTTP proxy can either be located closer to the EEs or closer to the RA or CA. The proxy <bcp14>MAY</bcp14> support service discovery and resource discovery, as described in <xref target="sect-2.2"/>. The CoAP-to-HTTP proxy <bcp14>MUST</bcp14> function as a reverse proxy, only permitting connections to a limited set of preconfigured servers. It is out of scope of this document to specify how a reverse proxy can route CoAP client requests to one of the configured servers. Some recommended mechanisms are as follows:
      </t>
      <ul spacing="normal">
        <li>Use the Uri-Path option to identify a server.</li>
        <li>Use separate hostnames for each of the configured servers and then use the Uri-Host option for routing the CoAP requests.</li>
        <li>Use separate hostnames for each of the configured servers and then use Server Name Indication <xref target="RFC8446" format="default"/> in case of the "coaps://" scheme for routing CoAP requests.</li>
      </ul>
      <t/>
    </section>
    <section anchor="sect-4" numbered="true" toc="default">
      <name>Security Considerations</name>
      <ul spacing="compact">
        <li>
                If PKIProtection is used, the PKIHeader and PKIBody of the CMP are cryptographically protected against malicious modifications. As such, UDP can be used without compromising the security of the CMP. Security considerations for CoAP are defined in <xref target="RFC7252" format="default"/>.
            </li>
        <li>
                The CMP does not provide confidentiality of the CMP payloads. If confidentiality is desired, CoAP over DTLS <xref target="RFC9147" format="default"/> <bcp14>SHOULD</bcp14> be used to provide confidentiality for the CMP payloads; although, it cannot conceal that the CMP is used within the DTLS layer.
			</li>
        <li> 
				<xref target="RFC7252" section="9.1" sectionFormat="of" format="default"/> defines how to use DTLS <xref target="RFC9147" format="default"/> for securing CoAP. DTLS <xref target="RFC9147" format="default"/> associations <bcp14>SHOULD</bcp14> be kept alive and reused where possible to amortize on the additional overhead of DTLS on constrained devices.
			</li>
        <li>
                 An EE might not witness all of the announcement messages when using the CoAP Observe Option <xref target="RFC7641" format="default"/>, since the Observe Option is a "best-effort" approach and the server might lose its state for subscribers to its announcement messages. The EEs may use an alternate method described in <xref target="sect-2.6"/> to obtain time critical changes, such as Certificate Revocation List (CRL) <xref target="RFC5280" format="default"/> updates. 
			</li>
        <li> 
				Implementations <bcp14>SHOULD</bcp14> use the available datagram size and avoid sending small datagrams containing partial CMP PKIMessage data in order to reduce memory usage for packet buffering. 
			</li>
        <li>
				A CoAP-to-HTTP proxy can also protect the PKI entities by handling UDP and CoAP messages. The proxy can mitigate attacks, like denial-of-service attacks, replay attacks, and resource-exhaustion attacks, by enforcing basic checks, like validating that the ASN.1 syntax is compliant to CMP messages and validating the PKIMessage protection before sending them to PKI entities. 
			</li>
        <li> 
				Since the proxy may have access to the CMP-level metadata and control over the flow of CMP messages, proper role-based access control should be in place. The proxy can be deployed at the edge of the "end entities" network or in front of an RA and CA to protect them. However, the proxy may itself be vulnerable to resource-exhaustion attacks as it's required to buffer the CMP messages received over CoAP transport before sending it to the HTTP endpoint. This can be mitigated by using short timers for discarding the buffered messages and rate limiting clients based on the resource usage.
			</li>
      </ul>
    </section>
    <section anchor="sect-5" numbered="true" toc="default">
      <name>IANA Considerations</name>
<!-- Note: IANA removed the "Content Coding text from CoAP Content-Format 259" based on feedback from the DE. -->
      <t>
		IANA has registered "application/pkixcmp" (ID 259) in the <eref target="https://www.iana.org/assignments/core-parameters" brackets="angle">"CoAP Content-Formats" registry</eref> to transfer CMP transactions over CoAP.  
      </t>
      <dl newline="false" spacing="compact">
	<dt>Type name:</dt>
	<dd>application</dd>
	<dt>Subtype name:</dt>
	<dd>pkixcmp</dd>
	<dt>Reference:</dt>
	<dd>RFC 9482
	<xref target="RFC4210" format="default"/></dd>
      </dl>
      <t>IANA has also registered a new path segment "ann" in the <eref target="https://www.iana.org/assignments/cmp" brackets="angle">"CMP Well-Known URI Path Segments" registry</eref> for the EEs to register themselves for the announcement messages.
      </t>
      <dl newline="false" spacing="compact">
	<dt>Path Segment:</dt>
	<dd>ann</dd>
	<dt>Description:</dt>
	<dd>The path to send a GET request with the CoAP Observe Option to register for CMP announcement messages.</dd>
	<dt>Reference:</dt>
	<dd>RFC 9482</dd>
      </dl>
      <t>
                IANA has added this document as a reference for the "cmp" entry in the <eref target="https://www.iana.org/assignments/well-known-uris" brackets="angle">"Well-Known URIs" registry</eref>. 
      </t>
      <t> 
                IANA has also added this document as a reference for the "p" entry in the <eref target="https://www.iana.org/assignments/cmp/" brackets="angle">"CMP Well-Known URI Path Segments" registry</eref>. 
      </t>
    </section>
  </middle>
  <back>
	<references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6712.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4210.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7252.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7959.xml"/>

<reference anchor="RFC9480" target="https://www.rfc-editor.org/info/rfc9480">
<front>
<title>Certificate Management Protocol (CMP) Updates</title>
<author initials='H' surname='Brockhaus' fullname='Hendrik Brockhaus'>
<organization />
</author>
<author initials='D' surname='von Oheimb' fullname='David von Oheimb'>
<organization />
</author>
<author initials="J" surname="Gray" fullname="John Gray">
 <organization/>
</author>
<date year='2023' month='November'/>
</front>
<seriesInfo name="RFC" value="9480"/>
<seriesInfo name="DOI" value="10.17487/RFC9480"/>
</reference>

<reference anchor="RFC9483" target="https://www.rfc-editor.org/info/rfc9483">
<front>
<title>Lightweight Certificate Management Protocol (CMP) Profile</title>
<author initials='H' surname='Brockhaus' fullname='Hendrik Brockhaus'>
<organization />
</author>
<author initials='D' surname='von Oheimb' fullname='David von Oheimb'>
<organization />
</author>
<author initials='S' surname='Fries' fullname='Steffen Fries'>
<organization />
</author>
<date year='2023' month='November'/>
</front>
<seriesInfo name="RFC" value="9483"/>
<seriesInfo name="DOI" value="10.17487/RFC9483"/>
</reference>

        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8615.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6690.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7641.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9147.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9112.xml"/>
      </references>
      <references>
        <name>Informative References</name>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5280.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8446.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8323.xml"/>
      </references>
    </references>
    <section anchor="sect-6" numbered="false" toc="default">
      <name>Acknowledgements</name>
      <t>
		The authors would like to thank <contact fullname="Hendrik Brockhaus"/>, <contact fullname="David von Oheimb"/>, and <contact fullname="Andreas Kretschmer"/> for their guidance in writing the content of this document and providing valuable feedback.
      </t>
    </section>
  </back>
</rfc>
