<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Discovering Alternative XMPP Connection Methods</title>
  <abstract>This document defines an XMPP Extension Protocol for discovering alternative methods of connecting to an XMPP server via Web Host Metadata Link format.</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>0156</number>
  <status>Draft</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>RFC 1464</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>alt-connections</shortname>
  <registry/>
  
  <author>
    <firstname>Joe</firstname>
    <surname>Hildebrand</surname>
    <email>jhildebr@cisco.com</email>
    <jid>hildjj@jabber.org</jid>
  </author>

  
  <author>
    <firstname>Peter</firstname>
    <surname>Saint-Andre</surname>
    <email>stpeter@stpeter.im</email>
    <jid>stpeter@jabber.org</jid>
    <uri>https://stpeter.im/</uri>
  </author>

  
  <author>
    <firstname>Lance</firstname>
    <surname>Stout</surname>
    <email>lance@andyet.com</email>
    <jid>lance@lance.im</jid>
  </author>

  <revision>
    <version>1.4.0</version>
    <date>2022-02-10</date>
    <initials>tjb</initials>
    <remark><p>Remove DNS _xmppconnect method due to security vulnerability.</p></remark>
  </revision>
  <revision>
    <version>1.3.1</version>
    <date>2020-07-07</date>
    <initials>adiaholic</initials>
    <remark><p>Include all described formats in the abstract, instead of just mentioning the TXT record format.</p></remark>
  </revision>
  <revision>
    <version>1.3.0</version>
    <date>2020-06-23</date>
    <initials>fs</initials>
    <remark><p>Fix reference to RFC 6415 and organize requirements more clearly. This raises the JSON requirement from MAY (OPTIONAL) to SHOULD (effectively), to accustom web-based software.</p></remark>
  </revision>
  <revision>
    <version>1.2.0</version>
    <date>2019-02-20</date>
    <initials>wk</initials>
    <remark><p>Add information about CORS header usage and requirements</p></remark>
  </revision>
  <revision>
    <version>1.1.5</version>
    <date>2018-09-30</date>
    <initials>jsc</initials>
    <remark><p>Make JSON example less error-prone.</p></remark>
  </revision>
  <revision>
    <version>1.1.4</version>
    <date>2018-09-30</date>
    <initials>jsc</initials>
    <remark><p>Fix XML header on example.</p></remark>
  </revision>
  <revision>
    <version>1.1.3</version>
    <date>2018-07-21</date>
    <initials>egp</initials>
    <remark>
      <p>Replace references to draft-ietf-xmpp-websocket with RFC7395 (XMPP over WebSocket).</p>
    </remark>
  </revision>
  <revision>
    <version>1.1.2</version>
    <date>2016-06-07</date>
    <initials>XSF Editor: ssw</initials>
    <remark>
      <ul>
        <li>Clarify that the XML version of the XRD document is required by the RFC and the JSON version is optional.</li>
        <li>Update references to draft-ietf-xmpp-websocket to point to RFC 7395.</li>
      </ul>
    </remark>
  </revision>
  <revision>
    <version>1.1.1</version>
    <date>2016-06-06</date>
    <initials>XSF Editor: ssw</initials>
    <remark><p>Fix a small typo in one of the examples (UTF-9 encoding).</p></remark>
  </revision>
  <revision>
    <version>1.1</version>
    <date>2014-01-08</date>
    <initials>ls/psa</initials>
    <remark><p>Defined HTTP lookup methods using well-known URIs as specified in RFC 5785.</p></remark>
  </revision>
  <revision>
    <version>1.0</version>
    <date>2007-06-12</date>
    <initials>psa</initials>
    <remark><p>Per a vote of the XMPP Council, advanced status to Draft; XMPP Registrar assigned alt-connections shortname and created appropriate registry.</p></remark>
  </revision>
  <revision>
    <version>0.7</version>
    <date>2007-04-18</date>
    <initials>psa</initials>
    <remark><p>Updated to reflect renaming of HTTP Binding to XMPP Over BOSH.</p></remark>
  </revision>
  <revision>
    <version>0.6</version>
    <date>2007-01-30</date>
    <initials>psa</initials>
    <remark><p>Finally and definitively removed _xmpp-client-tcp and _xmpp-server-tcp attributes since clients and servers should use either SRV records or standard XMPP ports (5222 or 5269).</p></remark>
  </revision>
  <revision>
    <version>0.5</version>
    <date>2007-01-30</date>
    <initials>psa</initials>
    <remark><p>Removed _xmpp-client-tcpssl attribute since use of the old-style SSL-only port is discouraged.</p></remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2007-01-29</date>
    <initials>psa</initials>
    <remark><p>Added _xmpp-client-tcpssl for old-style SSL connections; added discussion of IETF U-NAPTR technology.</p></remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2006-05-16</date>
    <initials>psa</initials>
    <remark><p>Clarified order of lookups; restored _xmpp-client-tcp and added _xmpp-server-tcp as optional records if SRV is not supported or accessible.</p></remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2005-12-05</date>
    <initials>psa</initials>
    <remark><p>Removed _xmpp-client-tcp from TXT records (belongs in SRV records only).</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2005-09-08</date>
    <initials>psa</initials>
    <remark><p>Initial version.</p></remark>
  </revision>
  <revision>
    <version>0.0.3</version>
    <date>2005-09-07</date>
    <initials>psa</initials>
    <remark><p>More fully specified the rationale for using DNS TXT records.</p></remark>
  </revision>
  <revision>
    <version>0.0.2</version>
    <date>2005-08-27</date>
    <initials>psa</initials>
    <remark><p>Added security considerations and registrar considerations.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2005-08-23</date>
    <initials>psa/jh</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>
