<?xml version="1.0" encoding="US-ASCII"?>
<!-- change the "txt" on the previous line to "xml" to make this a valid XML2RFC template -->
<!-- this is version 5 of this xml2rfc template -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
	<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
	<!ENTITY RFC8174 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml">
	<!ENTITY RFC4210 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4210.xml">
	<!ENTITY RFC6712 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6712.xml">
	<!ENTITY RFC7252 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7252.xml">
	<!ENTITY RFC7959 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7959.xml">
	<!ENTITY RFC8446 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8446.xml">
	<!ENTITY RFC8323 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8323.xml">
	<!ENTITY RFC8615 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8615.xml">
	<!ENTITY RFC6690 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6690.xml">
	<!ENTITY RFC5280 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5280.xml">
	<!ENTITY RFC7641 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7641.xml">
	<!ENTITY RFC9147 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.9147.xml">
	<!ENTITY RFC9112 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.9112.xml">
	<!ENTITY I-D.ietf-lamps-lightweight-cmp-profile SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-lamps-lightweight-cmp-profile-13.xml">
	<!ENTITY I-D.ietf-lamps-cmp-updates SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-lamps-cmp-updates-23.xml">
]>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc strict="no"?>
<?rfc rfcedstyle="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>

<rfc category="std" docName="draft-ietf-ace-cmpv2-coap-transport-08" ipr="trust200902">
	<front>

		<title abbrev="CoAP Transfer for the CMP">CoAP Transfer for the Certificate Management Protocol</title>

		<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>US</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>US</country>
				</postal>
				<email>stripathi@paloaltonetworks.com</email>
			</address>
		</author>
		<!-- month and day will be generated automatically by XML2RFC; 
be sure the year is current.-->

		<date year="2023" />

		<!-- IETF area is optional -->

		<area>Authentication and Authorization for Constrained Environments</area>

		<!--WG name at the upperleft corner of the doc, 
IETF is fine for non-WG IETF submissions -->

		<workgroup>ACE</workgroup>

		<!--add additional keywords here for IETF website search engine -->
		<abstract>

			<t>
					This document specifies the use of 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 IoT space. 
			</t>

		</abstract>
	</front>

	<middle>
		<section title="Introduction" anchor="sect-1">
			<t>
				The Certificate Management Protocol (CMP)
				<xref target="RFC4210" />
				is used by the PKI entities for the generation and management of certificates. One of the requirements of Certificate Management Protocol 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" /> , <xref target="RFC7959" /> and <xref target="RFC8323" /> 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" /> 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 the CMP version 2
				<xref target="RFC4210" />
				,
				<xref target="I-D.ietf-lamps-cmp-updates"> CMP version 3 </xref>
				designated as CMP in this document and
				<xref target="I-D.ietf-lamps-lightweight-cmp-profile">Lightweight CMP Profile</xref>
				. This document, in general, follows the HTTP transfer for CMP specifications defined in
				<xref target="RFC6712" />
				and specifies the requirements for using CoAP as a transfer mechanism for the CMP.
			</t>
			<t>
