<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>End-to-End XML Streams</title>
  <abstract>This specification defines methods for communicating via end-to-end XML streams over a logical or physical connection that provides a reliable transport between two endpoints.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0246</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>NOT_YET_ASSIGNED</shortname>
  
  <author>
    <firstname>Peter</firstname>
    <surname>Saint-Andre</surname>
    <email>stpeter@stpeter.im</email>
    <jid>stpeter@jabber.org</jid>
    <uri>https://stpeter.im/</uri>
  </author>

  <revision>
    <version>0.1.1</version>
    <date>2016-01-20</date>
    <initials>XEP Editor (mam)</initials>
    <remark><p>Updated missing 'ice-tcp' reference to RFC 6544.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2008-06-18</date>
    <initials>psa</initials>
    <remark><p>Initial published version.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2008-06-13</date>
    <initials>psa</initials>
    <remark><p>First draft, split off from XEP-0174.</p></remark>
  </revision>
</header>

<section1 topic="Introduction" anchor="intro">
  <p>XMPP as defined in <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">XMPP Core</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note> does not support direct interaction between endpoints, since it requires a client to authenticate an XML stream with a "home" server and send of all of its outbound XML stanzas through that server (which potentially can route those stanzas through a peer server for delivery to the intended recipient). However, in some scenarios it is desirable to establish end-to-end XML streams between two endpoints instead of relying on the standard client-server architecture. These scenarios include:</p>
  <ul>
    <li>Two endpoints cannot access an XMPP server</li>
    <li>Two endpoints want to enforce end-to-end encryption</li>
    <li>Two endpoints want to send a high volume of XMPP traffic but the intermediate servers enforce rate limits</li>
  </ul>
  <p>The first scenario is addressed by <span class="ref"><link url="https://xmpp.org/extensions/xep-0174.html">Link-Local Messaging (XEP-0174)</link></span> <note>XEP-0174: Link-Local Messaging &lt;<link url="https://xmpp.org/extensions/xep-0174.html">https://xmpp.org/extensions/xep-0174.html</link>&gt;.</note>. The second and third scenarios are addressed by <span class="ref"><link url="https://xmpp.org/extensions/xep-0247.html">Jingle XML Streams (XEP-0247)</link></span> <note>XEP-0247: Jingle XML Streams &lt;<link url="https://xmpp.org/extensions/xep-0247.html">https://xmpp.org/extensions/xep-0247.html</link>&gt;.</note>. Both of those technologies result in the establishment of a direct or mediated connection between two endpoints, such as a direct TCP connection, a bytestream through SOCKS5 (<span class="ref"><link url="https://xmpp.org/extensions/xep-0065.html">SOCKS5 Bytestreams (XEP-0065)</link></span> <note>XEP-0065: SOCKS5 Bytestreams &lt;<link url="https://xmpp.org/extensions/xep-0065.html">https://xmpp.org/extensions/xep-0065.html</link>&gt;.</note>) or XMPP itself (<span class="ref"><link url="https://xmpp.org/extensions/xep-0047.html">In-Band Bytestreams (XEP-0047)</link></span> <note>XEP-0047: In-Band Bytestreams &lt;<link url="https://xmpp.org/extensions/xep-0047.html">https://xmpp.org/extensions/xep-0047.html</link>&gt;.</note>), or other future transport methods such as <span class="ref"><link url="http://tools.ietf.org/html/rfc6544">RFC 6544</link></span> <note>RFC 6544: TCP Candidates with Interactive Connectivity Establishment (ICE) &lt;<link url="http://tools.ietf.org/html/rfc6544">http://tools.ietf.org/html/rfc6544</link>&gt;.</note>.</p>
  <p>Once two endpoints have opened a direct or mediated connection, they can establish an XML stream over that connection for end-to-end "("e2e") communication. We call this an "e2e stream".</p>
</section1>

<section1 topic="Initiating an e2e Stream" anchor="initiate">
  <p>The initiator and recipient essentially follow the process defined in <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">RFC 6120</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note> to establish XML streams between themselves.</p>
  <p>First, the initiator opens an XML stream to the recipient over the negotiated transport.</p>
  <example caption="Opening a Stream"><![CDATA[
<stream:stream
        xmlns='jabber:client'
        xmlns:stream='http://etherx.jabber.org/streams'
        from='romeo@forza'
        to='juliet@pronto'
        version='1.0'>
]]></example>
  <p>In accordance with <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">RFC 6120</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note>, the initial stream header SHOULD include the 'to' and 'from' attributes. In the case of <span class="ref"><link url="https://xmpp.org/extensions/xep-0174.html">Link-Local Messaging (XEP-0174)</link></span> <note>XEP-0174: Link-Local Messaging &lt;<link url="https://xmpp.org/extensions/xep-0174.html">https://xmpp.org/extensions/xep-0174.html</link>&gt;.</note>, these SHOULD be the username@machine-name advertised in the PTR record. In the case of <cite>Jingle XML Streams</cite>, these SHOULD be the bare JIDs (&lt;localpart@domain.tld&gt; or &lt;domain.tld&gt;) of the entities as communicated via XMPP.</p>
  <p>If the initiator supports stream features and the other stream-related aspects of XMPP 1.0 as specified in <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">RFC 6120</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note>, then it SHOULD include the version='1.0' flag as shown in the previous example.</p>
  <p>The recipient then responds with a stream header as well:</p>
  <example caption="Stream Header Response"><![CDATA[
<stream:stream
        xmlns='jabber:client'
        xmlns:stream='http://etherx.jabber.org/streams'
        from='juliet@pronto'
        to='romeo@forza'
        version='1.0'>
]]></example>
  <p>If both the initiator and recipient included the version='1.0' flag, the recipient SHOULD also send stream features as specified in <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">RFC 6120</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note>:</p>
  <example caption="Recipient Sends Stream Features"><![CDATA[
<stream:features>
  <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
</stream:features>
]]></example>
</section1>