<section1 topic="Introduction" anchor="intro">
  <p>Although <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> specifies the use of TCP as the method of connecting to an XMPP server, alternative connection methods exist, including the <span class="ref"><link url="https://xmpp.org/extensions/xep-0124.html">BOSH (XEP-0124)</link></span> <note>XEP-0124: Bidirectional-streams Over Synchronous HTTP &lt;<link url="https://xmpp.org/extensions/xep-0124.html">https://xmpp.org/extensions/xep-0124.html</link>&gt;.</note> method (for which <span class="ref"><link url="https://xmpp.org/extensions/xep-0206.html">XMPP Over BOSH (XEP-0206)</link></span> <note>XEP-0206: XMPP Over BOSH &lt;<link url="https://xmpp.org/extensions/xep-0206.html">https://xmpp.org/extensions/xep-0206.html</link>&gt;.</note> is the XMPP profile) and the websocket subprotocol specified in <span class="ref"><link url="http://tools.ietf.org/html/rfc7395">RFC 7395</link></span> <note>RFC 7395: An Extensible Messaging and Presence Protocol (XMPP) Subprotocol for WebSocket &lt;<link url="http://tools.ietf.org/html/rfc7395">http://tools.ietf.org/html/rfc7395</link>&gt;.</note>. For some of these methods, it is necessary to discover further parameters before connecting, such as the HTTP URL of an alternative connection manager. Without ways to auto-discover alternative connection methods, the relevant information would need to be provided manually by a human user (which is cumbersome and error-prone) or hard-coded into XMPP software applications (which is brittle and not interoperable).</p>
  <p>This document defines a way to encapsulate information about alternative connection methods for auto-discovery via Link entries in a server's "host-meta" file.
  </p>
</section1>

