<p><cite>RFC 3920</cite> allows the use of any SASL mechanism (see &rfc4422;) in XMPP authentication, including the SASL EXTERNAL mechanism. This document specifies a recommended protocol flow for such use, specifically when use of TLS is required by a deployment. <note>The protocol flows when TLS is not required are more complicated (e.g., alternate flows involving server dialback) and may be documented in a future version of this document.</note></p>
<p>If certificate is unacceptable (e.g., because the certificate has been revoked, because the certificate has expired, or because the root certificate was issued by a certification authority that is untrusted), server closes client's TCP connection.</p>
<p>Because client presented a certificate, client SHOULD consider EXTERNAL to be its preferred SASL mechanism. The client SHOULD NOT include an authorization identity (i.e., XML character data for the <auth/> element) since client-to-server authorization in XMPP is handled during resource binding.</p>
<p>If the certificate presented by the client contains only one valid XMPP address that corresponds to a registered account on the server, the server SHOULD allow authentication of that JID. For the purpose of client authentication with a server, a valid XMPP address is a JID encapsulated as a subjectAltName entity of type otherName with an ASN.1 Object Identifier of "id-on-xmppAddr" as specified in Section 5.1.1. of <cite>RFC 3920</cite>.</p>
<p>If the certificate contains more than one valid XMPP address that corresponds to a registered account on the server (e.g., because the server offers virtual hosting), the server SHOULD allow authentication of the JID whose hostname matches the 'to' address of the stream header sent by the client to the server.</p>
<p>If the certificate does not contain a valid XMPP address that corresponds to a registered account on the server, the server MAY attempt to determine if there is a registered account associated with the user, for example by performing an LDAP lookup based on the Common Name in the certificate; if such a JID mapping is successful, the server SHOULD allow authentication of that mapped JID.</p>
<p>If the user cannot be associated with an account registered on the server, the server MUST return a SASL failure of <not-authorized/> and close the stream.</p>
<code><![CDATA[
<failurexmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
<not-authorized/>
</failure>
</stream:stream>
]]></code>
</li>
</ol>
</li>
<li>
<p>If SASL authentication succeeded, client opens new stream, then client and server proceed with resource binding as described in <cite>RFC 3920</cite>.</p>
<p>If certificate is unacceptable (e.g., because the certificate has been revoked, because the certificate has expired, or because the root certificate was issued by a certification authority that is untrusted), Server2 closes Server1's TCP connection.</p>
<p>Because Server1 presented a certificate, Server1 SHOULD consider EXTERNAL to be its preferred SASL mechanism. Server1 SHOULD include an authorization identity (base64-encoded as described in RFC 3920) as the XML character data of the <auth/> element, which SHOULD be the same as the 'from' address on the stream header.</p>
<p>If the authorization identity provided by Server1 matches one of the valid XMPP addresses in the certificate, Server2 SHOULD return success. For the purpose of server authentication with another server, a valid XMPP address is a JID encapsulated as a subjectAltName extension of type otherName with an ASN.1 Object Identifier of "id-on-xmppAddr" or a domain name (which MAY include the wildcard character '*') encapsulated as a subjectAltName extension of type dNSName.</p>
<p>Else server MUST return a ¬authorized; failure and close the stream.</p>
<code><![CDATA[
<failurexmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
<not-authorized/>
</failure>
</stream:stream>
]]></code>
</li>
</ol>
</li>
</ol>
</section1>
<section1topic='Use of SASL EXTERNAL Without Certificates'anchor='other'>
<p>The SASL EXTERNAL mechanism can be used outside the context of X.509 certificates, for example via Internet Protocol Security (IPSec) as specified in &rfc4301;. A future version of this specification may document best practices for use of SASL EXTERNAL outside the context of the X.509 infrastructure.</p>
<p>Peter Millard, co-author of the initial version of this specification, died on April 26, 2006. The remaining author appreciates his assistance in defining the best practices described herein.</p>