This document also provides guidance on how to use a "CoAP-to-HTTP" proxy to ease adoption of CoAP transfer mechanism by enabling the interconnection with existing PKI entities already providing CMP over HTTP.
			</t>
			<section title="Terminology">
				<t>
					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
					<xref target="RFC2119" />
					<xref target="RFC8174" />
					when, and only when, they appear in all capitals, as shown here.
				</t>
			</section>
		</section>
		<section title="CoAP Transfer Mechanism for CMP" anchor="sect-2">
			<t>
				A CMP transaction consists of exchanging PKIMessages
				<xref target="RFC4210" />
				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. 
				The RAs and CAs, in general, 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 the Certificate Management Protocol.
			</t>
			<section title="CoAP URI Format" anchor="sect-2.1">
				<t>
					The CoAP URI format is described in section 6 of <xref target="RFC7252" />. The CoAP endpoints MUST support use of the path prefix "/.well-known/" as defined in
					<xref target="RFC8615" />
					and the registered name "cmp" to help with endpoint discovery and interoperability. Optional path segments MAY 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, e.g., as specified in the Lightweight CMP Profile [I-D.ietf-lamps-lightweight-cmp-profile], could indicate PKI management operations using an operationLabel &lt;operation&gt;. A valid full CMP URI can look like this:
				</t>
				<figure>
					<artwork>
						<![CDATA[
    coap://www.example.com/.well-known/cmp
    coap://www.example.com/.well-known/cmp/<operation>
    coap://www.example.com/.well-known/cmp/p/<name>
    coap://www.example.com/.well-known/cmp/p/<name>/<operation>
]]>
					</artwork>
				</figure>
			</section>
			<section title="Discovery of CMP RA/CA" anchor="sect-2.2">
				<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 ports numbers MUST be assumed for the "coap:" and the "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" />
					.
				</t>
				<t>
					Optionally, in the environments where a Local Registration Authority (LRA) or a Local CA is deployed, EEs can also use the CoAP service discovery mechanism
					<xref target="RFC7252" />
					to discover the URI of the Local RA or CA. The CoAP CMP endpoints supporting service discovery MUST also support resource discovery in the CoRE Link Format as described in
					<xref target="RFC6690" />
					. The Link MUST include the 'ct' attribute defined in section 7.2.1 of
					<xref target="RFC7252" />
					with the value of "application/pkixcmp" as defined in the CoAP Content-Formats IANA registry.
				</t>
			</section>
			<section title="CoAP Request Format" anchor="sect-2.3">
				<t>
					The CMP PKIMessages MUST be DER encoded and sent as the body of the CoAP POST request. A CMP client MUST send each CoAP requests marked as a Confirmable message <xref target="RFC7252" />. If the CoAP request is successful then the server MUST return a Success 2.xx response code otherwise server MUST 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" /> to the client or it MAY send a Separate response <xref target="RFC7252" /> in case it takes some time for CA or RA to process the CMP transaction.
				</t>
				<t>
		            When transferring CMP PKIMesssage over CoAP the content-format "application/pkixcmp" MUST be used. 
		        </t>
			</section>
			<section title="CoAP Block-Wise Transfer Mode" anchor="sect-2.4">
				<t>
					A CMP PKIMesssage consists of a header, body, protection, and extraCerts structures 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, MUST use the Block-Wise transfer mode
					<xref target="RFC7959" />
					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 CA or EEs and RA then, if the server supports, it MUST use the chunked transfer encoding <xref target="RFC9112" /> to send data over the HTTP transport. The proxy MUST try to reduce the number of packets sent by using an optimal chunk length for the HTTP transport.
				</t>
			</section>
			<section title="Multicast CoAP" anchor="sect-2.5">
				<t>
		    CMP PKIMessages sent over CoAP MUST NOT use a Multicast destination address.
		    </t>
			</section>

			<section title="Announcement PKIMessage" anchor="sect-2.6">
				<t>
					A CMP server may publish announcements, that can be event triggered or periodic, for the other PKI entities. 
					Here is the list of CMP announcement messages prefixed by their respective ASN.1 identifier (section 5.1.2 <xref target="RFC4210"/>)
				</t>
				<figure>
					<artwork>
						<![CDATA[
      [15] CA Key Update Announcement
      [16] Certificate Announcement
      [17] Revocation Announcement
      [18] CRL Announcement

]]>
					</artwork>
				</figure>
				<t>
					An EE MAY use CoAP Observe option <xref target="RFC7641" /> 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:
					<figure>
						<artwork>
							<![CDATA[
    coap://www.example.com/.well-known/cmp/ann
    coap://www.example.com/.well-known/cmp/p/<profileLabel>/ann
]]>
						</artwork>
					</figure>
					If the server supports CMP Announcements messages, then it MUST send appropriate Success 2.xx response code, otherwise it MUST send an appropriate Client Error 4.xx or Server Error 5.xx response code. If for some reason server cannot add the client to its list of observers for the announcements, it can omit the Observe option <xref target="RFC7641" /> in the response to the client. A client on receiving a 2.xx success response without the Observe option <xref target="RFC7641" /> MAY try after some time to register again for announcements from the CMP server. Since server can remove the EE from the list of observers for announcement messages, an EE SHOULD periodically re-register itself for announcement messages.
				</t>
				<t>
                    Alternatively, an EE MAY periodically poll for the current status of the CA via the "PKI Information Request" message, see section 6.5 of <xref target="RFC4210" />. If supported, EEs may also use "Support Messages" defined in section 4.3 of <xref target="I-D.ietf-lamps-lightweight-cmp-profile">Lightweight CMP Profile</xref> to get information about the CA status.
				</t>
				<t>
					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 RA or CA. It will also simplify the implementation of a CoAP-to-HTTP proxy.
				</t>
			</section>
		</section>
		<section title="Proxy Support" anchor="sect-3">
			<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. Since the CMP payload is same over CoAP and HTTP transfer mechanisms, a CoAP-to-HTTP cross-protocol proxy can be implemented based on section 10 of <xref target="RFC7252" />.
			</t>
			<t>
				The CoAP-to-HTTP proxy can either be located closer to the EEs or closer to the RA or CA. The proxy MAY support service discovery and resource discovery as described in section 2.2. The CoAP-to-HTTP proxy MUST function as a reverse proxy, only permitting connections to a limited set of pre-configured servers. It is out of scope of this document on how a reverse proxy can route CoAP client requests to one of the configured servers. Some recommended mechanisms are as follows:
			</t>
			<t>
				<list style="symbols">
					<?rfc subcompact="yes"?>
					<t>
						Use the Uri-Path option to identify a server.
					</t>
					<t>
						Use separate hostnames for each of the configured servers and then use the Uri-Host option for routing the CoAP requests.
					</t>
					<t>
						Use separate hostnames for each of the configured servers and then use Server Name Indication <xref target="RFC8446" /> in case of "coaps://" scheme for routing CoAP requests.
					</t>
				</list>
			</t>
			<t></t>
		</section>
		<section title="Security Considerations" anchor="sect-4">
		<list style="symbols">

			<t>
                If PKIProtection is used, the PKIHeader and PKIBody of the CMP protocol are cryptographically protected against malicious modifications. As such, UDP can be used without compromising the security of the CMP protocol. Security Considerations for CoAP are defined in <xref target="RFC7252" />.
            </t>

			<t>
                The CMP protocol does not provide confidentiality of the CMP payloads. If confidentiality is desired, CoAP over DTLS <xref target="RFC9147"/> MAY be used to provide confidentiality for the CMP payloads, although it cannot conceal that the CMP protocol is used within the DTLS layer.
			</t>
			<t> 
				Section 9.1 of <xref target="RFC7252" /> defines how to use DTLS <xref target="RFC9147" /> for securing the CoAP. DTLS <xref target="RFC9147" /> associations SHOULD be kept alive and re-used where possible to amortize on the additional overhead of DTLS on constrained devices.
			</t>

			<t>
                 An EE might not witness all of the Announcement messages when using the CoAP Observe option <xref target="RFC7641" />, 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 section 2.6 to obtain time critical changes such as CRL updates. 
			</t>
			<t> 
				Implementations SHOULD use the available datagram size and avoid small datagrams containing partial CMP PKIMessage data in order to reduce memory usage for packet buffering. 
			</t>
			<t>
				A CoAP-to-HTTP proxy can also protect the PKI entities by handling UDP and CoAP messages. 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. 
			</t>
			<t> 
				Since the Proxy may have access to the CMP-Level metadata and control over the flow of CMP messages therefore proper role based access control should be in place. Proxy can be deployed at the edge of the "End Entities" network or in front of an RA and CA to protect them. The proxy however 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.
			</t>
			</list>
		</section>
		<section title="IANA Considerations" anchor="sect-5">
			<t>
					This document adds a new entry to the CoAP Content-Formats Registry code for the content-type "application/pkixcmp" for transferring CMP transactions over CoAP from the identifier range 256-9999 reserved for IETF specifications.
			</t>
			<t>
		Type name: application
	</t>
	<t>
		Subtype name: pkixcmp
	</t>
			<t>
				Encoding: Content may contain arbitrary octet values. The octet values are the ASN.1 DER encoding of a PKI message, as defined in the
				<xref target="RFC4210" />
				specifications.
			</t>
			<t>
				Reference: This document and
				<xref target="RFC4210" />
			</t>
			<t>
					This document also adds a new path segment "ann" to the CMP protocol registry for the EEs to register themselves for the announcement messages.
			</t>
			<t>
				Path Segment: ann
			</t>
			<t>
				Description: The path to send a GET request with CoAP Observer Option to register for CMP announcement messages. 
			</t>
			<t>
				Reference: This document.
			</t>

			<t>
                This document references the cmp, in the <eref target="https://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml">Well-Known URIs</eref> IANA registry. Please add a reference of this document to the <eref target="https://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml">Well-Known URIs</eref> IANA registry for that entry.

			</t>
			<t> 
                This document also refers the path segment "p" in the <eref target="https://www.iana.org/assignments/cmp/cmp.xhtml">Certificate Management Protocol (CMP)</eref> IANA registry. Please add a reference of this document to the <eref target="https://www.iana.org/assignments/cmp/cmp.xhtml">Certificate Management Protocol (CMP)</eref> for that path segment.
			</t>
            <t>
            [Note RFC Editor]: This document should be published together or after the <xref target="I-D.ietf-lamps-cmp-updates"> CMP version 3 </xref> as it references IANA entries created by that Internet draft.

            </t>
		</section>

		<section title="Acknowledgments" anchor="sect-6">
			<t>
		The authors would like to thank Hendrik Brockhaus, David von Oheimb, and Andreas Kretschmer for their guidance in writing the content of this document and providing valuable feedback.
	</t>
		</section>
	</middle>

	<back>

		<!-- References Section -->
	<references title="Normative References">
        &RFC2119;
        &RFC8174;
        &RFC6712;
        &RFC4210;
        &RFC7252;
        &RFC7959;
        &I-D.ietf-lamps-cmp-updates;
        &I-D.ietf-lamps-lightweight-cmp-profile;
        &RFC8615;
        &RFC6690;
        &RFC7641;
        &RFC9147;
        &RFC9112;
    </references>
	<references title="Informative References">
        &RFC5280;
        &RFC8446;
        &RFC8323;
    </references>
	</back>
</rfc>