<section1 topic="HTTP Lookup Method" anchor="http">

  <section2 topic="Link Format" anchor="httpformat">
    <p>The HTTP lookup method uses Web Host Metadata <span class="ref"><link url="http://tools.ietf.org/html/rfc6415">RFC 6415</link></span> <note>RFC 6415: Web Host Metadata &lt;<link url="http://tools.ietf.org/html/rfc6415">http://tools.ietf.org/html/rfc6415</link>&gt;.</note> to categorize and list the URIs of alternative connection methods. It is primarily intended for use by clients in environments where the ability to perform DNS queries is restricted, such as in web browsers.</p>
    <p>Each alternative connection method is specified in the host-meta (XRD) file using a distinctive link relation <span class="ref"><link url="http://tools.ietf.org/html/rfc5988">RFC 5988</link></span> <note>RFC 5988: Web Linking &lt;<link url="http://tools.ietf.org/html/rfc5988">http://tools.ietf.org/html/rfc5988</link>&gt;.</note>. This specification defines several extension relation types:</p>
    <ul>
      <li>urn:xmpp:alt-connections:websocket</li>
      <li>urn:xmpp:alt-connections:xbosh</li>
    </ul>
  </section2>

  <section2 topic="Business Rules" anchor="httpbizrules">
    <p>The following business rules apply:</p>
    <ol start="1">
      <li>host-meta files MUST be fetched only over HTTPS, and MUST only use connection URLs starting with 'https://' or 'wss://'. This provides secure delegation, meaning you SHOULD send SNI matching the host of the URL from the connection URL and validate that the certificate is valid for that host *or* the XMPP domain.</li>  
      <li>Services implementing this XEP MUST offer the information in the Extensible Resource Descriptor (XRD) format and SHOULD additionally provide the JRD format (both formats are specified in <span class="ref"><link url="http://tools.ietf.org/html/rfc6415">RFC 6415</link></span> <note>RFC 6415: Web Host Metadata &lt;<link url="http://tools.ietf.org/html/rfc6415">http://tools.ietf.org/html/rfc6415</link>&gt;.</note>).</li>
      <li>HTTPS queries for host-meta information MUST be used only as a fallback after the methods 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> have been exhausted.</li>
      <li>A domain SHOULD NOT present information in host-meta link records that is available via the DNS SRV records 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>.</li>
      <li>The order of XMPP related link entries in the host-meta file SHOULD NOT be interpreted as significant by the presenting domain or the receiving entity.</li>
    </ol>
  </section2>

  <section2 topic="Examples" anchor="httpexamples">
    <p>The following examples show two host-meta link records: the first indicates support for the XMPP Over BOSH connection method defined in <span class="ref"><link url="https://xmpp.org/extensions/xep-0124.html">BOSH (XEP-0124)</link></span> <note>XEP-0124: Bidirectional-streams Over Synchronous HTTP &lt;<link url="https://xmpp.org/extensions/xep-0124.html">https://xmpp.org/extensions/xep-0124.html</link>&gt;.</note> and <cite>XEP-0206</cite> and the second indicates support for the XMPP Over WebSocket connection method defined in <span class="ref"><link url="http://tools.ietf.org/html/rfc7395">RFC 7395</link></span> <note>RFC 7395: An Extensible Messaging and Presence Protocol (XMPP) Subprotocol for WebSocket &lt;<link url="http://tools.ietf.org/html/rfc7395">http://tools.ietf.org/html/rfc7395</link>&gt;.</note>.</p>
    <example caption="Result for /.well-known/host-meta"><![CDATA[<?xml version='1.0' encoding='utf-8'?>
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
  ...
  <Link rel="urn:xmpp:alt-connections:xbosh"
        href="https://web.example.com:5280/bosh" />
  <Link rel="urn:xmpp:alt-connections:websocket"
        href="wss://web.example.com:443/ws" />
  ...
</XRD>
]]></example>
    <p>It is possible to use additionally a JSON-based format for host-meta information. The JSON representation of the host metadata is named JRD and specified in Appendix A of <span class="ref"><link url="http://tools.ietf.org/html/rfc6415">RFC 6415</link></span> <note>RFC 6415: Web Host Metadata &lt;<link url="http://tools.ietf.org/html/rfc6415">http://tools.ietf.org/html/rfc6415</link>&gt;.</note>. The above XRD example would be presented in JRD as:</p>
    <example caption="Result for /.well-known/host-meta.json"><![CDATA[{
  ...
  "links": [
    ...
    {
      "rel": "urn:xmpp:alt-connections:xbosh",
      "href": "https://web.example.com:5280/bosh"
    },
    {
      "rel": "urn:xmpp:alt-connections:websocket",
      "href": "wss://web.example.com:443/ws"
    }
  ]
}
]]></example>
  </section2>
</section1>
<section1 topic="Implementation Notes" anchor="impl">
  <p>To make connection discovery work in web clients (including those hosted on a different domain) the host service SHOULD set appropriate <link url="https://www.w3.org/TR/cors/">CORS</link> headers for Web Host Metadata files. The exact headers and values are out of scope of this document but may include: <em>Access-Control-Allow-Origin</em>, <em>Access-Control-Allow-Methods</em> and <em>Access-Control-Allow-Headers</em>.</p>
  <p>Due care has to be exercised in limiting the scope of <em>Access-Control-Allow-Origin</em> response header to Web Host Metadata files only.</p>
<code caption="Example header allowing all sites to read host metadata"><![CDATA[
Access-Control-Allow-Origin: *
]]></code>
  <p class="box"><em>Access-Control-Allow-Origin</em> header with a value of <em>*</em> allows JavaScript code running on a different domain to read the content of Web Host Metadata files. Special value <em>*</em> ensures that the request will only succeed if it is <link url="https://www.w3.org/TR/cors/#resource-requests">invoked without user credentials</link> (e.g. cookies, HTTP authentication).</p>
</section1>
<section1 topic="Security Considerations" anchor="security">
  <p>It is possible that advertisement of alternative connection methods can introduce security vulnerabilities, since a connecting entity (usually a client) might deliberately seek to connect using the method with the weakest security mechanisms (e.g., no channel encryption or relatively weak authentication). Care needs to be taken in determining which alternative connection methods are appropriate to advertise or implement in your lookup.</p>
  <p>Entities that use these connection methods MUST only fetch host-meta over Transport Layer Security (TLS), and MUST only use 'https' or 'wss' URLs that are protected using TLS.</p>
  <p>A previous version of this XEP defined a DNS method to look up this info using a TXT <em>_xmppconnect</em> record, this was insecure and has been removed.</p>
</section1>

<section1 topic="IANA Considerations" anchor="iana">
  <p>Because the link relations specified here are extension relation types rather than registered relation types (see Section 4 of RFC 5988), 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">
  <section2 topic="Namespaces" anchor="ns">
    <p>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> shall include 'urn:xmpp:alt-connections' in its registry of protocol namespaces (see &lt;<link url="https://xmpp.org/registrar/namespaces.html">https://xmpp.org/registrar/namespaces.html</link>&gt;).</p>
    <ul>
      <li>urn:xmpp:alt-connections</li>
    </ul>
  </section2>
</section1>
</xep>
