<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>
&LEGALNOTICE;
<number>0246</number>
<status>Experimental</status>
<type>Standards Track</type>
<sig>Standards</sig>
<approver>Council</approver>
<dependencies>
<spec>XMPP Core</spec>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>NOT_YET_ASSIGNED</shortname>
<registry/>
&stpeter;
<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>
<p>XMPP as defined in &rfc3920; 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>
<p>The first scenario is addressed by &xep0174;. The second and third scenarios are addressed by &xep0247;. 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 (&xep0065;) or XMPP itself (&xep0047;), or other future transport methods such as &ice-tcp;.</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>
<section1topic='Initiating an e2e Stream'anchor='initiate'>
<p>The initiator and recipient essentially follow the process defined in <cite>RFC 3920</cite> to establish XML streams between themselves.</p>
<p>First, the initiator opens an XML stream to the recipient over the negotiated transport.</p>
<examplecaption="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 &rfc3921bis;, the initial stream header SHOULD include the 'to' and 'from' attributes. In the case of <cite>XEP-0174</cite>, 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 &BAREJID; 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 <cite>RFC 3920</cite>, 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>
<p>If both the initiator and recipient included the version='1.0' flag, the recipient SHOULD also send stream features as specified in <cite>RFC 3920</cite>:</p>
<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 &xmppcore; using &rfc4346;, optionally followed by SASL negotiation for mutual authentication (see &rfc4422;).</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 &xep0045; 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 &rfc3920bis;; however, applications of end-to-end XML streams MAY define supplemental guidelines for certificate validation in the context of particular architectures, such as <cite>XEP-0174</cite> 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 &xep0027;, clients using TLS for e2e streams MAY use the OpenPGP TLS extension defined in &rfc5081; (if available).</p>
<p>Use of other TLS extensions MAY be appropriate as well, including those defined in &rfc4346; and &rfc5054;.</p>
<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>
<examplecaption="Sending a Message"><![CDATA[
<messagefrom='romeo@forza'to='juliet@pronto'>
<body>M'lady, I would be pleased to make your acquaintance.</body>
</message>
]]></example>
<examplecaption="A Reply"><![CDATA[
<messagefrom='juliet@pronto'to='romeo@forza'>
<body>Art thou not Romeo, and a Montague?</body>
</message>
]]></example>
</section1>
<section1topic='Ending an e2e Stream'anchor='end'>
<p>To end the stream, either party closes the XML stream:</p>
<examplecaption="Closing the Stream"><![CDATA[
</stream:stream>
]]></example>
<p>The other party then closes the stream in the other direction as well:</p>
<examplecaption="Closing the Stream"><![CDATA[
</stream:stream>
]]></example>
<p>Both parties then SHOULD close the logical or physical connection between them.</p>