<section1 topic="Stream Encryption" anchor="encryption">
  <p>The mere exchange of stream headers results in an unencrypted and unauthenticated channel between the two entities. The entities SHOULD upgrade the channel to an encrypted stream using the XMPP STARTTLS command defined in <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">XMPP Core</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note> using <span class="ref"><link url="http://tools.ietf.org/html/rfc5246">RFC 5246</link></span> <note>RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 &lt;<link url="http://tools.ietf.org/html/rfc5246">http://tools.ietf.org/html/rfc5246</link>&gt;.</note>, optionally followed by SASL negotiation for mutual authentication (see <span class="ref"><link url="http://tools.ietf.org/html/rfc4422">RFC 4422</link></span> <note>RFC 4422: Simple Authentication and Security Layer (SASL) &lt;<link url="http://tools.ietf.org/html/rfc4422">http://tools.ietf.org/html/rfc4422</link>&gt;.</note>).</p>
  <p>End-to-end XML streams can be negotiated between two XMPP clients, between an XMPP client and a remote XMPP service (i.e., a service with which a client does not have a direct XML stream, such as a remote <span class="ref"><link url="https://xmpp.org/extensions/xep-0045.html">Multi-User Chat (XEP-0045)</link></span> <note>XEP-0045: Multi-User Chat &lt;<link url="https://xmpp.org/extensions/xep-0045.html">https://xmpp.org/extensions/xep-0045.html</link>&gt;.</note> room), or between two remote XMPP services. Therefore, if standard X.509 certificates are used then a party to an e2e XML stream will present either a client certificate or a server certificate as appropriate. If X.509 certificates are used, they MUST at a minimum be generated and validated in accordance with the certificate guidelines guidelines provided in <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">RFC 6120</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note>; however, applications of end-to-end XML streams MAY define supplemental guidelines for certificate validation in the context of particular architectures, such as <span class="ref"><link url="https://xmpp.org/extensions/xep-0174.html">Link-Local Messaging (XEP-0174)</link></span> <note>XEP-0174: Link-Local Messaging &lt;<link url="https://xmpp.org/extensions/xep-0174.html">https://xmpp.org/extensions/xep-0174.html</link>&gt;.</note> for link-local streams and <cite>XEP-0247</cite> for direct or mediated streams negotiated through XMPP servers.</p>
  <p>To ease the transition from the PGP-based object encryption method specified in <span class="ref"><link url="https://xmpp.org/extensions/xep-0027.html">Current Jabber OpenPGP Usage (XEP-0027)</link></span> <note>XEP-0027: Current Jabber OpenPGP Usage &lt;<link url="https://xmpp.org/extensions/xep-0027.html">https://xmpp.org/extensions/xep-0027.html</link>&gt;.</note>, clients using TLS for e2e streams MAY use the OpenPGP TLS extension defined in <span class="ref"><link url="http://tools.ietf.org/html/rfc5081">RFC 5081</link></span> <note>RFC 5081: Using OpenPGP Keys for Transport Layer Security (TLS) Authentication &lt;<link url="http://tools.ietf.org/html/rfc5081">http://tools.ietf.org/html/rfc5081</link>&gt;.</note> (if available).</p>
  <p>Use of other TLS extensions MAY be appropriate as well, including those defined in <span class="ref"><link url="http://tools.ietf.org/html/rfc5246">RFC 5246</link></span> <note>RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 &lt;<link url="http://tools.ietf.org/html/rfc5246">http://tools.ietf.org/html/rfc5246</link>&gt;.</note> and <span class="ref"><link url="http://tools.ietf.org/html/rfc5054">RFC 5054</link></span> <note>RFC 5054: Using the Secure Remote Password (SRP) Protocol for TLS Authentication &lt;<link url="http://tools.ietf.org/html/rfc5054">http://tools.ietf.org/html/rfc5054</link>&gt;.</note>.</p>
</section1>

<section1 topic="Exchanging Stanzas" anchor="exchange">
  <p>Once the streams are established, either entity then can send XMPP message, presence, and IQ stanzas, with or without 'to' and 'from' addresses.</p>
  <example caption="Sending a Message"><![CDATA[
<message from='romeo@forza' to='juliet@pronto'>
  <body>M'lady, I would be pleased to make your acquaintance.</body>
</message>
]]></example>
  <example caption="A Reply"><![CDATA[
<message from='juliet@pronto' to='romeo@forza'>
  <body>Art thou not Romeo, and a Montague?</body>
</message>
]]></example>
</section1>

<section1 topic="Ending an e2e Stream" anchor="end">
  <p>To end the stream, either party closes the XML stream:</p>
  <example caption="Closing the Stream"><![CDATA[
</stream:stream>
]]></example>
  <p>The other party then closes the stream in the other direction as well:</p>
  <example caption="Closing the Stream"><![CDATA[
</stream:stream>
]]></example>
  <p>Both parties then SHOULD close the logical or physical connection between them.</p>
</section1>

<section1 topic="Security Considerations" anchor="security">
  <p>End-to-end streams SHOULD be encrypted; see the <link url="#encrytion">Stream Encryption</link> section of this document.</p>
</section1>

<section1 topic="IANA Considerations" anchor="iana">
  <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
</section1>

<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <p>This document requires no interaction with the <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note>.</p>
</section1>

</xep>
