idnits 2.17.1 draft-saintandre-rfc3920bis-09.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** The document seems to lack a License Notice according IETF Trust Provisions of 28 Dec 2009, Section 6.b.ii or Provisions of 12 Sep 2009 Section 6.b -- however, there's a paragraph with a matching beginning. Boilerplate error? (You're using the IETF Trust Provisions' Section 6.b License Notice from 12 Feb 2009 rather than one of the newer Notices. See https://trustee.ietf.org/license-info/.) Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 7007 has weird spacing: '...equence xmlns...' == Line 7008 has weird spacing: '...s:group ref=...' == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (March 8, 2009) is 5499 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '3' on line 490 -- Looks like a reference, but probably isn't: '1' on line 1054 ** Obsolete normative reference: RFC 3490 (ref. 'IDNA') (Obsoleted by RFC 5890, RFC 5891) ** Obsolete normative reference: RFC 4646 (ref. 'LANGTAGS') (Obsoleted by RFC 5646) ** Obsolete normative reference: RFC 3491 (ref. 'NAMEPREP') (Obsoleted by RFC 5891) ** Obsolete normative reference: RFC 3454 (ref. 'STRINGPREP') (Obsoleted by RFC 7564) ** Obsolete normative reference: RFC 793 (ref. 'TCP') (Obsoleted by RFC 9293) ** Obsolete normative reference: RFC 5246 (ref. 'TLS') (Obsoleted by RFC 8446) -- Possible downref: Non-RFC (?) normative reference: ref. 'UCS2' -- Possible downref: Non-RFC (?) normative reference: ref. 'UNICODE' ** Obsolete normative reference: RFC 3280 (ref. 'X509') (Obsoleted by RFC 5280) -- Possible downref: Non-RFC (?) normative reference: ref. 'XML' -- Possible downref: Non-RFC (?) normative reference: ref. 'XML-NAMES' -- Obsolete informational reference (is this intentional?): RFC 2831 (ref. 'DIGEST-MD5') (Obsoleted by RFC 6331) -- Obsolete informational reference (is this intentional?): RFC 2616 (ref. 'HTTP') (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) -- Obsolete informational reference (is this intentional?): RFC 3501 (ref. 'IMAP') (Obsoleted by RFC 9051) -- Obsolete informational reference (is this intentional?): RFC 3920 (Obsoleted by RFC 6120) -- Obsolete informational reference (is this intentional?): RFC 3921 (Obsoleted by RFC 6121) -- Obsolete informational reference (is this intentional?): RFC 2821 (ref. 'SMTP') (Obsoleted by RFC 5321) Summary: 8 errors (**), 0 flaws (~~), 4 warnings (==), 15 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group P. Saint-Andre 3 Internet-Draft Cisco 4 Obsoletes: 3920 (if approved) March 8, 2009 5 Intended status: Standards Track 6 Expires: September 9, 2009 8 Extensible Messaging and Presence Protocol (XMPP): Core 9 draft-saintandre-rfc3920bis-09 11 Status of this Memo 13 This Internet-Draft is submitted to IETF in full conformance with the 14 provisions of BCP 78 and BCP 79. 16 Internet-Drafts are working documents of the Internet Engineering 17 Task Force (IETF), its areas, and its working groups. Note that 18 other groups may also distribute working documents as Internet- 19 Drafts. 21 Internet-Drafts are draft documents valid for a maximum of six months 22 and may be updated, replaced, or obsoleted by other documents at any 23 time. It is inappropriate to use Internet-Drafts as reference 24 material or to cite them other than as "work in progress." 26 The list of current Internet-Drafts can be accessed at 27 http://www.ietf.org/ietf/1id-abstracts.txt. 29 The list of Internet-Draft Shadow Directories can be accessed at 30 http://www.ietf.org/shadow.html. 32 This Internet-Draft will expire on September 9, 2009. 34 Copyright Notice 36 Copyright (c) 2009 IETF Trust and the persons identified as the 37 document authors. All rights reserved. 39 This document is subject to BCP 78 and the IETF Trust's Legal 40 Provisions Relating to IETF Documents in effect on the date of 41 publication of this document (http://trustee.ietf.org/license-info). 42 Please review these documents carefully, as they describe your rights 43 and restrictions with respect to this document. 45 Abstract 47 This document defines the core features of the Extensible Messaging 48 and Presence Protocol (XMPP), a technology for streaming Extensible 49 Markup Language (XML) elements for the purpose of exchanging 50 structured information in close to real time between any two or more 51 network-aware entities. XMPP provides a generalized, extensible 52 framework for incrementally exchanging XML data, upon which a variety 53 of applications can be built. The framework includes methods for 54 stream setup and teardown, channel encryption, authentication of a 55 client to a server and of one server to another server, and 56 primitives for push-style messages, publication of network 57 availability information ("presence"), and request-response 58 interactions. This document also specifies the format for XMPP 59 addresses, which are fully internationalizable. 61 This document obsoletes RFC 3920. 63 Table of Contents 65 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 9 66 1.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 9 67 1.2. Functional Summary . . . . . . . . . . . . . . . . . . . 10 68 1.3. Conventions . . . . . . . . . . . . . . . . . . . . . . 11 69 1.4. Acknowledgements . . . . . . . . . . . . . . . . . . . . 12 70 1.5. Discussion Venue . . . . . . . . . . . . . . . . . . . . 12 71 2. Architecture . . . . . . . . . . . . . . . . . . . . . . . . 12 72 2.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 12 73 2.2. Server . . . . . . . . . . . . . . . . . . . . . . . . . 13 74 2.3. Client . . . . . . . . . . . . . . . . . . . . . . . . . 13 75 2.4. Network . . . . . . . . . . . . . . . . . . . . . . . . 14 76 3. Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . 14 77 3.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 14 78 3.2. Domain Identifier . . . . . . . . . . . . . . . . . . . 15 79 3.3. Node Identifier . . . . . . . . . . . . . . . . . . . . 16 80 3.4. Resource Identifier . . . . . . . . . . . . . . . . . . 17 81 3.5. Determination of Addresses . . . . . . . . . . . . . . . 18 82 4. TCP Binding . . . . . . . . . . . . . . . . . . . . . . . . . 18 83 4.1. Scope . . . . . . . . . . . . . . . . . . . . . . . . . 18 84 4.2. Hostname Resolution . . . . . . . . . . . . . . . . . . 19 85 4.3. Client-to-Server Communication . . . . . . . . . . . . . 20 86 4.4. Server-to-Server Communication . . . . . . . . . . . . . 20 87 4.5. Reconnection . . . . . . . . . . . . . . . . . . . . . . 20 88 4.6. Other Bindings . . . . . . . . . . . . . . . . . . . . . 21 89 5. XML Streams . . . . . . . . . . . . . . . . . . . . . . . . . 21 90 5.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 21 91 5.2. Stream Security . . . . . . . . . . . . . . . . . . . . 23 92 5.3. Stream Attributes . . . . . . . . . . . . . . . . . . . 24 93 5.3.1. from . . . . . . . . . . . . . . . . . . . . . . . . 24 94 5.3.2. to . . . . . . . . . . . . . . . . . . . . . . . . . 26 95 5.3.3. id . . . . . . . . . . . . . . . . . . . . . . . . . 27 96 5.3.4. xml:lang . . . . . . . . . . . . . . . . . . . . . . 27 97 5.3.5. version . . . . . . . . . . . . . . . . . . . . . . 29 98 5.3.6. Summary of Stream Attributes . . . . . . . . . . . . 30 99 5.4. Namespace Declarations . . . . . . . . . . . . . . . . . 30 100 5.5. Stream Features . . . . . . . . . . . . . . . . . . . . 31 101 5.6. Restarts During Stream Negotiation . . . . . . . . . . . 33 102 5.7. Closing a Stream . . . . . . . . . . . . . . . . . . . . 33 103 5.7.1. With Stream Error . . . . . . . . . . . . . . . . . 33 104 5.7.2. Without Stream Error . . . . . . . . . . . . . . . . 34 105 5.7.3. Handling of Idle Streams . . . . . . . . . . . . . . 34 106 5.8. Stream Errors . . . . . . . . . . . . . . . . . . . . . 35 107 5.8.1. Rules . . . . . . . . . . . . . . . . . . . . . . . 35 108 5.8.1.1. Stream Errors Are Unrecoverable . . . . . . . . . 35 109 5.8.1.2. Stream Errors Can Occur During Setup . . . . . . 35 110 5.8.1.3. Stream Errors When the Host is Unspecified or 111 Unknown . . . . . . . . . . . . . . . . . . . . . 36 112 5.8.2. Syntax . . . . . . . . . . . . . . . . . . . . . . . 37 113 5.8.3. Defined Stream Error Conditions . . . . . . . . . . 38 114 5.8.3.1. bad-format . . . . . . . . . . . . . . . . . . . 38 115 5.8.3.2. bad-namespace-prefix . . . . . . . . . . . . . . 38 116 5.8.3.3. conflict . . . . . . . . . . . . . . . . . . . . 39 117 5.8.3.4. connection-timeout . . . . . . . . . . . . . . . 40 118 5.8.3.5. host-gone . . . . . . . . . . . . . . . . . . . . 40 119 5.8.3.6. host-unknown . . . . . . . . . . . . . . . . . . 41 120 5.8.3.7. improper-addressing . . . . . . . . . . . . . . . 42 121 5.8.3.8. internal-server-error . . . . . . . . . . . . . . 42 122 5.8.3.9. invalid-from . . . . . . . . . . . . . . . . . . 43 123 5.8.3.10. invalid-id . . . . . . . . . . . . . . . . . . . 43 124 5.8.3.11. invalid-namespace . . . . . . . . . . . . . . . . 44 125 5.8.3.12. invalid-xml . . . . . . . . . . . . . . . . . . . 44 126 5.8.3.13. not-authorized . . . . . . . . . . . . . . . . . 45 127 5.8.3.14. policy-violation . . . . . . . . . . . . . . . . 46 128 5.8.3.15. remote-connection-failed . . . . . . . . . . . . 47 129 5.8.3.16. resource-constraint . . . . . . . . . . . . . . . 47 130 5.8.3.17. restricted-xml . . . . . . . . . . . . . . . . . 48 131 5.8.3.18. see-other-host . . . . . . . . . . . . . . . . . 48 132 5.8.3.19. system-shutdown . . . . . . . . . . . . . . . . . 49 133 5.8.3.20. undefined-condition . . . . . . . . . . . . . . . 50 134 5.8.3.21. unsupported-encoding . . . . . . . . . . . . . . 50 135 5.8.3.22. unsupported-stanza-type . . . . . . . . . . . . . 51 136 5.8.3.23. unsupported-version . . . . . . . . . . . . . . . 51 137 5.8.3.24. xml-not-well-formed . . . . . . . . . . . . . . . 52 138 5.8.4. Application-Specific Conditions . . . . . . . . . . 53 139 5.9. Simplified Stream Examples . . . . . . . . . . . . . . . 53 140 6. STARTTLS Negotiation . . . . . . . . . . . . . . . . . . . . 55 141 6.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 56 142 6.2. Rules . . . . . . . . . . . . . . . . . . . . . . . . . 56 143 6.2.1. Data Formatting . . . . . . . . . . . . . . . . . . 56 144 6.2.2. Order of Negotiation . . . . . . . . . . . . . . . . 56 145 6.3. Process . . . . . . . . . . . . . . . . . . . . . . . . 57 146 6.3.1. Exchange of Stream Headers and Stream Features . . . 57 147 6.3.2. Initiation of STARTTLS Negotiation . . . . . . . . . 58 148 6.3.2.1. STARTTLS Command . . . . . . . . . . . . . . . . 58 149 6.3.2.2. Failure Case . . . . . . . . . . . . . . . . . . 58 150 6.3.2.3. Proceed Case . . . . . . . . . . . . . . . . . . 59 151 6.3.3. TLS Negotiation . . . . . . . . . . . . . . . . . . 59 152 6.3.3.1. Rules . . . . . . . . . . . . . . . . . . . . . . 59 153 6.3.3.2. TLS Failure . . . . . . . . . . . . . . . . . . . 60 154 6.3.3.3. TLS Success . . . . . . . . . . . . . . . . . . . 60 155 7. SASL Negotiation . . . . . . . . . . . . . . . . . . . . . . 61 156 7.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 61 157 7.2. Rules . . . . . . . . . . . . . . . . . . . . . . . . . 61 158 7.2.1. Mechanism Preferences . . . . . . . . . . . . . . . 61 159 7.2.2. Mechanism Offers . . . . . . . . . . . . . . . . . . 62 160 7.2.3. Data Formatting . . . . . . . . . . . . . . . . . . 62 161 7.2.4. Security Layers . . . . . . . . . . . . . . . . . . 63 162 7.2.5. Simple Usernames . . . . . . . . . . . . . . . . . . 63 163 7.2.6. Authorization Identities . . . . . . . . . . . . . . 63 164 7.2.7. Realms . . . . . . . . . . . . . . . . . . . . . . . 64 165 7.2.8. Round Trips . . . . . . . . . . . . . . . . . . . . 64 166 7.3. Process . . . . . . . . . . . . . . . . . . . . . . . . 64 167 7.3.1. Exchange of Stream Headers and Stream Features . . . 64 168 7.3.2. Initiation . . . . . . . . . . . . . . . . . . . . . 66 169 7.3.3. Challenge-Response Sequence . . . . . . . . . . . . 66 170 7.3.4. Abort . . . . . . . . . . . . . . . . . . . . . . . 67 171 7.3.5. Failure . . . . . . . . . . . . . . . . . . . . . . 67 172 7.3.6. Success . . . . . . . . . . . . . . . . . . . . . . 68 173 7.4. SASL Errors . . . . . . . . . . . . . . . . . . . . . . 69 174 7.4.1. aborted . . . . . . . . . . . . . . . . . . . . . . 70 175 7.4.2. account-disabled . . . . . . . . . . . . . . . . . . 70 176 7.4.3. credentials-expired . . . . . . . . . . . . . . . . 70 177 7.4.4. encryption-required . . . . . . . . . . . . . . . . 70 178 7.4.5. incorrect-encoding . . . . . . . . . . . . . . . . . 71 179 7.4.6. invalid-authzid . . . . . . . . . . . . . . . . . . 71 180 7.4.7. invalid-mechanism . . . . . . . . . . . . . . . . . 71 181 7.4.8. malformed-request . . . . . . . . . . . . . . . . . 72 182 7.4.9. mechanism-too-weak . . . . . . . . . . . . . . . . . 72 183 7.4.10. not-authorized . . . . . . . . . . . . . . . . . . . 72 184 7.4.11. temporary-auth-failure . . . . . . . . . . . . . . . 73 185 7.4.12. transition-needed . . . . . . . . . . . . . . . . . 73 186 7.5. SASL Definition . . . . . . . . . . . . . . . . . . . . 73 187 8. Resource Binding . . . . . . . . . . . . . . . . . . . . . . 74 188 8.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 74 189 8.2. Advertising Support . . . . . . . . . . . . . . . . . . 75 190 8.3. Generation of Resource Identifiers . . . . . . . . . . . 75 191 8.4. Server-Generated Resource Identifier . . . . . . . . . . 76 192 8.4.1. Success Case . . . . . . . . . . . . . . . . . . . . 76 193 8.4.2. Error Cases . . . . . . . . . . . . . . . . . . . . 76 194 8.4.2.1. Resource Constraint . . . . . . . . . . . . . . . 77 195 8.4.2.2. Not Allowed . . . . . . . . . . . . . . . . . . . 77 196 8.5. Client-Submitted Resource Identifier . . . . . . . . . . 77 197 8.5.1. Success Case . . . . . . . . . . . . . . . . . . . . 77 198 8.5.2. Error Cases . . . . . . . . . . . . . . . . . . . . 78 199 8.5.2.1. Bad Request . . . . . . . . . . . . . . . . . . . 78 200 8.5.2.2. Conflict . . . . . . . . . . . . . . . . . . . . 78 201 8.5.3. Retries . . . . . . . . . . . . . . . . . . . . . . 79 202 8.6. Binding Multiple Resources . . . . . . . . . . . . . . . 79 203 8.6.1. Support . . . . . . . . . . . . . . . . . . . . . . 80 204 8.6.2. Binding an Additional Resource . . . . . . . . . . . 80 205 8.6.3. Unbinding a Resource . . . . . . . . . . . . . . . . 80 206 8.6.3.1. Success Case . . . . . . . . . . . . . . . . . . 80 207 8.6.3.2. Error Cases . . . . . . . . . . . . . . . . . . . 81 208 8.6.4. From Addresses . . . . . . . . . . . . . . . . . . . 82 209 9. XML Stanzas . . . . . . . . . . . . . . . . . . . . . . . . . 82 210 9.1. Common Attributes . . . . . . . . . . . . . . . . . . . 83 211 9.1.1. to . . . . . . . . . . . . . . . . . . . . . . . . . 83 212 9.1.1.1. Client-to-Server Streams . . . . . . . . . . . . 83 213 9.1.1.2. Server-to-Server Streams . . . . . . . . . . . . 83 214 9.1.2. from . . . . . . . . . . . . . . . . . . . . . . . . 84 215 9.1.2.1. Client-to-Server Streams . . . . . . . . . . . . 84 216 9.1.2.2. Server-to-Server Streams . . . . . . . . . . . . 85 217 9.1.3. id . . . . . . . . . . . . . . . . . . . . . . . . . 85 218 9.1.4. type . . . . . . . . . . . . . . . . . . . . . . . . 85 219 9.1.5. xml:lang . . . . . . . . . . . . . . . . . . . . . . 85 220 9.2. Basic Semantics . . . . . . . . . . . . . . . . . . . . 87 221 9.2.1. Message Semantics . . . . . . . . . . . . . . . . . 87 222 9.2.2. Presence Semantics . . . . . . . . . . . . . . . . . 87 223 9.2.3. IQ Semantics . . . . . . . . . . . . . . . . . . . . 87 224 9.3. Stanza Errors . . . . . . . . . . . . . . . . . . . . . 89 225 9.3.1. Rules . . . . . . . . . . . . . . . . . . . . . . . 89 226 9.3.2. Syntax . . . . . . . . . . . . . . . . . . . . . . . 89 227 9.3.3. Defined Conditions . . . . . . . . . . . . . . . . . 91 228 9.3.3.1. bad-request . . . . . . . . . . . . . . . . . . . 91 229 9.3.3.2. conflict . . . . . . . . . . . . . . . . . . . . 91 230 9.3.3.3. feature-not-implemented . . . . . . . . . . . . . 92 231 9.3.3.4. forbidden . . . . . . . . . . . . . . . . . . . . 92 232 9.3.3.5. gone . . . . . . . . . . . . . . . . . . . . . . 93 233 9.3.3.6. internal-server-error . . . . . . . . . . . . . . 93 234 9.3.3.7. item-not-found . . . . . . . . . . . . . . . . . 94 235 9.3.3.8. jid-malformed . . . . . . . . . . . . . . . . . . 94 236 9.3.3.9. not-acceptable . . . . . . . . . . . . . . . . . 95 237 9.3.3.10. not-allowed . . . . . . . . . . . . . . . . . . . 95 238 9.3.3.11. not-authorized . . . . . . . . . . . . . . . . . 95 239 9.3.3.12. not-modified . . . . . . . . . . . . . . . . . . 96 240 9.3.3.13. payment-required . . . . . . . . . . . . . . . . 97 241 9.3.3.14. recipient-unavailable . . . . . . . . . . . . . . 97 242 9.3.3.15. redirect . . . . . . . . . . . . . . . . . . . . 98 243 9.3.3.16. registration-required . . . . . . . . . . . . . . 98 244 9.3.3.17. remote-server-not-found . . . . . . . . . . . . . 99 245 9.3.3.18. remote-server-timeout . . . . . . . . . . . . . . 99 246 9.3.3.19. resource-constraint . . . . . . . . . . . . . . . 100 247 9.3.3.20. service-unavailable . . . . . . . . . . . . . . . 100 248 9.3.3.21. subscription-required . . . . . . . . . . . . . . 101 249 9.3.3.22. undefined-condition . . . . . . . . . . . . . . . 101 250 9.3.3.23. unexpected-request . . . . . . . . . . . . . . . 102 251 9.3.3.24. unknown-sender . . . . . . . . . . . . . . . . . 103 252 9.3.4. Application-Specific Conditions . . . . . . . . . . 103 253 9.4. Extended Content . . . . . . . . . . . . . . . . . . . . 104 254 9.5. Stanza Size . . . . . . . . . . . . . . . . . . . . . . 105 255 10. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 105 256 10.1. Client-to-Server . . . . . . . . . . . . . . . . . . . . 105 257 10.1.1. TLS . . . . . . . . . . . . . . . . . . . . . . . . 106 258 10.1.2. SASL . . . . . . . . . . . . . . . . . . . . . . . . 107 259 10.1.3. Resource Binding . . . . . . . . . . . . . . . . . . 108 260 10.1.4. Stanza Exchange . . . . . . . . . . . . . . . . . . 109 261 10.1.5. Close . . . . . . . . . . . . . . . . . . . . . . . 110 262 10.2. Server-to-Server Examples . . . . . . . . . . . . . . . 110 263 10.2.1. TLS . . . . . . . . . . . . . . . . . . . . . . . . 110 264 10.2.2. SASL . . . . . . . . . . . . . . . . . . . . . . . . 112 265 10.2.3. Stanza Exchange . . . . . . . . . . . . . . . . . . 113 266 10.2.4. Close . . . . . . . . . . . . . . . . . . . . . . . 114 267 11. Server Rules for Processing XML Stanzas . . . . . . . . . . . 114 268 11.1. No 'to' Address . . . . . . . . . . . . . . . . . . . . 114 269 11.1.1. Overview . . . . . . . . . . . . . . . . . . . . . . 114 270 11.1.2. Message . . . . . . . . . . . . . . . . . . . . . . 115 271 11.1.3. Presence . . . . . . . . . . . . . . . . . . . . . . 115 272 11.1.4. IQ . . . . . . . . . . . . . . . . . . . . . . . . . 115 273 11.2. Local Domain . . . . . . . . . . . . . . . . . . . . . . 115 274 11.2.1. Mere Domain . . . . . . . . . . . . . . . . . . . . 116 275 11.2.2. Domain with Resource . . . . . . . . . . . . . . . . 116 276 11.2.3. Node at Domain . . . . . . . . . . . . . . . . . . . 116 277 11.2.3.1. No Such User . . . . . . . . . . . . . . . . . . 116 278 11.2.3.2. Bare JID . . . . . . . . . . . . . . . . . . . . 116 279 11.2.3.3. Full JID . . . . . . . . . . . . . . . . . . . . 117 280 11.3. Foreign Domain . . . . . . . . . . . . . . . . . . . . . 117 281 11.3.1. Existing Stream . . . . . . . . . . . . . . . . . . 117 282 11.3.2. No Existing Stream . . . . . . . . . . . . . . . . . 117 283 11.3.3. Error Handling . . . . . . . . . . . . . . . . . . . 118 284 12. XML Usage . . . . . . . . . . . . . . . . . . . . . . . . . . 118 285 12.1. Restrictions . . . . . . . . . . . . . . . . . . . . . . 118 286 12.2. XML Namespace Names and Prefixes . . . . . . . . . . . . 119 287 12.2.1. Streams Namespace . . . . . . . . . . . . . . . . . 119 288 12.2.2. Default Namespace . . . . . . . . . . . . . . . . . 119 289 12.2.3. Extended Namespaces . . . . . . . . . . . . . . . . 120 290 12.3. Well-Formedness . . . . . . . . . . . . . . . . . . . . 121 291 12.4. Validation . . . . . . . . . . . . . . . . . . . . . . . 122 292 12.5. Inclusion of Text Declaration . . . . . . . . . . . . . 122 293 12.6. Character Encoding . . . . . . . . . . . . . . . . . . . 122 294 12.7. Whitespace . . . . . . . . . . . . . . . . . . . . . . . 123 295 12.8. XML Versions . . . . . . . . . . . . . . . . . . . . . . 123 296 13. Compliance Requirements . . . . . . . . . . . . . . . . . . . 123 297 13.1. Servers . . . . . . . . . . . . . . . . . . . . . . . . 124 298 13.2. Clients . . . . . . . . . . . . . . . . . . . . . . . . 124 299 14. Internationalization Considerations . . . . . . . . . . . . . 124 300 15. Security Considerations . . . . . . . . . . . . . . . . . . . 125 301 15.1. High Security . . . . . . . . . . . . . . . . . . . . . 125 302 15.2. Certificates . . . . . . . . . . . . . . . . . . . . . . 125 303 15.2.1. Certificate Generation . . . . . . . . . . . . . . . 126 304 15.2.1.1. Server Certificates . . . . . . . . . . . . . . . 126 305 15.2.1.2. Client Certificates . . . . . . . . . . . . . . . 128 306 15.2.1.3. ASN.1 Object Identifier . . . . . . . . . . . . . 128 307 15.2.2. Certificate Validation . . . . . . . . . . . . . . . 129 308 15.2.2.1. Server-to-Server Streams . . . . . . . . . . . . 129 309 15.2.2.2. Client-to-Server Streams . . . . . . . . . . . . 131 310 15.2.2.3. Use of Certificates in XMPP Extensions . . . . . 131 311 15.3. Client-to-Server Communication . . . . . . . . . . . . . 132 312 15.4. Server-to-Server Communication . . . . . . . . . . . . . 132 313 15.5. Order of Layers . . . . . . . . . . . . . . . . . . . . 133 314 15.6. Mandatory-to-Implement Technologies . . . . . . . . . . 133 315 15.7. SASL Downgrade Attacks . . . . . . . . . . . . . . . . . 133 316 15.8. Lack of SASL Channel Binding to TLS . . . . . . . . . . 134 317 15.9. Use of base64 in SASL . . . . . . . . . . . . . . . . . 134 318 15.10. Stringprep Profiles . . . . . . . . . . . . . . . . . . 134 319 15.11. Address Spoofing . . . . . . . . . . . . . . . . . . . . 135 320 15.11.1. Address Forging . . . . . . . . . . . . . . . . . . 135 321 15.11.2. Address Mimicking . . . . . . . . . . . . . . . . . 136 322 15.12. Firewalls . . . . . . . . . . . . . . . . . . . . . . . 137 323 15.13. Denial of Service . . . . . . . . . . . . . . . . . . . 137 324 15.14. Presence Leaks . . . . . . . . . . . . . . . . . . . . . 139 325 15.15. Directory Harvesting . . . . . . . . . . . . . . . . . . 139 326 16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 139 327 16.1. XML Namespace Name for TLS Data . . . . . . . . . . . . 139 328 16.2. XML Namespace Name for SASL Data . . . . . . . . . . . . 140 329 16.3. XML Namespace Name for Stream Errors . . . . . . . . . . 140 330 16.4. XML Namespace Name for Resource Binding . . . . . . . . 140 331 16.5. XML Namespace Name for Stanza Errors . . . . . . . . . . 140 332 16.6. Nodeprep Profile of Stringprep . . . . . . . . . . . . . 141 333 16.7. Resourceprep Profile of Stringprep . . . . . . . . . . . 141 334 16.8. GSSAPI Service Name . . . . . . . . . . . . . . . . . . 141 335 16.9. Port Numbers . . . . . . . . . . . . . . . . . . . . . . 142 337 17. References . . . . . . . . . . . . . . . . . . . . . . . . . 142 338 17.1. Normative References . . . . . . . . . . . . . . . . . . 142 339 17.2. Informative References . . . . . . . . . . . . . . . . . 144 340 Appendix A. Nodeprep . . . . . . . . . . . . . . . . . . . . . . 148 341 A.1. Introduction . . . . . . . . . . . . . . . . . . . . . . 148 342 A.2. Character Repertoire . . . . . . . . . . . . . . . . . . 148 343 A.3. Mapping . . . . . . . . . . . . . . . . . . . . . . . . 148 344 A.4. Normalization . . . . . . . . . . . . . . . . . . . . . 148 345 A.5. Prohibited Output . . . . . . . . . . . . . . . . . . . 149 346 A.6. Bidirectional Characters . . . . . . . . . . . . . . . . 149 347 A.7. Notes . . . . . . . . . . . . . . . . . . . . . . . . . 149 348 Appendix B. Resourceprep . . . . . . . . . . . . . . . . . . . . 150 349 B.1. Introduction . . . . . . . . . . . . . . . . . . . . . . 150 350 B.2. Character Repertoire . . . . . . . . . . . . . . . . . . 151 351 B.3. Mapping . . . . . . . . . . . . . . . . . . . . . . . . 151 352 B.4. Normalization . . . . . . . . . . . . . . . . . . . . . 151 353 B.5. Prohibited Output . . . . . . . . . . . . . . . . . . . 151 354 B.6. Bidirectional Characters . . . . . . . . . . . . . . . . 151 355 Appendix C. XML Schemas . . . . . . . . . . . . . . . . . . . . 151 356 C.1. Streams Namespace . . . . . . . . . . . . . . . . . . . 152 357 C.2. Stream Error Namespace . . . . . . . . . . . . . . . . . 153 358 C.3. STARTTLS Namespace . . . . . . . . . . . . . . . . . . . 155 359 C.4. SASL Namespace . . . . . . . . . . . . . . . . . . . . . 155 360 C.5. Resource Binding Namespace . . . . . . . . . . . . . . . 157 361 C.6. Stanza Error Namespace . . . . . . . . . . . . . . . . . 158 362 Appendix D. Contact Addresses . . . . . . . . . . . . . . . . . 160 363 Appendix E. Account Provisioning . . . . . . . . . . . . . . . . 160 364 Appendix F. Differences From RFC 3920 . . . . . . . . . . . . . 161 365 Appendix G. Copying Conditions . . . . . . . . . . . . . . . . . 162 366 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 367 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 163 369 1. Introduction 371 1.1. Overview 373 The Extensible Messaging and Presence Protocol (XMPP) is an 374 application profile of the Extensible Markup Language [XML] for 375 streaming XML data in close to real time between any two (or more) 376 network-aware entities. XMPP is typically used to exchange messages, 377 share presence information, and engage in structured request-response 378 interactions. The basic syntax and semantics of XMPP were developed 379 originally within the Jabber open-source community, mainly in 1999. 380 In late 2002, the XMPP Working Group was chartered with developing an 381 adaptation of the core Jabber protocol that would be suitable as an 382 IETF instant messaging (IM) and presence technology. As a result of 383 work by the XMPP WG, [RFC3920] and [RFC3921] were published in 384 October 2004, representing the most complete definition of XMPP at 385 that time. 387 As a result of extensive implementation and deployment experience 388 with XMPP since 2004, as well as more formal interoperability testing 389 carried out under the auspices of the XMPP Standards Foundation 390 (XSF), this document reflects consensus from the XMPP developer 391 community regarding XMPP's core XML streaming technology. In 392 particular, this document incorporates the following backward- 393 compatible changes from RFC 3920: 395 o Incorporated corrections and errata 396 o Added examples throughout 397 o Clarified and more completely specified matters that were 398 underspecified 399 o Modified text to reflect updated technologies for which XMPP is a 400 using protocol, e.g., Transport Layer Security (TLS) and the 401 Simple Authentication and Security Layer (SASL) 402 o Defined several additional stream, stanza, and SASL error 403 conditions 404 o Removed the deprecated DIGEST-MD5 SASL mechanism [DIGEST-MD5] as a 405 mandatory-to-implement technology 406 o Added the TLS plus the SASL PLAIN mechanism [PLAIN] as a 407 mandatory-to-implement technology 408 o Defined of optional support for multiple resources over the same 409 connection 410 o Transferred historical documentation for the server dialback 411 protocol from this specification to a separate specification 413 Therefore, this document defines the core features of XMPP 1.0, thus 414 obsoleting RFC 3920. 416 Note: [rfc3921bis] defines the XMPP features needed to provide the 417 basic instant messaging and presence functionality that is 418 described in [IMP-REQS]. 420 1.2. Functional Summary 422 This non-normative section provides a developer-friendly, functional 423 summary of XMPP; refer to the sections that follow for a normative 424 definition of XMPP. 426 The purpose of XMPP is to enable the exchange of relatively small 427 pieces of structured data (called "XML stanzas") over a network 428 between any two (or more) entities. XMPP is implemented using a 429 client-server architecture, wherein a client needs to connect to a 430 server in order to gain access to the network and thus be allowed to 431 exchange XML stanzas with other entities (which can be associated 432 with other servers). The process whereby a client connects to a 433 server, exchanges XML stanzas, and ends the connection is: 435 1. Determine the hostname and port at which to connect 436 2. Open a TCP connection 437 3. Open an XML stream 438 4. Complete TLS negotiation for channel encryption (recommended) 439 5. Complete SASL negotiation for authentication 440 6. Bind a resource to the stream 441 7. Exchange an unbounded number of XML stanzas with other entities 442 on the network 443 8. Close the XML stream 444 9. Close the TCP connection 446 Within XMPP, one server can optionally connect to another server to 447 enable inter-domain or inter-server communication. For this to 448 happen, the two servers need to negotiate a connection between 449 themselves and then exchange XML stanzas; the process for doing so 450 is: 452 1. Determine the hostname and port at which to connect 453 2. Open a TCP connection 454 3. Open an XML stream 455 4. Complete TLS negotiation for channel encryption (recommended) 456 5. Complete SASL negotiation for authentication * 457 6. Exchange an unbounded number of XML stanzas both directly for the 458 servers and indirectly on behalf of entities associated with each 459 server (e.g., connected clients) 460 7. Close the XML stream 461 8. Close the TCP connection 462 * Note: Depending on local service policies, it is possible that a 463 deployed server will use the older server dialback protocol to 464 provide weak identity verification in cases where SASL negotiation 465 would not result in strong authentication (e.g., because TLS 466 negotiation was not mandated by the peer server, or because the 467 certificate presented by the peer server during TLS negotiation is 468 self-signed and thus provides only weak identity); for details, 469 see [XEP-0220]. 471 In the sections following discussion of XMPP architecture and XMPP 472 addresses, this document specifies how clients connect to servers and 473 specifies the basic semantics of XML stanzas. However, this document 474 does not define the "payloads" of the XML stanzas that might be 475 exchanged once a connection is successfully established; instead, 476 those payloads are defined by various XMPP extensions. For example, 477 [rfc3921bis] defines extensions for basic instant messaging and 478 presence functionality. In addition, various specifications produced 479 in the XSF's XEP series [XEP-0001] define extensions for a wide range 480 of more advanced functionality. 482 1.3. Conventions 484 The following capitalized keywords are to be interpreted as described 485 in [TERMS]: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; 486 "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", 487 "OPTIONAL". 489 The term "whitespace" is used to refer to any character that matches 490 production [3] content of [XML], i.e., any instance of SP, HT, CR, 491 and LF. 493 Following the "XML Notation" used in [IRI] to represent characters 494 that cannot be rendered in ASCII-only documents, some examples in 495 this document use the form "&#x...." as a notational device to 496 represent Unicode characters (e.g., the string "ř" stands for 497 the Unicode character LATIN SMALL LETTER R WITH CARON). 499 In examples, lines have been wrapped for improved readability, 500 "[...]" means elision, and the following prepended strings are used 501 (these prepended strings are not to be sent over the wire): 503 o C: = a client 504 o E: = any XMPP entity 505 o I: = an initiating entity 506 o P: = a peer server 507 o R: = a receiving entity 508 o S: = a server 509 o S1: = server1 510 o S2: = server2 512 1.4. Acknowledgements 514 The editor of this document finds it impossible to appropriately 515 acknowledge the many individuals who have provided comments regarding 516 the protocols defined herein. However, thanks are due to those who 517 have who have provided implementation feedback, bug reports, requests 518 for clarification, and suggestions for improvement since the 519 publication of the RFC this document supersedes. The editor has 520 endeavored to address all such feedback, but is solely responsible 521 for any remaining errors and ambiguities. 523 1.5. Discussion Venue 525 The document editor and the broader XMPP developer community welcome 526 discussion and comments related to the topics presented in this 527 document. The preferred forum is the mailing 528 list, for which archives and subscription information are available 529 at . 531 2. Architecture 533 2.1. Overview 535 XMPP assumes a client-server architecture, wherein a client utilizing 536 XMPP accesses a server (normally over a [TCP] connection) and servers 537 can also communicate with each other over TCP connections. 539 A simplified architectural diagram for a typical deployment is shown 540 here, where the entities have the following significance: 542 o romeo@example.net -- an XMPP user. 543 o example.net -- an XMPP server. 544 o im.example.com -- an XMPP server. 545 o juliet@im.example.com -- an XMPP user. 547 example.net ---------------- im.example.com 548 | | 549 | | 550 romeo@example.net juliet@im.example.com 551 Note: Architectures that employ XML streams (Section 5) and XML 552 stanzas (Section 9) but that establish peer-to-peer connections 553 directly between clients using technologies based on [LINKLOCAL] 554 have been deployed, but such architectures are not XMPP and are 555 best described as "XMPP-like"; for details, see [XEP-0174]. In 556 addition, XML streams can be established end-to-end over any 557 reliable transport, including extensions to XMPP itself; for 558 details, see [XEP-0246]. 560 2.2. Server 562 A SERVER is an entity whose primary responsibilities are to: 564 o Manage XML streams (Section 5) with local clients and deliver XML 565 stanzas (Section 9) to those clients over the negotiated XML 566 streams. 567 o Subject to local service policies on server-to-server 568 communication, manage XML streams (Section 5) with foreign servers 569 and route XML stanzas (Section 9) to those servers over the 570 negotiated XML streams. 572 Depending on the application, the secondary responsibilities of an 573 XMPP server can include: 575 o Storing XML data that is used by clients (e.g., contact lists for 576 users of XMPP-based instant messaging and presence applications as 577 defined in [rfc3921bis]); in this case, the relevant XML stanza is 578 handled directly by the server itself on behalf of the client and 579 is not routed to a foreign server or delivered to a local entity. 580 o Hosting local services that also use XMPP as the basis for 581 communication but that provide additional functionality beyond 582 that defined in this document or in [rfc3921bis]; examples include 583 multi-user conferencing services as specified in [XEP-0045] and 584 publish-subscribe services as specified in [XEP-0060]. 586 2.3. Client 588 A CLIENT is an entity that establishes an XML stream with a server by 589 authenticating using the credentials of a local account and that then 590 completes resource binding (Section 8) in order to enable delivery of 591 XML stanzas via the server to the client. A client then uses XMPP to 592 communicate with its server, other clients, and any other accessible 593 entities on a network. Multiple clients can connect simultaneously 594 to a server on behalf of a local account, where each client is 595 differentiated by the resource identifier portion of an XMPP address 596 (e.g., vs. ), as defined under 597 Section 3 and Section 8. The RECOMMENDED port for TCP connections 598 between a client and a server is 5222, as registered with the IANA 599 (see Section 16.9). 601 2.4. Network 603 Because each server is identified by a network address and because 604 server-to-server communication is a straightforward extension of the 605 client-to-server protocol, in practice the system consists of a 606 network of servers that inter-communicate. Thus, for example, 607 is able to exchange messages, presence, and 608 other information with . This pattern is familiar 609 from messaging protocols (such as [SMTP]) that make use of network 610 addressing standards. Communication between any two servers is 611 OPTIONAL. The RECOMMENDED port for TCP connections between servers 612 is 5269, as registered with the IANA (see Section 16.9). 614 3. Addresses 616 3.1. Overview 618 An ENTITY is anything that is network-addressable and that can 619 communicate using XMPP. For historical reasons, the native address 620 of an XMPP entity is called a JABBER IDENTIFIER or JID. A valid JID 621 contains a set of ordered elements formed of an XMPP node identifier, 622 domain identifier, and resource identifier. 624 The syntax for a JID is defined as follows using the Augmented 625 Backus-Naur Form as specified in [ABNF]. 627 jid = [ node "@" ] domain [ "/" resource ] 628 node = 1*(nodepoint) 629 ; a "nodepoint" is a UTF-8 encoded Unicode code 630 ; point that satisfies the Nodeprep profile of 631 ; stringprep 632 domain = fqdn / address-literal 633 fqdn = *(ldhlabel ".") toplabel 634 ldhlabel = letdig [*61(ldh) letdig] 635 toplabel = ALPHA *61(ldh) letdig 636 letdig = ALPHA / DIGIT 637 ldh = ALPHA / DIGIT / "-" 638 address-literal = IPv4address / IPv6address 639 ; the "IPv4address" and "IPv6address" rules are 640 ; defined in RFC 3986 641 resource = 1*(resourcepoint) 642 ; a "resourcepoint" is a UTF-8 encoded Unicode 643 ; code point that satisfies the Resourceprep 644 ; profile of stringprep 646 All JIDs are based on the foregoing structure. One common use of 647 this structure is to identify a messaging and presence account, the 648 server that hosts the account, and a connected resource (e.g., a 649 specific device) in the form of . However, 650 node types other than clients are possible; for example, a specific 651 chat room offered by a multi-user conference service (see [XEP-0045]) 652 could be addressed as (where "room" is the name of the 653 chat room and "service" is the hostname of the multi-user conference 654 service) and a specific occupant of such a room could be addressed as 655 (where "nick" is the occupant's room nickname). 656 Many other JID types are possible (e.g., could be a 657 server-side script or service). 659 Each allowable portion of a JID (node identifier, domain identifier, 660 and resource identifier) MUST NOT be more than 1023 bytes in length, 661 resulting in a maximum total size (including the '@' and '/' 662 separators) of 3071 bytes. 664 Note: While the format of a JID is consistent with [URI], an 665 entity's address on an XMPP network MUST be represented as a JID 666 (without a URI scheme) and not a [URI] or [IRI] as specified in 667 [XMPP-URI]; the latter specification is provided only for 668 identification and interaction outside the context of the XMPP 669 wire protocol itself. 671 3.2. Domain Identifier 673 The DOMAIN IDENTIFIER portion of a JID is that portion after the '@' 674 character (if any) and before the '/' character (if any); it is the 675 primary identifier and is the only REQUIRED element of a JID (a mere 676 domain identifier is a valid JID). Typically a domain identifier 677 identifies the "home" server to which clients connect for XML routing 678 and data management functionality. However, it is not necessary for 679 an XMPP domain identifier to identify an entity that provides core 680 XMPP server functionality (e.g., a domain identifier can identity an 681 entity such as a multi-user conference service, a publish-subscribe 682 service, or a user directory). 684 Note: A single server can service multiple domain identifiers, 685 i.e., multiple local domains; this is typically referred to as 686 virtual hosting. 688 The domain identifier for every server or service that will 689 communicate over a network SHOULD be a fully qualified domain name 690 (see [DNS]); while the domain identifier MAY be either an Internet 691 Protocol (IPv4 or IPv6) address or a text label that is resolvable on 692 a local network (commonly called an "unqualified hostname"), it is 693 possible that domain identifiers that are IP addresses will not be 694 acceptable to other services for the sake of interdomain 695 communication. Furthermore, domain identifiers that are unqualified 696 hostnames MUST NOT be used on public networks but MAY be used on 697 private networks. 699 Note: If the domain identifier includes a final character 700 considered to be a label separator (dot) by [IDNA] or [DNS], this 701 character MUST be stripped from the domain identifier before the 702 JID of which it is a part is used for the purpose of routing an 703 XML stanza, comparing against another JID, or constructing an 704 [XMPP-URI]; in particular, the character MUST be stripped before 705 any other canonicalization steps are taken, such as application of 706 the [NAMEPREP] profile of [STRINGPREP] or completion of the 707 ToASCII operation as described in [IDNA]. 709 A domain identifier MUST be an "internationalized domain name" as 710 defined in [IDNA], that is, "a domain name in which every label is an 711 internationalized label". When preparing a text label (consisting of 712 a sequence of Unicode code points) for representation as an 713 internationalized label in the process of constructing an XMPP domain 714 identifier or comparing two XMPP domain identifiers, an application 715 MUST ensure that for each text label it is possible to apply without 716 failing the ToASCII operation specified in [IDNA] with the 717 UseSTD3ASCIIRules flag set (thus forbidding ASCII code points other 718 than letters, digits, and hyphens). If the ToASCII operation can be 719 applied without failing, then the label is an internationalized 720 label. An internationalized domain name (and therefore an XMPP 721 domain identifier) is constructed from its constituent 722 internationalized labels by following the rules specified in [IDNA]. 724 Note: The ToASCII operation includes application of the [NAMEPREP] 725 profile of [STRINGPREP] and encoding using the algorithm specified 726 in [PUNYCODE]; for details, see [IDNA]. Although the output of 727 the ToASCII operation is not used in XMPP, it MUST be possible to 728 apply that operation without failing. 730 3.3. Node Identifier 732 The NODE IDENTIFIER portion of a JID is an optional secondary 733 identifier placed before the domain identifier and separated from the 734 latter by the '@' character. Typically a node identifier uniquely 735 identifies the entity requesting and using network access provided by 736 a server (i.e., a local account), although it can also represent 737 other kinds of entities (e.g., a chat room associated with a multi- 738 user conference service). The entity represented by an XMPP node 739 identifier is addressed within the context of a specific domain. 741 A node identifier MUST be formatted such that the Nodeprep profile of 743 [STRINGPREP] can be applied without failing (see Appendix A). Before 744 comparing two node identifiers, an application MUST first ensure that 745 the Nodeprep profile has been applied to each identifier (the profile 746 need not be applied each time a comparison is made, as long as it has 747 been applied before comparison). 749 3.4. Resource Identifier 751 The RESOURCE IDENTIFIER portion of a JID is an optional tertiary 752 identifier placed after the domain identifier and separated from the 753 latter by the '/' character. A resource identifier can modify either 754 a address or a mere address. Typically a 755 resource identifier uniquely identifies a specific connection (e.g., 756 a device or location) or object (e.g., a participant in a multi-user 757 conference room) belonging to the entity associated with an XMPP node 758 identifier at a local domain. 760 When an XMPP address does not include a resource identifier (i.e., 761 when it is of the form or ), it is referred to 762 as a BARE JID. When an XMPP address includes a resource identifier 763 (i.e., when it is of the form or 764 ), is referred to as a FULL JID. 766 A resource identifier MUST be formatted such that the Resourceprep 767 profile of [STRINGPREP] can be applied without failing (see 768 Appendix B). Before comparing two resource identifiers, an 769 application MUST first ensure that the Resourceprep profile has been 770 applied to each identifier (the profile need not be applied each time 771 a comparison is made, as long as it has been applied before 772 comparison). 774 Note: For historical reasons, the term "resource identifier" is 775 used in XMPP to refer to the optional portion of an XMPP address 776 that follows the domain identifier and the "/" separator 777 character; this use of the term "resource identifier" is not to be 778 confused with the meanings of "resource" and "identifier" provided 779 in Section 1.1 of [URI]. 781 XMPP entities SHOULD consider resource identifiers to be opaque 782 strings and SHOULD NOT impute meaning to any given resource 783 identifier. In paticular, the use of the '/' character as a 784 separator between the domain identifier and the resource identifier 785 does not imply that resource identifiers are hierarchical in the say 786 that, say, HTTP addresses are hierarchical; thus for example an XMPP 787 address of the form does not identify a 788 resource "bar" that exists below a resource "foo" in a hierarchy of 789 resources associated with the entity "node@domain". 791 3.5. Determination of Addresses 793 After the parties to an XML stream have completed the appropriate 794 aspects of stream negotiation (typically SASL negotiation (Section 7) 795 and, if appropriate, resource binding (Section 8)) the receiving 796 entity for a stream MUST determine the initiating entity's JID. 798 For server-to-server communication, the initiating server's JID MUST 799 be the authorization identity (as defined by [SASL]), either (1) as 800 directly communicated by the initiating server during SASL 801 negotiation (Section 7) or (2) as derived by the receiving server 802 from the authentication identity if no authorization identity was 803 specified during SASL negotiation (Section 7). (For information 804 about the determination of addresses in the absence of SASL 805 negotiation when the older server dialback protocol is used, see 806 [XEP-0220].) 808 For client-to-server communication, the client's bare JID 809 () MUST be the authorization identity (as defined by 810 [SASL]), either (1) as directly communicated by the client during 811 SASL negotiation (Section 7) or (2) as derived by the server from the 812 authentication identity if no authorization identity was specified 813 during SASL negotiation (Section 7). The resource identifier portion 814 of the full JID () MUST be the resource 815 identifier negotiated by the client and server during resource 816 binding (Section 8). 818 The receiving entity MUST ensure that the resulting JID (including 819 node identifier, domain identifier, resource identifier, and 820 separator characters) conforms to the rules and formats defined 821 earlier in this section; to meet this restriction, the receiving 822 entity MAY replace the JID sent by the initiating entity with the 823 canonicalized JID as determined by the receiving entity. 825 4. TCP Binding 827 4.1. Scope 829 As XMPP is defined in this specification, an initiating entity 830 (client or server) MUST open a Transmission Control Protocol [TCP] 831 connection at the receiving entity (server) before it negotiates XML 832 streams with the receiving entity. The rules specified in the 833 following sections apply to the TCP binding. 835 4.2. Hostname Resolution 837 Before opening the TCP connection, the initiating entity first MUST 838 resolve the Domain Name System (DNS) hostname associated with the 839 receiving entity and determine the appropriate TCP port for 840 communication with the receiving entity. The process is: 842 1. Attempt to resolve the hostname using (a) a [DNS-SRV] Service of 843 "xmpp-client" (for client-to-server connections) or "xmpp-server" 844 (for server-to-server connections) and (b) a Proto of "tcp", 845 resulting in resource records such as "_xmpp- 846 client._tcp.example.net." or "_xmpp-server._tcp.im.example.com.". 847 The result of the SRV lookup will be one or more combinations of 848 a port and hostname, which hostnames the initiating entity MUST 849 resolve according to returned SRV record weight (if the result of 850 the SRV lookup is a single RR with a Target of ".", i.e. the root 851 domain, the initiating entity MUST abort SRV processing but 852 SHOULD attempt a fallback resolution as described below). The 853 initiating entity uses the IP address(es) from the first 854 successfully resolved hostname (with the corresponding port 855 number returned by the SRV lookup) in order to connect to the 856 receiving entity. If the initiating entity fails to connect 857 using one of the IP addresses, the initiating entity uses the 858 next resolved IP address to connect. If the initiating entity 859 fails to connect using all resolved IP addresses, then the 860 initiating entity repeats the process of resolution and 861 connection for the next hostname returned by the SRV lookup. 862 2. If the SRV lookup aborts or fails, the fallback SHOULD be a 863 normal IPv4 or IPv6 address record resolution to determine the IP 864 address, where the port used is the "xmpp-client" port of 5222 865 for client-to-server connections or the "xmpp-server" port 5269 866 for server-to-server connections. 867 3. For client-to-server connections, the fallback MAY be a [DNS-TXT] 868 lookup for alternative connection methods, for example as 869 described in [XEP-0156]. 871 Note: If the initiating entity has been explicitly configured to 872 associate a particular hostname (and potentially port) with the 873 original hostname of the receiving entity (say, to "hardcode" an 874 association between an original hostname of example.net and a 875 configured hostname and of webcm.example.com:80), the initiating 876 entity SHALL use the configured name instead of performing the 877 foregoing resolution process on the original name. 879 Note: Many XMPP servers are implemented in such a way that they 880 can host additional services (beyond those defined in this 881 specification and [rfc3921bis]) at hostnames that are subdomains 882 of the hostname of the main XMPP service (e.g., 883 conference.example.net for a [XEP-0045] service associated with 884 the example.net XMPP service) or subdomains of the first-level 885 domain of the underlying host (e.g., muc.example.com for a 886 [XEP-0045] service associated with the im.example.com XMPP 887 service). If an entity from a remote domain wishes to use such 888 additional services, it would generate an appropriate XML stanza 889 and the remote domain itself would attempt to resolve the 890 service's hostname via an SRV lookup on resource records such as 891 "_xmpp-server._tcp.conference.example.net." or "_xmpp- 892 server._tcp.muc.example.com.". Therefore if a service wishes to 893 enable entities from remote domains to access these additional 894 services, it needs to advertise the appropriate "_xmpp-server" SRV 895 records in addition to the "_xmpp-server" record for its main XMPP 896 service. 898 4.3. Client-to-Server Communication 900 Because a client is subordinate to a server and therefore a client 901 authenticates to the server but the server does not necessarily 902 authenticate to the client, it is necessary to have only one TCP 903 connection between client and server. Thus the server MUST allow the 904 client to share a single TCP connection for XML stanzas sent from 905 client to server and from server to client (i.e., the inital stream 906 and response stream as specified under Section 5). 908 4.4. Server-to-Server Communication 910 Because two servers are peers and therefore each peer MUST 911 authenticate with the other, the servers MUST use two TCP 912 connections: one for XML stanzas sent from the first server to the 913 second server and another (initiated by the second server) for XML 914 stanzas from the second server to the first server. 916 This rule applies only to XML stanzas (Section 9). Therefore during 917 STARTTLS negotiation (Section 6) and SASL negotiation (Section 7) the 918 servers would use one TCP connection, but after stream setup that TCP 919 connection would be used only for the initiating server to send XML 920 stanzas to the receiving server. In order for the receiving server 921 to send XML stanzas to the initiating server, the receiving server 922 would need to reverse the roles and negotiate an XML stream from the 923 receiving server to the initiating server. 925 4.5. Reconnection 927 It can happen that an XMPP server goes offline while servicing TCP 928 connections from local clients and from other servers. Because the 929 number of such connections can be quite large, the reconnection 930 algorithm employed by entities that seek to reconnect can have a 931 significant impact on software and network performance. The 932 following guidelines are RECOMMENDED: 934 o The time to live (TTL) specified in Domain Name System records 935 MUST be honored, even if DNS results are cached; if the TTL has 936 not expired, an entity that seeks to reconnect MUST NOT re-resolve 937 the server hostname before reconnecting. 938 o The time that expires before an entity first seeks to reconnect 939 MUST be randomized (e.g., so that all clients do not attempt to 940 reconnect exactly 30 seconds after being disconnected). 941 o If the first reconnection attempt does not succeed, an entity MUST 942 back off increasingly on the time between subsequent reconnection 943 attempts. 945 Note: Because it is possible that a disconnected entity cannot 946 determine the cause of disconnection (e.g., because there was no 947 explicit stream error) or does not require a new stream for 948 immediate communication (e.g., because the stream was idle and 949 therefore timed out), it SHOULD NOT assume that is needs to 950 reconnect immediately. 952 4.6. Other Bindings 954 There is no necessary coupling of an XML stream to a TCP connection. 955 For example, two entities could connect to each other via another 956 transport, such as [HTTP] as specified in [XEP-0124] and [XEP-0206]. 957 Although this specification neither encourages nor discourages other 958 bindings, it defines only a binding of XMPP to TCP. 960 5. XML Streams 962 5.1. Overview 964 Two fundamental concepts make possible the rapid, asynchronous 965 exchange of relatively small payloads of structured information 966 between presence-aware entities: XML streams and XML stanzas. These 967 terms are defined as follows. 969 Definition of XML Stream: An XML STREAM is a container for the 970 exchange of XML elements between any two entities over a network. 971 The start of an XML stream is denoted unambiguously by an opening 972 STREAM HEADER (i.e., an XML tag with appropriate 973 attributes and namespace declarations), while the end of the XML 974 stream is denoted unambiguously by a closing XML tag. 975 During the life of the stream, the entity that initiated it can 976 send an unbounded number of XML elements over the stream, either 977 elements used to negotiate the stream (e.g., to complete TLS 978 negotiation (Section 6) or SASL negotiation (Section 7)) or XML 979 stanzas. The INITIAL STREAM is negotiated from the initiating 980 entity (typically a client or server) to the receiving entity 981 (typically a server), and can be seen as corresponding to the 982 initiating entity's "connection" or "session" with the receiving 983 entity. The initial stream enables unidirectional communication 984 from the initiating entity to the receiving entity; in order to 985 enable information exchange from the receiving entity to the 986 initiating entity, the receiving entity MUST negotiate a stream in 987 the opposite direction (the RESPONSE STREAM). 988 Definition of XML Stanza: An XML STANZA is a discrete semantic unit 989 of structured information that is sent from one entity to another 990 over an XML stream, and is the basic unit of meaning in XMPP. An 991 XML stanza exists at the direct child level of the root 992 element; the start of any XML stanza is denoted unambiguously by 993 the element start tag at depth=1 of the XML stream (e.g., 994 ), and the end of any XML stanza is denoted 995 unambiguously by the corresponding close tag at depth=1 (e.g., 996 ). The only XML stanzas defined herein are the 997 , , and elements qualified by the 998 default namespace for the stream, as described under Section 9; 999 for example, an XML element sent for the purpose of TLS 1000 negotiation (Section 6) or SASL negotiation (Section 7) is not 1001 considered to be an XML stanza, nor is a stream error or a stream 1002 feature. An XML stanza MAY contain child elements (with 1003 accompanying attributes, elements, and XML character data) as 1004 necessary in order to convey the desired information, which MAY be 1005 qualified by any XML namespace (see [XML-NAMES] as well as 1006 Section 9.4 herein). 1008 Consider the example of a client's connection to a server. In order 1009 to connect to a server, a client initiates an XML stream by sending a 1010 stream header to the server, optionally preceded by a text 1011 declaration specifying the XML version and the character encoding 1012 supported (see Section 12.5 and Section 12.6). Subject to local 1013 policies and service provisioning, the server then replies with a 1014 second XML stream back to the client, again optionally preceded by a 1015 text declaration. Once the client has completed SASL negotiation 1016 (Section 7) and resource binding (Section 8), the client can send an 1017 unbounded number of XML stanzas over the stream. When the client 1018 desires to close the stream, it simply sends a closing tag 1019 to the server as further described under Section 5.7. 1021 In essence, then, an XML stream acts as an envelope for all the XML 1022 stanzas sent during a connection. We can represent this in a 1023 simplistic fashion as follows. 1025 +--------------------+ 1026 | | 1027 |--------------------| 1028 | | 1029 | | 1030 | | 1031 |--------------------| 1032 | | 1033 | | 1034 | | 1035 |--------------------| 1036 | | 1037 | | 1038 | | 1039 |--------------------| 1040 | | 1041 | | 1042 | | 1043 |--------------------| 1044 | [ ... ] | 1045 |--------------------| 1046 | | 1047 +--------------------+ 1049 Note: Those who are accustomed to thinking of XML in a document- 1050 centric manner might view a client's connection to a server as 1051 consisting of two open-ended XML documents: one from the client to 1052 the server and one from the server to the client. On this 1053 analogy, the two XML streams can be considered equivalent to two 1054 "documents" (matching production [1] content of [XML]) that are 1055 built up through the accumulation of XML stanzas, the root 1056 element can be considered equivalent to the "document 1057 entity" for each "document" (as described in Section 4.8 of 1058 [XML]), and the XML stanzas sent over the streams can be 1059 considered equivalent to "fragments" of the "documents" as 1060 described in [XML-FRAG]. However, this perspective is merely an 1061 analogy; XMPP does not deal in documents and fragments but in 1062 streams and stanzas. 1064 5.2. Stream Security 1066 For the purpose of stream security, both Transport Layer Security 1067 (see Section 6) and the Simple Authentication and Security Layer (see 1068 Section 7) are mandatory to implement. Use of these technologies 1069 results in high security as described under Section 15.1. 1071 The initial stream and the response stream MUST be secured 1072 separately, although security in both directions MAY be established 1073 via mechanisms that provide mutual authentication. 1075 The initiating entity MUST NOT attempt to send XML stanzas 1076 (Section 9) over the stream before the stream has been authenticated. 1077 However, if it does attempt to do so, the receiving entity MUST NOT 1078 accept such stanzas and MUST return a stream error. 1079 This rule applies to XML stanzas only (i.e., , , 1080 and elements qualified by the default namespace) and not to XML 1081 elements used for stream negotiation (e.g., elements used to complete 1082 TLS negotiation (Section 6) or SASL negotiation (Section 7)). 1084 5.3. Stream Attributes 1086 The attributes of the root element are defined in the 1087 following sections. 1089 Note: The attributes of the root element are not 1090 prepended by a 'stream:' prefix because, as explained in 1091 [XML-NAMES], "[d]efault namespace declarations do not apply 1092 directly to attribute names; the interpretation of unprefixed 1093 attributes is determined by the element on which they appear." 1095 5.3.1. from 1097 The 'from' attribute communicates an XMPP identity of the entity 1098 sending the stream element. 1100 Note: It is possible for an entity to have more than one XMPP 1101 identity (e.g., in the case of a server that provides virtual 1102 hosting). It is also possible that an entity does not know the 1103 XMPP identity of the principal controlling the entity (e.g., 1104 because the XMPP identity is assigned at a level other than the 1105 XMPP application layer, as in the General Security Service 1106 Application Program Interface [GSS-API]). 1108 For initial stream headers in client-to-server communication, if the 1109 client knows the XMPP identity of the principal controlling the 1110 client (typically an account name of the form ), then it 1111 SHOULD include the 'from' attribute and set its value to that 1112 identity. If the client does not know the XMPP identity of the 1113 principal controlling the client, then it MUST NOT include the 'from' 1114 attribute. 1116 I: 1117 1125 For initial stream headers in server-to-server communication, a 1126 server MUST include the 'from' attribute and MUST set its value to a 1127 hostname serviced by the initiating entity. 1129 I: 1130 1138 For response stream headers in both client-to-server and server-to- 1139 server communication, the receiving entity MUST include the 'from' 1140 attribute and MUST set its value to a hostname serviced by the 1141 receiving entity (which MAY be a hostname other than that specified 1142 in the 'to' attribute of the initial stream header). 1144 R: 1145 1154 Whether or not the 'from' attribute is included, each entity MUST 1155 verify the identity of the other entity before exchanging XML stanzas 1156 with it (see Section 15.3 and Section 15.4). 1158 Note: It is possible that implementations based on an earlier 1159 revision of this specification will not include the 'from' address 1160 on stream headers; an entity SHOULD be liberal in accepting such 1161 stream headers. 1163 5.3.2. to 1165 For initial stream headers in both client-to-server and server-to- 1166 server communication, the initiating entity MUST include the 'to' 1167 attribute and MUST set its value to a hostname that the initiating 1168 entity knows or expects the receiving entity to service. 1170 I: 1171 1179 For response stream headers in client-to-server communication, if the 1180 client included a 'from' attribute in the initial stream header then 1181 the server MUST include a 'to' attribute in the response stream 1182 header and MUST set its value to the bare JID specified in the 'from' 1183 attribute of the initial stream header. If the client did not 1184 include a 'from' attribute in the initial stream header then the 1185 server MUST NOT include a 'to' attribute in the response stream 1186 header. 1188 R: 1189 1198 For response stream headers in server-to-server communication, the 1199 receiving entity MUST include a 'to' attribute in the response stream 1200 header and MUST set its value to the hostname specified in the 'from' 1201 attribute of the initial stream header. 1203 R: 1204 1213 Whether or not the 'to' attribute is included, each entity MUST 1214 verify the identity of the other entity before exchanging XML stanzas 1215 with it (see Section 15.3 and Section 15.4). 1217 Note: It is possible that implementations based on an earlier 1218 revision of this specification will not include the 'to' address 1219 on stream headers; an entity SHOULD be liberal in accepting such 1220 stream headers. 1222 5.3.3. id 1224 The 'id' attribute communicates a unique identifier for the stream. 1225 This identifier is called a STREAM ID. The stream ID MUST be 1226 generated by the receiving entity when it sends a response stream 1227 header, MUST BE unique within the receiving application (normally a 1228 server), and MUST be both unpredictable and nonrepeating because it 1229 can be security-critical (see [RANDOM] for recommendations regarding 1230 randomness for security purposes). 1232 For initial stream headers, the initiating entity MUST NOT include 1233 the 'id' attribute; however, if the 'id' attribute is included, the 1234 receiving entity MUST silently ignore it. 1236 For response stream headers, the receiving entity MUST include the 1237 'id' attribute. 1239 R: 1240 1249 5.3.4. xml:lang 1251 The 'xml:lang' attribute communicates an entity's preferred or 1252 default language for any human-readable XML character data to be sent 1253 over the stream. The syntax of this attribute is defined in Section 1254 2.12 of [XML]; in particular, the value of the 'xml:lang' attribute 1255 MUST conform to the NMTOKEN datatype (as defined in Section 2.3 of 1256 [XML]) and MUST conform to the language identifier format defined in 1257 [LANGTAGS]. 1259 For initial stream headers, the initiating entity SHOULD include the 1260 'xml:lang' attribute. 1262 I: 1263 1271 For response stream headers, the receiving entity MUST include the 1272 'xml:lang' attribute. If the initiating entity included an 'xml: 1273 lang' attribute in its initial stream header and the receiving entity 1274 supports that language in the human-readable XML character data that 1275 it generates and sends to the initiating entity (e.g., in the 1276 element for stream and stanza errors), the value of the 'xml:lang' 1277 attribute MUST be identifier for the initiating entity's preferred 1278 language; if the receiving entity supports a language that closely 1279 matches the initiating entity's preferred language (e.g., "de" 1280 instead of "de-CH"), then the value of the 'xml:lang' attribute 1281 SHOULD be the identifier for the matching language but MAY be the 1282 identifier for the default language of the receiving entity; if the 1283 receiving entity does not support the initiating entity's preferred 1284 language or a closely matching language (or the initiating entity did 1285 not include the 'xml:lang' attribute in its initial stream header), 1286 then the value of the 'xml:lang' attribute MUST be the identifier for 1287 the default language of the receiving entity. 1289 R: 1290 1299 If the initiating entity included the 'xml:lang' attribute in its 1300 initial stream header, the receiving entity SHOULD remember that 1301 value as the default xml:lang for all stanzas sent by the initiating 1302 entity. As described under Section 9.1.5, the initiating entity MAY 1303 include the 'xml:lang' attribute in any XML stanzas it sends over the 1304 stream. If the initiating entity does not include the 'xml:lang' 1305 attribute in any such stanza, the receiving entity SHOULD add the 1306 'xml:lang' attribute to the stanza, whose value MUST be the 1307 identifier for the language preferred by the initiating entity (even 1308 if the receiving entity does not support that language for human- 1309 readable XML character data it generates and sends to the initiating 1310 entity, such as in stream or stanza errors). If the initiating 1311 entity includes the 'xml:lang' attribute in any such stanza, the 1312 receiving entity MUST NOT modify or delete it. 1314 5.3.5. version 1316 The inclusion of the version attribute set to a value of at least 1317 "1.0" signals support for the stream-related protocols defined in 1318 this specification, including (TLS negotiation (Section 6), SASL 1319 negotiation (Section 7), Section 5.5, and stream errors 1320 (Section 5.8). 1322 The version of XMPP specified herein is "1.0"; in particular, XMPP 1323 1.0 encapsulates the stream-related protocols as well as the basic 1324 semantics of the three defined XML stanza types (, 1325 , and ). 1327 The numbering scheme for XMPP versions is ".". The 1328 major and minor numbers MUST be treated as separate integers and each 1329 number MAY be incremented higher than a single digit. Thus, "XMPP 1330 2.4" would be a lower version than "XMPP 2.13", which in turn would 1331 be lower than "XMPP 12.3". Leading zeros (e.g., "XMPP 6.01") MUST be 1332 ignored by recipients and MUST NOT be sent. 1334 The major version number will be incremented only if the stream and 1335 stanza formats or required actions have changed so dramatically that 1336 an older version entity would not be able to interoperate with a 1337 newer version entity if it simply ignored the elements and attributes 1338 it did not understand and took the actions specified in the older 1339 specification. 1341 The minor version number will be incremented only if significant new 1342 capabilities have been added to the core protocol (e.g., a newly 1343 defined value of the 'type' attribute for message, presence, or IQ 1344 stanzas). The minor version number MUST be ignored by an entity with 1345 a smaller minor version number, but MAY be used for informational 1346 purposes by the entity with the larger minor version number (e.g., 1347 the entity with the larger minor version number would simply note 1348 that its correspondent would not be able to understand that value of 1349 the 'type' attribute and therefore would not send it). 1351 The following rules apply to the generation and handling of the 1352 'version' attribute within stream headers: 1354 1. The initiating entity MUST set the value of the 'version' 1355 attribute in the initial stream header to the highest version 1356 number it supports (e.g., if the highest version number it 1357 supports is that defined in this specification, it MUST set the 1358 value to "1.0"). 1359 2. The receiving entity MUST set the value of the 'version' 1360 attribute in the response stream header to either the value 1361 supplied by the initiating entity or the highest version number 1362 supported by the receiving entity, whichever is lower. The 1363 receiving entity MUST perform a numeric comparison on the major 1364 and minor version numbers, not a string match on 1365 ".". 1366 3. If the version number included in the response stream header is 1367 at least one major version lower than the version number included 1368 in the initial stream header and newer version entities cannot 1369 interoperate with older version entities as described, the 1370 initiating entity SHOULD generate an 1371 stream error. 1372 4. If either entity receives a stream header with no 'version' 1373 attribute, the entity MUST consider the version supported by the 1374 other entity to be "0.9" and SHOULD NOT include a 'version' 1375 attribute in the response stream header. 1377 5.3.6. Summary of Stream Attributes 1379 The following table summarizes the attributes of the root 1380 element. 1382 +----------+--------------------------+-------------------------+ 1383 | | initiating to receiving | receiving to initiating | 1384 +----------+--------------------------+-------------------------+ 1385 | to | JID of receiver | JID of initiator | 1386 | from | JID of initiator | JID of receiver | 1387 | id | silently ignored | stream identifier | 1388 | xml:lang | default language | default language | 1389 | version | XMPP 1.0+ supported | XMPP 1.0+ supported | 1390 +----------+--------------------------+-------------------------+ 1392 5.4. Namespace Declarations 1394 The stream element MUST possess both a streams namespace declaration 1395 and a default namespace declaration (as "namespace declaration" is 1396 defined in [XML-NAMES]). For detailed information regarding the 1397 streams namespace and default namespace, see Section 12.2. 1399 5.5. Stream Features 1401 If the initiating entity includes the 'version' attribute set to a 1402 value of at least "1.0" in the initial stream header, after sending 1403 the response stream header the receiving entity MUST send a 1404 child element (prefixed by the streams namespace prefix) 1405 to the initiating entity in order to announce any stream-level 1406 features that can be negotiated or capabilities that otherwise need 1407 to be advertised. 1409 R: 1410 1418 R: 1419 1420 1421 1422 1424 Stream features are used mainly to advertise TLS negotiation 1425 (Section 6), SASL negotiation (Section 7), and resource binding 1426 (Section 8); however, stream features also can be used to advertise 1427 features associated with various XMPP extensions. 1429 If it is mandatory for a feature to be successfully negotiated before 1430 the initiating entity will be allowed to proceed with the sending of 1431 XML stanzas or with further steps of the stream negotiation, the 1432 advertisement of that feature SHOULD include an empty 1433 child element but MAY include neither a element not an 1434 element (i.e., features default to required). 1436 R: 1437 1438 1439 1440 1442 If successful negotiation of a feature is discretionary, the 1443 advertisement of that feature MUST include an empty child 1444 element. 1446 R: 1447 1448 1449 1450 1452 If an entity does not understand or support a feature that has been 1453 advertised, it MUST still inspect the feature advertisement to 1454 determine if negotiation of the feature is mandatory. If negotiation 1455 of an unsupported feature is mandatory (as determined by inclusion of 1456 the child element or the absence of an child 1457 element), then the entity MUST abort the stream negotiation process. 1458 If negotiation of an unsupported feature is discretionary (as 1459 determined by inclusion of the child element or the 1460 absence of a child element), the entity MUST silently ignore the 1461 associated feature advertisement and proceed with the stream 1462 negotiation process. 1464 Note: Implementations based on an earlier revision of this 1465 specification do not include the child element and 1466 they include the child element only in the case of the 1467 STARTTLS feature. Entities MUST accept stream feature 1468 advertisements without the child elements, and SHOULD consider 1469 consider negotiation of such features to be discretionary. 1471 If it is necessary for a feature to be successfully negotiated before 1472 the initiating entity is allowed to proceed with the sending a non- 1473 security-related feature or with further steps of the stream 1474 negotiation, the receiving entity SHOULD NOT advertise any other 1475 stream features until the mandatory feature has been successfully 1476 negotiated; however, if the mandatory feature is security-critical 1477 (e.g., STARTTLS or SASL) then the receiving entity MUST NOT advertise 1478 any other stream features until the security-critical feature has 1479 been successfully negotiated. 1481 The order of child elements contained in any given 1482 element is not significant. 1484 After completing negotiation of any stream feature (even stream 1485 features that do not require a stream restart), the receiving entity 1486 MUST send an updated list of stream features to the initiating 1487 entity. However, if there are no features to be advertised then the 1488 receiving entity MUST send an empty element. 1490 R: 1491 1500 R: 1502 At any time after stream establishment, the receiving entity MAY send 1503 additional or modified stream feature advertisements (e.g., because a 1504 new feature has been enabled). 1506 5.6. Restarts During Stream Negotiation 1508 Certain stream features require the initiating entity to send a new 1509 initial stream header on successful negotiation of the feature (e.g., 1510 after successful negotiation of TLS or SASL). Both parties MUST 1511 consider the previous stream to be replaced on successful feature 1512 negotiation but MUST NOT terminate the underlying TCP connection; 1513 instead, the parties MUST reuse the existing connection, which might 1514 be in a new state (e.g., encrypted as a result of TLS negotiation). 1515 When the receiving entity receives the new initial stream header, it 1516 MUST generate a new stream ID (instead of re-using the old stream ID) 1517 before sending a new response stream header. 1519 5.7. Closing a Stream 1521 An XML stream between two entities can be closed because a stream 1522 error has occurred or in some cases in the absence of an error. 1523 Where feasible, it is preferable to close a stream only if a stream 1524 error has occurred. 1526 A stream is closed by sending a closing tag over the TCP 1527 connection. 1529 S: 1531 After an entity sends a closing stream tag, it MUST NOT send further 1532 data over that stream. 1534 5.7.1. With Stream Error 1536 If a stream error has occurred, the entity that detects the error 1537 MUST close the stream as described under Section 5.8.1. 1539 5.7.2. Without Stream Error 1541 At any time after XML streams have been negotiated between two 1542 entities, either entity MAY close its stream to the other party in 1543 the absence of a stream error by sending a closing stream tag. 1545 P: 1547 The entity that sends the closing stream tag SHOULD wait for the 1548 other party to also close its stream. 1550 S: 1552 However, the entity that sends the first closing stream tag MAY 1553 consider both streams to be void if the other party does not send its 1554 closing stream tag within a reasonable amount of time (where the 1555 definition of "reasonable" is a matter of implementation or 1556 deployment). 1558 After the entity that sent the first closing stream tag receives a 1559 reciprocal closing stream tag from the other party (or if it 1560 considers the stream to be void after a reasonable amount of time), 1561 it MUST terminate the underlying TCP connection or connections. 1563 5.7.3. Handling of Idle Streams 1565 An XML stream can become idle, i.e., neither entity has sent XMPP 1566 traffic over the stream for some period of time. The idle timeout 1567 period is a matter of implementation and local service policy; 1568 however, it is RECOMMENDED to be liberal in accepting idle streams, 1569 since experience has shown that doing so improves the reliability of 1570 communications over XMPP networks. In particular, it is typically 1571 more efficient to maintain a stream between two servers than it is to 1572 aggressively timeout such a stream, especially with regard to 1573 synchronization of presence information as described in [rfc3921bis]; 1574 therefore it is RECOMMENDED to maintain such a stream since 1575 experience has shown that server-to-server streams are cyclical and 1576 typically need to be re-established every 24 to 48 hours if they are 1577 timed out. 1579 An XML stream can appear idle at the XMPP level because the 1580 underlying TCP connection has become idle (e.g., a client's network 1581 connection has been lost). The typical method for detecting an idle 1582 TCP connection is to send a space character (U+0020) over the TCP 1583 connection between XML stanzas, which is allowed for XML streams as 1584 described under Section 12.7. The sending of such a space character 1585 is called a WHITESPACE PING. The time between such whitespace pings 1586 (or other connection-testing methods) is a matter of implementation 1587 and local service policy; however, it is RECOMMENDED that these pings 1588 be sent not more than once every 60 seconds. 1590 To close an idle stream with a local client or remote server, a 1591 server MUST close the stream without error as explained under 1592 Section 5.7.2. 1594 5.8. Stream Errors 1596 The root stream element MAY contain an child element that is 1597 prefixed by the streams namespace prefix. The error child shall be 1598 sent by a compliant entity if it perceives that a stream-level error 1599 has occurred. 1601 5.8.1. Rules 1603 The following rules apply to stream-level errors. 1605 5.8.1.1. Stream Errors Are Unrecoverable 1607 Stream-level errors are unrecoverable. Therefore, if an error occurs 1608 at the level of the stream, the entity that detects the error MUST 1609 send a element with an appropriate child element that 1610 specifies the error condition and at the same time send a closing 1611 tag. 1613 C: 1615 S: 1616 1618 1619 1621 The entity that generates the stream error then SHOULD immediately 1622 terminate the underlying TCP connection, although it MAY wait until 1623 after it receives a closing tag from the entity to which it 1624 sent the stream error. 1626 C: 1628 5.8.1.2. Stream Errors Can Occur During Setup 1630 If the error is triggered by the initial stream header, the receiving 1631 entity MUST still send the opening tag, include the 1632 element as a child of the stream element, and send the closing 1633 tag (preferably all at the same time). 1635 C: 1636 1644 S: 1645 1654 1656 1657 1659 5.8.1.3. Stream Errors When the Host is Unspecified or Unknown 1661 If the initiating entity provides no 'to' attribute or provides an 1662 unknown host in the 'to' attribute and the error occurs during stream 1663 setup, the receiving entity SHOULD provide an authoritative hostname 1664 in the 'from' attribute of the stream header sent before termination, 1665 but absent such an authoritative hostname MAY instead simply populate 1666 the response stream's 'from' attribute with the value of the initial 1667 stream header's 'to' attribute (where the value of the 'from' 1668 attribute MAY be empty if the initiating entity provided no 'to' 1669 attribute). 1671 C: 1672 1680 S: 1681 1689 1690 1692 1693 1695 5.8.2. Syntax 1697 The syntax for stream errors is as follows, where "defined-condition" 1698 is a placeholder for one of the conditions defined under 1699 Section 5.8.3. 1701 1702 1703 [ 1705 [ ... descriptive text ... ] 1706 ] 1707 [application-specific condition element] 1708 1710 The element: 1712 o MUST contain a child element corresponding to one of the defined 1713 stream error conditions (Section 5.8.3); this element MUST be 1714 qualified by the 'urn:ietf:params:xml:ns:xmpp-streams' namespace. 1715 o MAY contain a child element containing XML character data 1716 that describes the error in more detail; this element MUST be 1717 qualified by the 'urn:ietf:params:xml:ns:xmpp-streams' namespace 1718 and SHOULD possess an 'xml:lang' attribute specifying the natural 1719 language of the XML character data. 1720 o MAY contain a child element for an application-specific error 1721 condition; this element MUST be qualified by an application- 1722 defined namespace, and its structure is defined by that namespace 1723 (see Section 5.8.4). 1725 The element is OPTIONAL. If included, it MUST be used only 1726 to provide descriptive or diagnostic information that supplements the 1727 meaning of a defined condition or application-specific condition. It 1728 MUST NOT be interpreted programmatically by an application. It MUST 1729 NOT be used as the error message presented to a human user, but MAY 1730 be shown in addition to the error message associated with the defined 1731 condition element (and, optionally, the application-specific 1732 condition element). 1734 5.8.3. Defined Stream Error Conditions 1736 The following stream-level error conditions are defined. 1738 5.8.3.1. bad-format 1740 The entity has sent XML that cannot be processed. 1742 (In the following example, the client sends an XMPP message that is 1743 not well-formed XML.) 1745 C: 1746 No closing body tag! 1747 1749 S: 1750 1752 1753 1755 This error MAY be used instead of the more specific XML-related 1756 errors, such as , , , , and . However, 1758 the more specific errors are RECOMMENDED. 1760 5.8.3.2. bad-namespace-prefix 1762 The entity has sent a namespace prefix that is unsupported, or has 1763 sent no namespace prefix on an element that requires such a prefix 1764 (see Section 12.2). 1766 (In the following example, the client specifies a namespace prefix of 1767 "foobar" for the XML streams namespace.) 1769 C: 1770 1777 S: 1778 1786 1787 1789 1790 1792 5.8.3.3. conflict 1794 The server is either (1) closing the existing stream for this entity 1795 because a new stream has been initiated that conflicts with the 1796 existing stream, or (2) is refusing a new stream for this entity 1797 because allowing the new stream would conflict with an existing 1798 stream (e.g., because the server allows only a certain number of 1799 connections from the same IP address). 1801 C: 1802 1809 S: 1810 1818 1819 1821 1822 1824 5.8.3.4. connection-timeout 1826 The entity has not generated any traffic over the stream for some 1827 period of time (configurable according to a local service policy) and 1828 therefore the connection is being dropped. 1830 P: 1831 1833 1834 1836 5.8.3.5. host-gone 1838 The value of the 'to' attribute provided in the initial stream header 1839 corresponds to a hostname that is no longer serviced by the receiving 1840 entity. 1842 (In the following example, the peer specifies a 'to' address of 1843 "foo.im.example.com" when connecting to the "im.example.com" server, 1844 but the server no longer hosts a service at that address.) 1845 P: 1846 1853 S: 1854 1862 1863 1865 1866 1868 5.8.3.6. host-unknown 1870 The value of the 'to' attribute provided in the initial stream header 1871 does not correspond to a hostname that is serviced by the receiving 1872 entity. 1874 (In the following example, the peer specifies a 'to' address of 1875 "example.org" when connecting to the "im.example.com" server, but the 1876 server knows nothing of that address.) 1877 P: 1878 1885 S: 1886 1894 1895 1897 1898 1900 5.8.3.7. improper-addressing 1902 A stanza sent between two servers lacks a 'to' or 'from' attribute, 1903 the 'from' or 'to' attribute has no value, or the value is not a 1904 valid XMPP address. 1906 (In the following example, the peer sends a stanza without a 'to' 1907 address.) 1909 P: 1910 Wherefore art thou? 1911 1913 S: 1914 1916 1917 1919 5.8.3.8. internal-server-error 1921 The server has experienced a misconfiguration or an otherwise- 1922 undefined internal error that prevents it from servicing the stream. 1924 S: 1925 1927 1928 1930 5.8.3.9. invalid-from 1932 The JID or hostname provided in a 'from' address is not a valid JID 1933 or does not match an authorized JID or validated domain as negotiated 1934 between servers via SASL or server dialback, or as negotiated between 1935 a client and a server via authentication and resource binding. 1937 (In the following example, a peer that has authenticated only as 1938 "example.net" attempts to send a stanza from an address at 1939 "example.org".) 1941 P: 1942 Neither, fair saint, if either thee dislike. 1943 1945 S: 1946 1948 1949 1951 5.8.3.10. invalid-id 1953 The stream ID or server dialback ID is invalid or does not match an 1954 ID previously provided. 1956 (In the following example, the server dialback ID is invalid; see 1957 [XEP-0220].) 1959 P: 1965 S: 1966 1968 1969 1971 5.8.3.11. invalid-namespace 1973 The streams namespace name is something other than 1974 "http://etherx.jabber.org/streams" (see Section 12.2) or the default 1975 namespace is not supported (e.g., something other than "jabber: 1976 client" or "jabber:server"). 1978 (In the following example, the client specifies a streams namespace 1979 of 'http://wrong.namespace.example.org/'.) 1981 C: 1982 1989 S: 1990 1998 1999 2001 2002 2004 5.8.3.12. invalid-xml 2006 The entity has sent invalid XML over the stream to a server that 2007 performs validation (see Section 12.4). 2009 (In the following example, the peer attempts to send an IQ stanza of 2010 type "subscribe" but the XML schema defines no such value for the 2011 'type' attribute.) 2012 P: 2016 2017 2019 S: 2020 2022 2023 2025 5.8.3.13. not-authorized 2027 The entity has attempted to send XML stanzas before the stream has 2028 been authenticated, or otherwise is not authorized to perform an 2029 action related to stream negotiation; the receiving entity MUST NOT 2030 process the offending stanza before sending the stream error. 2032 (In the following example, the client attempts to send XML stanzas 2033 before authenticating with the server.) 2034 C: 2035 2042 S: 2043 2053 Wherefore art thou? 2054 2056 S: 2057 2059 2060 2062 5.8.3.14. policy-violation 2064 The entity has violated some local service policy (e.g., the stanza 2065 exceeds a configured size limit); the server MAY choose to specify 2066 the policy in the element or in an application-specific 2067 condition element. 2069 (In the following example, the client sends an XMPP message that is 2070 too large according to the server's local service policy.) 2072 C: 2073 [ ... the-emacs-manual ... ] 2074 2076 S: 2077 2079 2081 S: 2083 5.8.3.15. remote-connection-failed 2085 The server is unable to properly connect to a remote entity that is 2086 required for authentication or authorization, such as a remote 2087 authentication database or (in server dialback) the authoritative 2088 server. 2090 C: 2091 2098 S: 2099 2107 2108 2110 2111 2113 5.8.3.16. resource-constraint 2115 The server lacks the system resources necessary to service the 2116 stream. 2118 C: 2119 2126 S: 2127 2135 2136 2138 2139 2141 5.8.3.17. restricted-xml 2143 The entity has attempted to send restricted XML features such as a 2144 comment, processing instruction, DTD subset, or XML entity reference 2145 (see Section 12.1). 2147 (In the following example, the client sends an XMPP message 2148 containing an XML comment.) 2150 C: 2151 2152 This message has no subject. 2153 2155 S: 2156 2158 2159 2161 5.8.3.18. see-other-host 2163 The server will not provide service to the initiating entity but is 2164 redirecting traffic to another host; the XML character data of the 2165 element returned by the server SHOULD specify the 2166 alternate hostname or IP address at which to connect, which SHOULD be 2167 a valid domain identifier but MAY also include a port number. When 2168 it receives a see-other-host stream error, the initiating entity 2169 SHOULD cleanly handle the disconnection and then reconnect to the 2170 host specified in the element; if no port is 2171 specified, the initiating entity SHOULD perform a [DNS-SRV] lookup on 2172 the provided domain identifier but MAY assume that it can connect to 2173 that domain identifier at the standard XMPP ports (i.e., 5222 for 2174 client-to-server connections and 5269 for server-to-server 2175 connections). 2177 C: 2178 2185 S: 2186 2194 2195 2197 im.example.com:9090 2198 2199 2200 2202 5.8.3.19. system-shutdown 2204 The server is being shut down and all active streams are being 2205 closed. 2207 S: 2208 2210 2211 2213 5.8.3.20. undefined-condition 2215 The error condition is not one of those defined by the other 2216 conditions in this list; this error condition SHOULD be used only in 2217 conjunction with an application-specific condition. 2219 S: 2220 2222 2223 2224 2226 5.8.3.21. unsupported-encoding 2228 The initiating entity has encoded the stream in an encoding that is 2229 not supported by the server (see Section 12.6) or has otherwise 2230 improperly encoded the stream (e.g., by violating the rules of the 2231 [UTF-8] encoding). 2233 (In the following example, the client attempts to encode data using 2234 UTF-16 instead of UTF-8.) 2236 C: 2237 2244 S: 2245 2254 2256 2257 2259 5.8.3.22. unsupported-stanza-type 2261 The initiating entity has sent a first-level child of the stream that 2262 is not supported by the server or consistent with the default 2263 namespace. 2265 (In the following example, the client attempts to send an XML stanza 2266 of when the default namespace is "jabber:client".) 2268 C: 2269 2270 2271 2272 Soliloquy 2273 2274 To be, or not to be: that is the question: 2275 Whether 'tis nobler in the mind to suffer 2276 The slings and arrows of outrageous fortune, 2277 Or to take arms against a sea of troubles, 2278 And by opposing end them? 2279 2280 2282 tag:denmark.example,2003:entry-32397 2283 2003-12-13T18:30:02Z 2284 2003-12-13T18:30:02Z 2285 2286 2287 2288 2290 S: 2291 2293 2294 2296 5.8.3.23. unsupported-version 2298 The value of the 'version' attribute provided by the initiating 2299 entity in the stream header specifies a version of XMPP that is not 2300 supported by the server; the server MAY specify the version(s) it 2301 supports in the element. 2303 (In the following example, the client specifies an XMPP version of 2304 "11.0" but the server supports only version "1.0" and "1.1".) 2305 C: 2306 2313 S: 2314 2323 2325 2326 1.0, 1.1 2327 2328 2329 2331 5.8.3.24. xml-not-well-formed 2333 The initiating entity has sent XML that violates the well-formedness 2334 rules of [XML] or [XML-NAMES]. 2336 (In the following example, the client sends an XMPP message that is 2337 not well-formed XML.) 2339 C: 2340 No closing body tag! 2341 2343 S: 2344 2346 2347 2349 5.8.4. Application-Specific Conditions 2351 As noted, an application MAY provide application-specific stream 2352 error information by including a properly-namespaced child in the 2353 error element. The application-specific element SHOULD supplement or 2354 further qualify a defined element. Thus the element will 2355 contain two or three child elements. 2357 C: 2358 2359 My keyboard layout is: 2361 QWERTYUIOP{}| 2362 ASDFGHJKL:" 2363 ZXCVBNM<>? 2364 2365 2367 S: 2368 2370 2371 Some special application diagnostic information! 2372 2373 2374 2375 2377 5.9. Simplified Stream Examples 2379 This section contains two simplified examples of a stream-based 2380 connection between a client and a server; these examples are included 2381 for the purpose of illustrating the concepts introduced thus far. 2383 A basic connection: 2385 C: 2386 2395 2404 [ ... channel encryption ... ] 2406 [ ... authentication ... ] 2408 [ ... resource binding ... ] 2410 C: 2413 Art thou not Romeo, and a Montague? 2414 2416 S: 2419 Neither, fair saint, if either thee dislike. 2420 2422 C: 2424 S: 2425 A connection gone bad: 2427 C: 2428 2436 S: 2437 2446 [ ... channel encryption ... ] 2448 [ ... authentication ... ] 2450 [ ... resource binding ... ] 2452 C: 2455 No closing body tag! 2456 2458 S: 2459 2461 2462 2464 More detailed examples are provided under Section 10. 2466 6. STARTTLS Negotiation 2467 6.1. Overview 2469 XMPP includes a method for securing the stream from tampering and 2470 eavesdropping. This channel encryption method makes use of the 2471 Transport Layer Security [TLS] protocol, specifically a "STARTTLS" 2472 extension that is modelled after similar extensions for the [IMAP], 2473 [POP3], and [ACAP] protocols as described in [USINGTLS]. The XML 2474 namespace name for the STARTTLS extension is 2475 'urn:ietf:params:xml:ns:xmpp-tls'. 2477 Support for STARTTLS is REQUIRED in XMPP client and server 2478 implementations. An administrator of a given deployment MAY require 2479 the use of TLS for client-to-server communication, server-to-server 2480 communication, or both. A deployed client SHOULD use TLS to secure 2481 its stream with a server prior to attempting the completion of SASL 2482 negotiation (Section 7), and deployed servers SHOULD use TLS between 2483 two domains for the purpose of securing server-to-server 2484 communication. 2486 6.2. Rules 2488 6.2.1. Data Formatting 2490 During STARTTLS negotiation, the entities MUST NOT send any 2491 whitespace within the root stream element as separators between XML 2492 elements (i.e., from the last character of the element 2493 qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' namespace at 2494 depth=1 of the stream as sent by the initiating entity until the last 2495 character of the element qualified by the 2496 'urn:ietf:params:xml:ns:xmpp-tls' namespace at depth=1 of the stream 2497 as sent by the receiving entity). This prohibition helps to ensure 2498 proper security layer byte precision. Any such whitespace shown in 2499 the STARTTLS examples provided in this document is included only for 2500 the sake of readability. 2502 6.2.2. Order of Negotiation 2504 If the initiating entity chooses to use TLS, STARTTLS negotiation 2505 MUST be completed before proceeding to SASL negotiation (Section 7); 2506 this order of negotiation is required to help safeguard 2507 authentication information sent during SASL negotiation, as well as 2508 to make it possible to base the use of the SASL EXTERNAL mechanism on 2509 a certificate (or other credentials) provided during prior TLS 2510 negotiation. 2512 6.3. Process 2514 6.3.1. Exchange of Stream Headers and Stream Features 2516 The initiating entity resolves the hostname of the receiving entity 2517 as specified under Section 4, opens a TCP connection to the 2518 advertised port at the resolved IP address, and sends an initial 2519 stream header to the receiving entity; if the initiating entity is 2520 capable of STARTTLS negotiation, it MUST include the 'version' 2521 attribute set to a value of at least "1.0" in the initial stream 2522 header. 2524 I: 2532 The receiving entity MUST send a response stream header to the 2533 initiating entity over the TCP connection opened by the initiating 2534 entity; if the receiving entity is capable of STARTTLS negotiation, 2535 it MUST include the 'version' attribute set to a value of at least 2536 "1.0" in the response stream header. 2538 R: element qualified by the 2551 'urn:ietf:params:xml:ns:xmpp-tls' namespace. 2553 If the receiving entity considers STARTTLS negotiation to be 2554 discretionary, the element MUST contain an empty 2555 child element. 2557 R: 2558 2559 2560 2561 2563 If the receiving entity considers STARTTLS negotiation to be 2564 mandatory, the element MUST contain an empty 2565 child element. 2567 R: 2568 2569 2570 2571 2573 6.3.2. Initiation of STARTTLS Negotiation 2575 6.3.2.1. STARTTLS Command 2577 In order to begin the STARTTLS negotiation, the initiating entity 2578 issues the STARTTLS command (i.e., a element qualified by 2579 the 'urn:ietf:params:xml:ns:xmpp-tls' namespace) to instruct the 2580 receiving entity that it wishes to begin a STARTTLS negotiation to 2581 secure the stream. 2583 I: 2585 The receiving entity MUST reply with either a element 2586 (proceed case) or a element (failure case) qualified by 2587 the 'urn:ietf:params:xml:ns:xmpp-tls' namespace. 2589 6.3.2.2. Failure Case 2591 If the failure case occurs, the receiving entity MUST return a 2592 element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' 2593 namespace, terminate the XML stream, and terminate the underlying TCP 2594 connection. 2596 R: 2598 R: 2600 Causes for the failure case include but are not limited to: 2602 1. The initiating entity has sent a malformed STARTTLS command. 2604 2. The receiving entity does not offer STARTTLS negotiation either 2605 temporarily or permanently. 2606 3. The receiving entity cannot complete STARTTLS negotiation because 2607 of an internal error. 2609 Note: STARTTLS failure is not triggered by TLS errors such as bad 2610 certificate or unknown certificate authority; those errors are 2611 generated and handled during the TLS negotiation itself as 2612 described in [TLS]. 2614 If the failure case occurs, the initiating entity MAY attempt to 2615 reconnect as explained under Section 4.5. 2617 6.3.2.3. Proceed Case 2619 If the proceed case occurs, the receiving entity MUST return a 2620 element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' 2621 namespace. 2623 R: 2625 The receiving entity MUST consider the TLS negotiation to have begun 2626 immediately after sending the closing '>' character of the 2627 element to the initiating entity. The initiating entity MUST 2628 consider the TLS negotiation to have begun immediately after 2629 receiving the closing '>' character of the element from 2630 the receiving entity. 2632 The entities now proceed to TLS negotiation as explained in the next 2633 section. 2635 6.3.3. TLS Negotiation 2637 6.3.3.1. Rules 2639 In order to complete TLS negotiation over the TCP connection, the 2640 entities MUST follow the process defined in [TLS]. 2642 The following rules apply: 2644 1. The entities MUST NOT send any further XML data until the TLS 2645 negotiation has either failed or succeeded. 2646 2. The receiving entity MUST present a certificate. 2647 3. The receiving entity SHOULD send a certificate request to the 2648 initiating entity so that mutual authentication will be possible. 2649 4. The initiating entity MUST validate the certificate to determine 2650 if the TLS negotiation shall succeed; see Section 15.2.2 2651 regarding certificate validation procedures. 2653 5. The receiving entity SHOULD choose which certificate to present 2654 based on the 'to' attribute of the initial stream header. 2656 Note: See Section 15.6 regarding ciphers that MUST be supported 2657 for TLS; naturally, other ciphers MAY be supported as well. 2659 6.3.3.2. TLS Failure 2661 If the TLS negotiation results in failure, the receiving entity MUST 2662 terminate the TCP connection. 2664 The receiving entity MUST NOT send a closing tag before 2665 terminating the TCP connection, since the receiving entity and 2666 initiating entity MUST consider the original stream to be replaced 2667 upon failure of the TLS negotiation. 2669 6.3.3.3. TLS Success 2671 If the TLS negotiation is successful, then the entities MUST proceed 2672 as follows. 2674 1. The receiving entity MUST discard any knowledge obtained in an 2675 insecure manner from the initiating entity before TLS took 2676 effect. 2677 2. The initiating entity MUST discard any knowledge obtained in an 2678 insecure manner from the receiving entity before TLS took effect. 2679 3. The initiating entity MUST send a new initial stream header to 2680 the receiving entity over the encrypted connection. 2682 I: 2690 Note: The initiating entity MUST NOT send a closing tag 2691 before sending the new initial stream header, since the receiving 2692 entity and initiating entity MUST consider the original stream to 2693 be replaced upon success of the TLS negotiation. 2694 4. The receiving entity MUST respond with a new response stream 2695 header over the encrypted connection. 2697 R: 2712 2713 EXTERNAL 2714 PLAIN 2715 2716 2717 2719 7. SASL Negotiation 2721 7.1. Overview 2723 XMPP includes a method for authenticating a stream by means of an 2724 XMPP-specific profile of the Simple Authentication and Security Layer 2725 protocol (see [SASL]). SASL provides a generalized method for adding 2726 authentication support to connection-based protocols, and XMPP uses 2727 an XML namespace profile of SASL that conforms to the profiling 2728 requirements of [SASL]. 2730 Support for SASL negotiation is REQUIRED in XMPP client and server 2731 implementations. 2733 7.2. Rules 2735 7.2.1. Mechanism Preferences 2737 Any entity that will act as a SASL client or a SASL server MUST 2738 maintain an ordered list of its preferred SASL mechanisms according 2739 to the client or server, where the list is ordered by the perceived 2740 strength of the mechanisms. A server MUST offer and a client MUST 2741 try SASL mechanisms in the order of their perceived strength. For 2742 example, if the server offers the ordered list "PLAIN DIGEST-MD5 2743 GSSAPI" or "DIGEST-MD5 GSSAPI PLAIN" but the client's ordered list is 2744 "GSSAPI DIGEST-MD5", the client shall try GSSAPI first and then 2745 DIGEST-MD5 but shall never try PLAIN (since PLAIN is not on its 2746 list). 2748 7.2.2. Mechanism Offers 2750 If the receiving entity considers TLS negotiation (Section 6) to be 2751 mandatory before use of a particular SASL authentication mechanism 2752 will be acceptable, the receiving entity MUST NOT advertise that 2753 mechanism in its list of available SASL authentication mechanisms 2754 prior to successful TLS negotiation. 2756 If during prior TLS negotiation the initiating entity presented a 2757 certificate that is acceptable to the receiving entity for purposes 2758 of strong identity verification in accordance with local service 2759 policies, the receiving entity MUST offer the SASL EXTERNAL mechanism 2760 to the initiating entity during SASL negotiation (refer to [SASL]) 2761 and SHOULD prefer that mechanism. However, the EXTERNAL mechanism 2762 MAY be offered under other circumstances as well. 2764 See Section 15.6 regarding mechanisms that MUST be supported; 2765 naturally, other SASL mechanisms MAY be supported as well. Best 2766 practices for the use of several SASL mechanisms in the context of 2767 XMPP are described in [XEP-0175] and [XEP-0178]. 2769 7.2.3. Data Formatting 2771 The following data formattting rules apply to the SASL negotiation: 2773 1. During SASL negotiation, the entities MUST NOT send any 2774 whitespace within the root stream element as separators between 2775 XML elements (i.e., from the last character of the 2776 element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' 2777 namespace at depth=1 of the stream as sent by the initiating 2778 entity until the last character of the element 2779 qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace at 2780 depth=1 of the stream as sent by the receiving entity). This 2781 prohibition helps to ensure proper security layer byte precision. 2782 Any such whitespace shown in the SASL examples provided in this 2783 document is included only for the sake of readability. 2784 2. Any XML character data contained within the XML elements MUST be 2785 encoded using base64, where the encoding adheres to the 2786 definition in Section 4 of [BASE64] and where the padding bits 2787 are set to zero. 2788 3. As formally specified in the XML schema for the 2789 'urn:ietf:params:xml:ns:xmpp-sasl' namespace under Appendix C.4, 2790 the receiving entity MAY include one or more application-specific 2791 child elements inside the element to provide 2792 information that might be needed by the initiating entity in 2793 order to complete successful SASL negotiation using one or more 2794 of the offered mechanisms; however, the syntax and semantics of 2795 all such elements are out of scope for this specification. 2797 7.2.4. Security Layers 2799 Upon successful SASL negotiation that involves negotiation of a 2800 security layer, both the initiating entity and the receiving MUST 2801 discard any application-layer state (i.e, state from the XMPP layer, 2802 excluding state from the TLS negotiation or SASL negotiation). 2804 7.2.5. Simple Usernames 2806 It is possible that provision of a "simple username" is supported by 2807 the selected SASL mechanism (e.g., this is supported by the DIGEST- 2808 MD5 and CRAM-MD5 mechanisms but not by the EXTERNAL and GSSAPI 2809 mechanisms). The simple username provided during authentication MUST 2810 be as follows: 2812 Client-to-server communication: The initiating entity's registered 2813 account name, i.e., a user name or node name as described under 2814 Section 3.3 (this is not a bare JID of the form but 2815 only the node portion of the JID). The simple username MUST 2816 adhere to the Nodeprep (Appendix A) profile of [STRINGPREP]. 2817 Server-to-server communication: The initiating entity's sending 2818 domain, i.e., IP address or fully qualified domain name as 2819 contained in an XMPP domain identifier. The simple username MUST 2820 adhere to the [NAMEPREP] profile of [STRINGPREP]. 2822 7.2.6. Authorization Identities 2824 If the initiating entity wishes to act on behalf of another entity 2825 and the selected SASL mechanism supports transmission of an 2826 authorization identity, the initiating entity MUST provide an 2827 authorization identity during SASL negotiation. If the initiating 2828 entity does not wish to act on behalf of another entity, it MUST NOT 2829 provide an authorization identity. As specified in [SASL], the 2830 initiating entity MUST NOT provide an authorization identity unless 2831 the authorization identity is different from the default 2832 authorization identity derived from the authentication identity. If 2833 provided, the value of the authorization identity MUST be a bare JID 2834 of the form (i.e., an XMPP domain identifier only) for 2835 servers and a bare JID of the form (i.e., node 2836 identifier and domain identifier) for clients. 2838 Note: The authorization identity communited during SASL 2839 negotiation is used to determine the canonical address for the 2840 initiating client or server according to the receiving server, as 2841 described under Section 3.5. 2843 7.2.7. Realms 2845 The receiving entity MAY include a realm when negotiating certain 2846 SASL mechanisms. If the receiving entity does not communicate a 2847 realm, the initiating entity MUST NOT assume that any realm exists. 2848 The realm MUST be used only for the purpose of authentication; in 2849 particular, an initiating entity MUST NOT attempt to derive an XMPP 2850 hostname from the realm information provided by the receiving entity. 2852 7.2.8. Round Trips 2854 [SASL] specifies that a using protocol such as XMPP can define two 2855 methods by which the protocol can save round trips where allowed for 2856 the SASL mechanism: 2858 1. When the SASL client (the XMPP "initiating entity") requests an 2859 authentication exchange, it can include "initial response" data 2860 with its request if appropriate for the SASL mechanism in use. 2861 In XMPP this is done by including the initial response as the XML 2862 character data of the element. 2863 2. At the end of the authentication exchange, the SASL server (the 2864 XMPP "receiving entity") can include "additional data with 2865 success" if appropriate for the SASL mechanism in use. In XMPP 2866 this is done by including the additional data as the XML 2867 character data of the element. 2869 For the sake of protocol efficiency, it is RECOMMENDED for XMPP 2870 clients and servers to use these methods, however they MUST support 2871 the less efficient modes as well. 2873 7.3. Process 2875 The process for SASL negotiation is as follows. 2877 7.3.1. Exchange of Stream Headers and Stream Features 2879 If SASL negotiation follows successful STARTTLS negotation 2880 (Section 6), then the SASL negotiation occurs over the encrypted 2881 stream that has already been negotiated. If not, the initiating 2882 entity resolves the hostname of the receiving entity as specified 2883 under Section 4, opens a TCP connection to the advertised port at the 2884 resolved IP address, and sends an initial stream header to the 2885 receiving entity; if the initiating entity is capable of STARTTLS 2886 negotiation, it MUST include the 'version' attribute set to a value 2887 of at least "1.0" in the initial stream header. 2889 I: 2897 The receiving entity MUST send a response stream header to the 2898 initiating entity; if the receiving entity is capable of SASL 2899 negotiation, it MUST include the 'version' attribute set to a value 2900 of at least "1.0" in the response stream header. 2902 R: element qualified by the 2915 'urn:ietf:params:xml:ns:xmpp-sasl' namespace. 2917 The element MUST contain one child element 2918 for each authentication mechanism the receiving entity offers to the 2919 initiating entity. The order of elements in the XML 2920 indicates the preference order of the SASL mechanisms according to 2921 the receiving entity; however the initiating entity MUST maintain its 2922 own preference order independent of the preference order of the 2923 receiving entity. 2925 R: 2926 2927 EXTERNAL 2928 PLAIN 2929 2930 2931 2933 If the receiving entity considers SASL negotiation to be 2934 discretionary, the element MUST contain an empty 2935 child element. 2937 R: 2938 2939 EXTERNAL 2940 PLAIN 2941 2942 2943 2945 If the receiving entity considers SASL negotiation to be mandatory, 2946 the element MUST contain an empty child 2947 element. 2949 R: 2950 2951 EXTERNAL 2952 PLAIN 2953 2954 2955 2957 7.3.2. Initiation 2959 In order to begin the SASL negotiation, the initiating entity sends 2960 an element qualified by the 2961 'urn:ietf:params:xml:ns:xmpp-sasl' namespace and includes an 2962 appropriate value for the 'mechanism' attribute. This element MAY 2963 contain XML character data (in SASL terminology, the "initial 2964 response") if the mechanism supports or requires it; if the 2965 initiating entity needs to send a zero-length initial response, it 2966 MUST transmit the response as a single equals sign character ("="), 2967 which indicates that the response is present but contains no data. 2969 I: UjBtMzBSMGNrcw== 2972 7.3.3. Challenge-Response Sequence 2974 If necessary, the receiving entity challenges the initiating entity 2975 by sending a element qualified by the 2976 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY 2977 contain XML character data (which MUST be generated in accordance 2978 with the definition of the SASL mechanism chosen by the initiating 2979 entity). 2981 The initiating entity responds to the challenge by sending a 2982 element qualified by the 2983 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY 2984 contain XML character data (which MUST be generated in accordance 2985 with the definition of the SASL mechanism chosen by the initiating 2986 entity). 2988 If necessary, the receiving entity sends more challenges and the 2989 initiating entity sends more responses. 2991 This series of challenge/response pairs continues until one of three 2992 things happens: 2994 o The initiating entity aborts the handshake. 2995 o The receiving entity reports failure of the handshake. 2996 o The receiving entity reports success of the handshake. 2998 These scenarios are described in the following sections. 3000 7.3.4. Abort 3002 The initiating entity aborts the handshake by sending an 3003 element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' 3004 namespace. 3006 I: 3008 Upon receiving an element, the receiving entity MUST return 3009 a element qualified by the 3010 'urn:ietf:params:xml:ns:xmpp-sasl' namespace and containing an 3011 child element. 3013 R: 3014 3015 3017 7.3.5. Failure 3019 The receiving entity reports failure of the handshake by sending a 3020 element qualified by the 3021 'urn:ietf:params:xml:ns:xmpp-sasl' namespace (the particular cause of 3022 failure MUST be communicated in an appropriate child element of the 3023 element as defined under Section 7.4). 3025 R: 3026 3027 3029 Where appropriate for the chosen SASL mechanism, the receiving entity 3030 SHOULD allow a configurable but reasonable number of retries (at 3031 least 2 and no more than 5); this enables the initiating entity 3032 (e.g., an end-user client) to tolerate incorrectly-provided 3033 credentials (e.g., a mistyped password) without being forced to 3034 reconnect. 3036 If the initiating entity attempts a reasonable number of retries with 3037 the same SASL mechanism and all attempts fail, it MAY fall back to 3038 the next mechanism in its ordered list by sending a new 3039 request to the receiving entity. If there are no remaining 3040 mechanisms in its list, the initiating entity SHOULD instead send an 3041 element to the receiving entity. 3043 If the initiating entity exceeds the number of retries, the receiving 3044 entity MUST return a stream error (which SHOULD be but MAY be ). 3047 7.3.6. Success 3049 The receiving entity reports success of the handshake by sending a 3050 element qualified by the 3051 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY 3052 contain XML character data (in SASL terminology, "additional data 3053 with success") if the chosen SASL mechanism supports or requires it; 3054 if the receiving entity needs to send additional data of zero length, 3055 it MUST transmit the data as a single equals sign character ("="). 3057 R: 3059 Note: The authorization identity communited during SASL 3060 negotiation is used to determine the canonical address for the 3061 initiating client or server according to the receiving server, as 3062 described under Section 3.5. 3064 Upon receiving the element, the initiating entity MUST 3065 initiate a new stream over the existing TCP connection by sending a 3066 new initial stream header to the receiving entity. 3068 I: tag 3077 before sending the new initial stream header, since the receiving 3078 entity and initiating entity MUST consider the original stream to 3079 be replaced upon sending or receiving the element. 3081 Upon receiving the new initial stream header from the initiating 3082 entity, the receiving entity MUST respond by sending a new response 3083 XML stream header to the initiating entity. 3085 R: 3094 The receiving entity MUST also send stream features, containing any 3095 further available features or containing no features (via an empty 3096 element). 3098 R: 3099 3100 3101 3102 3104 7.4. SASL Errors 3106 The syntax of SASL errors is as follows: 3108 3109 3110 [ 3111 OPTIONAL descriptive text 3112 ] 3113 3115 Where "defined-condition" is one of the SASL-related error conditions 3116 defined in the following sections. 3118 Inclusion of a defined condition is REQUIRED. 3120 Inclusion of the element is OPTIONAL, and can be used to 3121 provide application-specific information about the error condition, 3122 which information MAY be displayed to a human but only as a 3123 supplement to the defined condition. 3125 7.4.1. aborted 3127 The receiving entity acknowledges an element sent by the 3128 initiating entity; sent in reply to the element. 3130 I: 3132 R: 3133 3134 3136 7.4.2. account-disabled 3138 The account of the initiating entity has been temporarily disabled; 3139 sent in reply to an element (with or without initial response 3140 data) or a element. 3142 I: UjBtMzBSMGNrcw== 3145 R: 3146 3147 Call 212-555-1212 for assistance. 3148 3150 7.4.3. credentials-expired 3152 The authentication failed because the initiating entity provided 3153 credentials that have expired; sent in reply to a element 3154 or an element with initial response data. 3156 I: 3157 [ ... ] 3158 3160 R: 3161 3162 3164 7.4.4. encryption-required 3166 The mechanism requested by the initiating entity cannot be used 3167 unless the underlying stream is encrypted; sent in reply to an 3168 element (with or without initial response data). 3170 I: UjBtMzBSMGNrcw== 3173 R: 3174 3175 3177 7.4.5. incorrect-encoding 3179 The data provided by the initiating entity could not be processed 3180 because the [BASE64] encoding is incorrect (e.g., because the 3181 encoding does not adhere to the definition in Section 4 of [BASE64]); 3182 sent in reply to a element or an element with 3183 initial response data. 3185 I: [ ... ] 3188 R: 3189 3190 3192 7.4.6. invalid-authzid 3194 The authzid provided by the initiating entity is invalid, either 3195 because it is incorrectly formatted or because the initiating entity 3196 does not have permissions to authorize that ID; sent in reply to a 3197 element or an element with initial response data. 3199 I: 3200 [ ... ] 3201 3203 R: 3204 3205 3207 7.4.7. invalid-mechanism 3209 The initiating entity did not provide a mechanism or requested a 3210 mechanism that is not supported by the receiving entity; sent in 3211 reply to an element. 3213 I: 3216 R: 3217 3219 3221 7.4.8. malformed-request 3223 The request is malformed (e.g., the element includes initial 3224 response data but the mechanism does not allow that, or the data sent 3225 violates the syntax for the specified SASL mechanism); sent in reply 3226 to an , , , or element. 3228 (In the following example, the XML character data of the 3229 element contains more than 255 UTF-8-encoded Unicode characters and 3230 therefore violates the "token" production for the SASL ANONYMOUS 3231 mechanism as specified in [ANONYMOUS].) 3233 I: [ ... some-long-token ... ] 3236 R: 3237 3238 3240 7.4.9. mechanism-too-weak 3242 The mechanism requested by the initiating entity is weaker than 3243 server policy permits for that initiating entity; sent in reply to an 3244 element (with or without initial response data). 3246 I: UjBtMzBSMGNrcw== 3249 R: 3250 3251 3253 7.4.10. not-authorized 3255 The authentication failed because the initiating entity did not 3256 provide proper credentials or the receiving entity has detected an 3257 attack but wishes to disclose as little information as possible to 3258 the attacker; sent in reply to a element or an 3259 element with initial response data. 3261 I: 3262 [ ... ] 3263 3265 R: 3266 3268 3270 Note: This error condition includes but is not limited to the case 3271 of incorrect credentials or an unknown username. In order to 3272 discourage directory harvest attacks, no differentiation is made 3273 between incorrect credentials and an unknown username. 3275 7.4.11. temporary-auth-failure 3277 The authentication failed because of a temporary error condition 3278 within the receiving entity, and it is advisable for the initiating 3279 entity to try again later; sent in reply to an element or a 3280 element. 3282 I: 3283 [ ... ] 3284 3286 R: 3287 3288 3290 7.4.12. transition-needed 3292 The authentication failed because the mechanism cannot be used until 3293 the initiating entity provides (for one time only) a plaintext 3294 password so that the receiving entity can build a hashed password for 3295 use in future authentication attempts; sent in reply to an 3296 element with or without initial response data. 3298 I: [ ... ] 3301 R: 3302 3303 3305 Note: An XMPP client MUST treat a error with 3306 extreme caution, SHOULD NOT provide a plaintext password over an 3307 XML stream that is not encrypted via Transport Layer Security, and 3308 MUST warn a human user before allowing the user to provide a 3309 plaintext password over an unencrypted connection. 3311 7.5. SASL Definition 3313 The profiling requirements of [SASL] require that the following 3314 information be supplied by the definition of a using protocol. 3316 service name: "xmpp" 3317 initiation sequence: After the initiating entity provides an opening 3318 XML stream header and the receiving entity replies in kind, the 3319 receiving entity provides a list of acceptable authentication 3320 methods. The initiating entity chooses one method from the list 3321 and sends it to the receiving entity as the value of the 3322 'mechanism' attribute possessed by an element, optionally 3323 including an initial response to avoid a round trip. 3324 exchange sequence: Challenges and responses are carried through the 3325 exchange of elements from receiving entity to 3326 initiating entity and elements from initiating entity 3327 to receiving entity. The receiving entity reports failure by 3328 sending a element and success by sending a 3329 element; the initiating entity aborts the exchange by sending an 3330 element. Upon successful negotiation, both sides 3331 consider the original XML stream to be closed and new stream 3332 headers are sent by both entities. 3333 security layer negotiation: The security layer takes effect 3334 immediately after sending the closing '>' character of the 3335 element for the receiving entity, and immediately after 3336 receiving the closing '>' character of the element for 3337 the initiating entity. The order of layers is first [TCP], then 3338 [TLS], then [SASL], then XMPP. 3339 use of the authorization identity: The authorization identity can be 3340 used in XMPP to denote the non-default of a client 3341 or the sending of a server; an empty string is equivalent 3342 to an absent authorization identity. 3344 8. Resource Binding 3346 8.1. Overview 3348 After a client authenticates with a server, it MUST bind a specific 3349 resource to the stream so that the server can properly address the 3350 client (see Section 3). That is, there MUST be an XMPP resource 3351 identifier associated with the bare JID () of the 3352 client, so that the address for use over that stream is a full JID of 3353 the form . This ensures that the server can 3354 deliver XML stanzas to and receive XML stanzas from the client (see 3355 Section 11). 3357 After a client has bound a resource to the stream, it is referred to 3358 as a CONNECTED RESOURCE. A server SHOULD allow an entity to maintain 3359 multiple connected resources simultaneously, where each connected 3360 resource is differentiated by a distinct resource identifier; 3361 however, a server MUST enable the administrator of an XMPP service to 3362 limit the number of connected resources in order to prevent certain 3363 denial of service attacks as described under Section 15.13. 3365 If, before completing the resource binding step, the client attempts 3366 to send an outbound XML stanza (i.e., a stanza not directed to the 3367 server itself or to the client's own account), the server MUST NOT 3368 process the stanza and MUST either ignore the stanza or return a 3369 stream error to the client. 3371 Support for resource binding is REQUIRED in XMPP client and server 3372 implementations. 3374 8.2. Advertising Support 3376 Upon sending a new response stream header to the client after 3377 successful SASL negotiation, the server MUST include a 3378 element qualified by the 'urn:ietf:params:xml:ns:xmpp-bind' namespace 3379 in the stream features it presents to the client; this 3380 element MUST include an empty element to explicitly 3381 indicate that it is mandatory for the client to complete resource 3382 binding at this stage of the stream negotiation process. 3384 Note: The server MUST NOT include the resource binding stream 3385 feature until after successful SASL negotiation. 3387 S: 3396 S: 3397 3398 3399 3400 3402 Upon being so informed that resource binding is required, the client 3403 MUST bind a resource to the stream as described in the following 3404 sections. 3406 8.3. Generation of Resource Identifiers 3408 A resource identifier MUST at a minimum be unique among the connected 3409 resources for that . Enforcement of this policy is the 3410 responsibility of the server. 3412 A resource identifier can be security-critical. For example, if a 3413 malicious entity can guess a client's resource identifier then it 3414 might be able to determine if the client (and therefore the 3415 controlling principal) is online or offline, thus resulting in a 3416 presence leak as described under Section 15.14. To prevent that 3417 possibility, a client can either (1) generate a random resource 3418 identifier on its own or (2) ask the server to generate a resource 3419 identifier on its behalf, which MUST be random (see [RANDOM]). When 3420 generating a random resource identifier, it is RECOMMENDED that the 3421 resource identifier be a Universally Unique Identifier (UUID), for 3422 which the format specified in [UUID] is RECOMMENDED. 3424 8.4. Server-Generated Resource Identifier 3426 A server that supports resource binding MUST be able to generate an 3427 XMPP resource identifier on behalf of a client. 3429 8.4.1. Success Case 3431 A client requests a server-generated resource identifier by sending 3432 an IQ stanza of type "set" (see Section 9.2.3) containing an empty 3433 element qualified by the 'urn:ietf:params:xml:ns:xmpp-bind' 3434 namespace. 3436 C: 3437 3438 3440 Once the server has generated an XMPP resource identifier for the 3441 client, it MUST return an IQ stanza of type "result" to the client, 3442 which MUST include a child element that specifies the full JID 3443 for the connected resource as determined by the server. 3445 S: 3446 3447 3448 juliet@im.example.com/4db06f06-1ea4-11dc-aca3-000bcd821bfb 3449 3450 3451 3453 8.4.2. Error Cases 3455 When a client asks the server to generate a resource identifer during 3456 resource binding, the following stanza error conditions are possible: 3458 o The account has reached a limit on the number of simultaneous 3459 connected resources allowed. 3460 o The client is otherwise not allowed to bind a resource to the 3461 stream. 3463 8.4.2.1. Resource Constraint 3465 If the account has reached a limit on the number of simultaneous 3466 connected resources allowed, the server MUST return a error. 3469 S: 3470 3471 3473 3474 3476 8.4.2.2. Not Allowed 3478 If the client is otherwise not allowed to bind a resource to the 3479 stream, the server MUST return a error. 3481 S: 3482 3483 3485 3486 3488 8.5. Client-Submitted Resource Identifier 3490 Instead of asking the server to generate a resource identifier on its 3491 behalf, a client MAY attempt to submit a resource identifier that it 3492 has generated or that the controlling user has provided. 3494 8.5.1. Success Case 3496 A client asks its server to accept a client-submitted resource 3497 identifier by sending an IQ stanza of type "set" containing a 3498 element with a child element containing non-zero-length 3499 XML character data. 3501 C: 3502 3503 balcony 3504 3505 3507 The server SHOULD accept the client-submitted resource identifier. 3508 It does so by returning an IQ stanza of type "result" to the client, 3509 including a child element that specifies the full JID for the 3510 connected resource and contains without modification the client- 3511 submitted text. 3513 S: 3514 3515 juliet@im.example.com/balcony 3516 3517 3519 8.5.2. Error Cases 3521 When a client attempts to submit its own XMPP resource identifier 3522 during resource binding, the following stanza error conditions are 3523 possible in addition to those described under Section 8.4.2: 3525 o The provided resource identifier cannot be processed by the 3526 server, e.g. because it is not in accordance with the Resourceprep 3527 (Appendix B) profile of [STRINGPREP]). 3528 o The provided resource identifier is already in use. 3530 8.5.2.1. Bad Request 3532 If the provided resource identifier cannot be processed by the 3533 server, the server MAY return a error (but SHOULD 3534 instead apply the Resourceprep (Appendix B) profile of [STRINGPREP] 3535 or otherwise process the resource identifier so that it is in 3536 conformance). 3538 S: 3539 3540 3541 3542 3544 8.5.2.2. Conflict 3546 If there is already a connected resource of the same name, the server 3547 MUST do one of the following: 3549 1. Not accept the resource identifier provided by the client but 3550 instead override it with an XMPP resource identifier that the 3551 server generates. 3552 2. Terminate the current resource and allow the newly-requested 3553 resource. 3555 3. Disallow the newly-requested resource and maintain the current 3556 resource. 3558 Which of these the server does is up to the implementation, although 3559 it is RECOMMENDED to implement case #1. 3561 S: 3562 3563 3564 juliet@im.example.com/balcony 4db06f06-1ea4-11dc-aca3-000bcd821bfb 3565 3566 3567 3569 In case #2, the server MUST send a stream error to the 3570 current resource and return an IQ stanza of type "result" (indicating 3571 success) to the newly-requested resource. 3573 S: 3575 In case #3, the server MUST send a stanza error to the 3576 newly-requested resource but maintain the XML stream for that 3577 connection so that the newly-requested resource has an opportunity to 3578 negotiate a non-conflicting resource identifier before sending 3579 another request for resource binding. 3581 S: 3582 3583 3584 3585 3587 8.5.3. Retries 3589 If an error occurs when a client submits a resource identifier, the 3590 server SHOULD allow a configurable but reasonable number of retries 3591 (at least 2 and no more than 5); this enables the client to tolerate 3592 incorrectly-provided resource identifiers (e.g., bad data formats or 3593 duplicate text strings) without being forced to reconnect. 3595 After the client has reached the retry limit, the server MUST return 3596 a stream error to the client. 3598 8.6. Binding Multiple Resources 3600 A server MAY support binding of multiple resources to the same 3601 stream. This functionality is desirable in certain environments 3602 (e.g., for devices that are unable to open more than one TCP 3603 connection or when a machine runs a local XMPP client daemon that is 3604 used by multiple applications). 3606 8.6.1. Support 3608 If a server supports binding of multiple resources to a stream, it 3609 MUST enable a client to unbind resources. A server that supports 3610 unbinding MUST also support binding of multiple resources. Thus a 3611 client can discover whether a server supports binding of multiple 3612 resources by determining if the server advertises a stream feature of 3613 , as follows. 3615 S: 3616 3617 3618 3619 3620 3621 3622 3624 If a server supports binding of mulitple resources, it MUST also send 3625 the unbind feature advertisement after resource binding has been 3626 completed. 3628 8.6.2. Binding an Additional Resource 3630 A connected client binds an additional resource by following the 3631 protocol for binding of the original resource, i.e., by sending an IQ 3632 stanza of type "set" containing a element qualified by the 3633 'urn:ietf:params:xml:ns:xmpp-bind' namespace (either empty to request 3634 server generation of the resource identifier or containing a 3635 element with XML character data to request a client- 3636 submitted resource identifier). 3638 8.6.3. Unbinding a Resource 3640 8.6.3.1. Success Case 3642 A client unbinds a resource by sending an IQ stanza of type "set" 3643 containing an element qualified by the 3644 'urn:ietf:params:xml:ns:xmpp-bind' namespace, which in turn contains 3645 a child element of whose XML character data specifies the 3646 resource to be unbound: 3648 C: 3649 3650 someresource 3651 3652 3654 If no error occurs, the server MUST unbind the resource and no longer 3655 accept stanzas whose 'from' address specifies the full JID associated 3656 with that resource. 3658 S: 3660 When a client unbinds the only resource associated with the stream, 3661 the server SHOULD close the stream and terminate the TCP connection. 3663 S: 3665 S: 3667 8.6.3.2. Error Cases 3669 8.6.3.2.1. Unbind Not Supported 3671 If the server understands the 'urn:ietf:params:xml:ns:xmpp-bind' 3672 namespace but does not understand the element, it MUST 3673 return a stanza error, which MUST be . 3675 S: 3676 3677 3679 3680 3682 8.6.3.2.2. No Such Resource 3684 If there is no such resource for that stream, the server MUST return 3685 an error of . 3687 S: 3688 3689 3690 3691 3693 8.6.4. From Addresses 3695 When a client binds multiple resources to the same stream, proper 3696 management of 'from' addresses is imperative. In particular, a 3697 client MUST specify a 'from' address on every stanza it sends over a 3698 stream to which it has bound multiple resources, where the 'from' 3699 address is the full JID () associated with 3700 the relevant resource. If a client does not specify a 'from' address 3701 on a stanza it sends over a stream to which it has bound multiple 3702 resources, the server MUST return the stanza to the client with an 3703 stanza error. 3705 C: 3706 Wherefore art thou? 3707 3709 S: 3711 Wherefore art thou? 3712 3713 3714 3715 3717 Naturally, the rules regarding validation of asserted 'from' 3718 addresses still apply (see Section 11). 3720 9. XML Stanzas 3722 After a client has connected to a server or two servers have 3723 connected to each other, either party can send XML stanzas over the 3724 negotiated stream. Three kinds of XML stanza are defined for the 3725 'jabber:client' and 'jabber:server' namespaces: , 3726 , and . In addition, there are five common 3727 attributes for these stanza types. These common attributes, as well 3728 as the basic semantics of the three stanza types, are defined herein; 3729 more detailed information regarding the syntax of XML stanzas for 3730 instant messaging and presence applications is provided in 3731 [rfc3921bis], and for other applications in the relevant XMPP 3732 extension specifications. 3734 A server MUST NOT process a partial stanza and MUST NOT attach 3735 meaning to the transmission timing of any part of a stanza (before 3736 receipt of the close tag). 3738 Support for the XML stanza syntax and semantics defined herein is 3739 REQUIRED in XMPP client and server implementations. 3741 9.1. Common Attributes 3743 The following five attributes are common to message, presence, and IQ 3744 stanzas. 3746 9.1.1. to 3748 The 'to' attribute specifies the JID of the intended recipient for 3749 the stanza. 3751 3752 Art thou not Romeo, and a Montague? 3753 3755 For information about server processing of inbound and outbound XML 3756 stanzas based on the nature of the 'to' address, refer to Section 11. 3758 9.1.1.1. Client-to-Server Streams 3760 The following rules apply to inclusion of the 'to' attribute in the 3761 context of XML streams qualified by the 'jabber:client' namespace 3762 (i.e., client-to-server streams). 3764 1. A stanza with a specific intended recipient MUST possess a 'to' 3765 attribute whose value is an XMPP address. 3766 2. A stanza sent from a client to a server for direct processing by 3767 the server on behalf of the client (e.g., presence sent to the 3768 server for broadcasting to other entities) MUST NOT possess a 3769 'to' attribute. 3771 9.1.1.2. Server-to-Server Streams 3773 The following rules apply to inclusion of the 'to' attribute in the 3774 context of XML streams qualified by the 'jabber:server' namespace 3775 (i.e., server-to-server streams). 3777 1. A stanza MUST possess a 'to' attribute whose value is an XMPP 3778 address; if a server receives a stanza that does not meet this 3779 restriction, it MUST generate an stream 3780 error. 3781 2. The domain identifier portion of the JID in the 'to' atttribute 3782 MUST match a hostname serviced by the receiving server; if a 3783 server receives a stanza that does not meet this restriction, it 3784 MUST generate a or stream error. 3786 9.1.2. from 3788 The 'from' attribute specifies the JID of the sender. 3790 3792 Art thou not Romeo, and a Montague? 3793 3795 9.1.2.1. Client-to-Server Streams 3797 The following rules apply to the 'from' attribute in the context of 3798 XML streams qualified by the 'jabber:client' namespace (i.e., client- 3799 to-server streams). 3801 1. When the server receives an XML stanza from a client and the 3802 stanza does not include a 'from' attribute, the server MUST add a 3803 'from' attribute to the stanza, where the value of the 'from' 3804 attribute is the full JID () determined by 3805 the server for the connected resource that generated the stanza 3806 (see Section 3.5), or the bare JID () in the case of 3807 subscription-related presence stanzas (see [rfc3921bis]); the 3808 only exception to this rule occurs when multiple resources are 3809 bound to the same stream as described under Section 8.6. 3810 2. When the server receives an XML stanza from a client and the 3811 stanza includes a 'from' attribute, the server MUST either (a) 3812 validate that the value of the 'from' attribute provided by the 3813 client is that of a connected resource for the associated entity 3814 or (b) override the provided 'from' attribute by adding a 'from' 3815 attribute as specified under Rule #1. 3816 3. When the server generates a stanza from the server for delivery 3817 to the client on behalf of the account of the connected client 3818 (e.g., in the context of data storage services provided by the 3819 server on behalf of the client), the stanza MUST either (a) not 3820 include a 'from' attribute or (b) include a 'from' attribute 3821 whose value is the account's bare JID (). 3822 4. When the server generates a stanza from the server itself for 3823 delivery to the client, the stanza MUST include a 'from' 3824 attribute whose value is the bare JID (i.e., ) of the 3825 server. 3826 5. A server MUST NOT send to the client a stanza without a 'from' 3827 attribute if the stanza was not generated by the server (e.g., if 3828 it was generated by another client or another server); therefore, 3829 when a client receives a stanza that does not include a 'from' 3830 attribute, it MUST assume that the stanza is from the server to 3831 which the client is connected. 3833 9.1.2.2. Server-to-Server Streams 3835 The following rules apply to the 'from' attribute in the context of 3836 XML streams qualified by the 'jabber:server' namespace (i.e., server- 3837 to-server streams). 3839 1. A stanza MUST possess a 'from' attribute whose value is an XMPP 3840 address; if a server receives a stanza that does not meet this 3841 restriction, it MUST generate an stream 3842 error. 3843 2. The domain identifier portion of the JID contained in the 'from' 3844 attribute MUST match the hostname of the sending server (or any 3845 validated domain thereof) as communicated in the SASL negotiation 3846 (see Section 7), server dialback (see [XEP-0220], or similar 3847 means; if a server receives a stanza that does not meet this 3848 restriction, it MUST generate an stream error. 3850 Enforcement of these rules helps to prevent certain denial of service 3851 attacks as described under Section 15.13. 3853 9.1.3. id 3855 The 'id' attribute MAY be used by a sending entity for internal 3856 tracking of stanzas that it sends and receives (especially for 3857 tracking the request-response interaction inherent in the semantics 3858 of IQ stanzas). The value of the 'id' attribute MAY be unique 3859 globally, within a domain, or within a stream. The semantics of IQ 3860 stanzas impose additional restrictions; see Section 9.2.3. 3862 9.1.4. type 3864 The 'type' attribute specifies the purpose or context of the message, 3865 presence, or IQ stanza. The particular allowable values for the 3866 'type' attribute vary depending on whether the stanza is a message, 3867 presence, or IQ stanza. The defined values for message and presence 3868 stanzas are specific to instant messaging and presence applications 3869 and therefore are specified in [rfc3921bis], whereas the values for 3870 IQ stanzas specify the role of an IQ stanza in a structured request- 3871 response exchange and therefore are specified under Section 9.2.3. 3872 The only 'type' value common to all three stanzas is "error"; see 3873 Section 9.3. 3875 9.1.5. xml:lang 3877 A stanza SHOULD possess an 'xml:lang' attribute (as defined in 3878 Section 2.12 of [XML]) if the stanza contains XML character data that 3879 is intended to be presented to a human user (as explained in 3880 [CHARSET], "internationalization is for humans"). The value of the 3881 'xml:lang' attribute specifies the default language of any such 3882 human-readable XML character data. 3884 3885 dnd 3886 Wooing Juliet 3887 3889 The value of the 'xml:lang' attribute MAY be overridden by the 'xml: 3890 lang' attribute of a specific child element. 3892 3893 dnd 3894 Wooing Juliet 3895 Dvořím se Julii 3896 3904 dnd 3905 Wooing Juliet 3906 3908 S: 3911 dnd 3912 Wooing Juliet 3913 3915 If an inbound stanza received received by a client or server does not 3916 possess an 'xml:lang' attribute, an implementation MUST assume that 3917 the default language is that specified for the stream as defined 3918 under Section 5.3.4. 3920 The value of the 'xml:lang' attribute MUST conform to the NMTOKEN 3921 datatype (as defined in Section 2.3 of [XML]) and MUST conform to the 3922 format defined in [LANGTAGS]. 3924 A server MUST NOT modify or delete 'xml:lang' attributes on stanzas 3925 it receives from other entities. 3927 9.2. Basic Semantics 3929 9.2.1. Message Semantics 3931 The stanza can be seen as a "push" mechanism whereby one 3932 entity pushes information to another entity, similar to the 3933 communications that occur in a system such as email. All message 3934 stanzas SHOULD possess a 'to' attribute that specifies the intended 3935 recipient of the message; upon receiving such a stanza, a server 3936 SHOULD route or deliver it to the intended recipient (see Section 11 3937 for general routing and delivery rules related to XML stanzas). 3939 9.2.2. Presence Semantics 3941 The stanza can be seen as a specialized broadcast or 3942 "publish-subscribe" mechanism, whereby multiple entities receive 3943 information (in this case, network availability information) about an 3944 entity to which they have subscribed. In general, a publishing 3945 entity (client) SHOULD send a presence stanza with no 'to' attribute, 3946 in which case the server to which the entity is connected SHOULD 3947 broadcast or multiplex that stanza to all subscribed entities. 3948 However, a publishing entity MAY also send a presence stanza with a 3949 'to' attribute, in which case the server SHOULD route or deliver that 3950 stanza to the intended recipient. See Section 11 for general routing 3951 and delivery rules related to XML stanzas, and [rfc3921bis] for rules 3952 specific to presence applications. 3954 9.2.3. IQ Semantics 3956 Info/Query, or IQ, is a request-response mechanism, similar in some 3957 ways to the Hypertext Transfer Protocol [HTTP]. The semantics of IQ 3958 enable an entity to make a request of, and receive a response from, 3959 another entity. The data content of the request and response is 3960 defined by the schema or other structural definition associated with 3961 the XML namespace that qualifies the direct child element of the IQ 3962 element (see Section 9.4), and the interaction is tracked by the 3963 requesting entity through use of the 'id' attribute. Thus, IQ 3964 interactions follow a common pattern of structured data exchange such 3965 as get/result or set/result (although an error can be returned in 3966 reply to a request if appropriate): 3968 Requesting Responding 3969 Entity Entity 3970 ---------- ---------- 3971 | | 3972 | | 3973 | [ ... payload ... ] | 3974 | | 3975 | -------------------------> | 3976 | | 3977 | | 3978 | [ ... payload ... ] | 3979 | | 3980 | <------------------------- | 3981 | | 3982 | | 3983 | [ ... payload ... ] | 3984 | | 3985 | -------------------------> | 3986 | | 3987 | | 3988 | [ ... condition ... ] | 3989 | | 3990 | <------------------------- | 3991 | | 3993 To enforce these semantics, the following rules apply: 3995 1. The 'id' attribute is REQUIRED for IQ stanzas. 3996 2. The 'type' attribute is REQUIRED for IQ stanzas. The value MUST 3997 be one of the following (if the value is other than one of the 3998 following strings, the recipient or an intermediate router MUST 3999 return a stanza error of ): 4000 * get -- The stanza requests information, inquires about what 4001 data is needed in order to complete further operations, etc. 4002 * set -- The stanza provides data that is needed for an 4003 operation to be completed, sets new values, replaces existing 4004 values, etc. 4005 * result -- The stanza is a response to a successful get or set 4006 request. 4007 * error -- The stanza reports an error that has occurred 4008 regarding processing or delivery of a previously-sent get or 4009 set request (see Section 9.3). 4010 3. An entity that receives an IQ request of type "get" or "set" MUST 4011 reply with an IQ response of type "result" or "error". The 4012 response MUST preserve the 'id' attribute of the request. 4013 4. An entity that receives a stanza of type "result" or "error" MUST 4014 NOT respond to the stanza by sending a further IQ response of 4015 type "result" or "error"; however, the requesting entity MAY send 4016 another request (e.g., an IQ of type "set" to provide required 4017 information discovered through a get/result pair). 4018 5. An IQ stanza of type "get" or "set" MUST contain exactly one 4019 child element, which specifies the semantics of the particular 4020 request. 4021 6. An IQ stanza of type "result" MUST include zero or one child 4022 elements. 4023 7. An IQ stanza of type "error" MAY include the child element 4024 contained in the associated "get" or "set" and MUST include an 4025 child; for details, see Section 9.3. 4027 9.3. Stanza Errors 4029 Stanza-related errors are handled in a manner similar to stream 4030 errors (Section 5.8). Unlike stream errors, stanza errors are 4031 recoverable; therefore they do not result in termination of the XML 4032 stream and underlying TCP connection. Instead, the entity that 4033 discovers the error condition returns an ERROR STANZA to the sender, 4034 i.e., a stanza of the same kind (message, presence, or IQ) whose 4035 'type' attribute is set to a value of "error" and which contains an 4036 child element that specifies the error condition. The 4037 specified error condition provides a hint regarding actions that the 4038 sender can take to remedy the error if possible. 4040 9.3.1. Rules 4042 The following rules apply to stanza errors: 4044 1. The receiving or processing entity that detects an error 4045 condition in relation to a stanza SHOULD return an error stanza 4046 (and MUST do so for IQ stanzas). 4047 2. The entity that generates an error stanza MAY include the 4048 original XML sent so that the sender can inspect and, if 4049 necessary, correct the XML before attempting to resend. 4050 3. An error stanza MUST contain an child element. 4051 4. An child MUST NOT be included if the 'type' attribute 4052 has a value other than "error" (or if there is no 'type' 4053 attribute). 4054 5. An entity that receives an error stanza MUST NOT respond to the 4055 stanza with a further error stanza; this helps to prevent 4056 looping. 4058 9.3.2. Syntax 4060 The syntax for stanza-related errors is: 4062 4063 [OPTIONAL to include sender XML here] 4064 4065 4066 [ 4068 OPTIONAL descriptive text 4069 ] 4070 [OPTIONAL application-specific condition element] 4071 4072 4074 The "stanza-kind" MUST be one of message, presence, or iq. 4076 The "error-type MUST be one of the following: 4078 o auth -- retry after providing credentials 4079 o cancel -- do not retry (the error cannot be remedied) 4080 o continue -- proceed (the condition was only a warning) 4081 o modify -- retry after changing the data sent 4082 o wait -- retry after waiting (the error is temporary) 4084 The element: 4086 o MUST contain a child element corresponding to one of the stanza 4087 error conditions defined under Section 9.3.3; this element MUST be 4088 qualified by the 'urn:ietf:params:xml:ns:xmpp-stanzas' namespace. 4089 o MAY contain a child element containing XML character data 4090 that describes the error in more detail; this element MUST be 4091 qualified by the 'urn:ietf:params:xml:ns:xmpp-stanzas' namespace 4092 and SHOULD possess an 'xml:lang' attribute specifying the natural 4093 language of the XML character data. 4094 o MAY contain a child element for an application-specific error 4095 condition; this element MUST be qualified by an application- 4096 specific namespace that defines the syntax and semantics of the 4097 element. 4099 The element is OPTIONAL. If included, it MUST be used only 4100 to provide descriptive or diagnostic information that supplements the 4101 meaning of a defined condition or application-specific condition. It 4102 MUST NOT be interpreted programmatically by an application. It MUST 4103 NOT be used as the error message presented to a human user, but MAY 4104 be shown in addition to the error message associated with the defined 4105 condition element (and, optionally, the application-specific 4106 condition element). 4108 9.3.3. Defined Conditions 4110 The following conditions are defined for use in stanza errors. 4112 9.3.3.1. bad-request 4114 The sender has sent a stanza containing XML that does not conform to 4115 the appropriate schema or that cannot be processed (e.g., an IQ 4116 stanza that includes an unrecognized value of the 'type' attribute, 4117 or an element that is qualified by a recognized namespace but that 4118 violates the defined syntax for the element); the associated error 4119 type SHOULD be "modify". 4121 C: 4125 4126 4128 S: 4132 4133 4134 4135 4137 9.3.3.2. conflict 4139 Access cannot be granted because an existing resource exists with the 4140 same name or address; the associated error type SHOULD be "cancel". 4142 C: 4143 4144 balcony 4145 4146 4148 S: 4149 4150 4151 4152 4154 9.3.3.3. feature-not-implemented 4156 The feature represented in the XML stanza is not implemented by the 4157 intended recipient or an intermediate server and therefore the stanza 4158 cannot be processed (e.g., the entity understands the namespace but 4159 does not recognize the element name); the associated error type 4160 SHOULD be "cancel" or "modify". 4162 C: 4166 4167 4168 4169 4171 E: 4175 4176 4178 4181 4182 4184 9.3.3.4. forbidden 4186 The requesting entity does not possess the required permissions to 4187 perform the action; the associated error type SHOULD be "auth". 4189 C: 4192 4193 4195 E: 4199 4200 4201 4203 4205 9.3.3.5. gone 4207 The recipient or server can no longer be contacted at this address, 4208 typically on a permanent basis; the associated error type SHOULD be 4209 "cancel" or "modify" and the error stanza SHOULD include a new 4210 address as the XML character data of the element (which MUST 4211 be a URI or IRI at which the entity can be contacted, typically an 4212 XMPP IRI as specified in [XMPP-URI]). 4214 C: 4217 4218 4220 E: 4224 4225 4226 xmpp:conference.example.com 4227 4228 4229 4231 9.3.3.6. internal-server-error 4233 The server could not process the stanza because of a misconfiguration 4234 or an otherwise-undefined internal server error; the associated error 4235 type SHOULD be "wait" or "cancel". 4237 C: 4240 4241 4243 E: 4247 4248 4250 4252 4254 9.3.3.7. item-not-found 4256 The addressed JID or item requested cannot be found; the associated 4257 error type SHOULD be "cancel" or "modify". 4259 C: 4260 4261 someresource 4262 4263 4265 S: 4266 4267 4268 4269 4271 Note: An application MUST NOT return this error if doing so would 4272 provide information about the intended recipient's network 4273 availability to an entity that is not authorized to know such 4274 information; instead it MUST return a 4275 error. 4277 9.3.3.8. jid-malformed 4279 The sending entity has provided or communicated an XMPP address 4280 (e.g., a value of the 'to' attribute) or aspect thereof (e.g., an 4281 XMPP resource identifier) that does not adhere to the syntax defined 4282 under Section 3; the associated error type SHOULD be "modify". 4284 C: 4287 4288 4290 E: 4294 4295 4297 4298 4300 9.3.3.9. not-acceptable 4302 The recipient or server understands the request but is refusing to 4303 process it because it does not meet criteria defined by the recipient 4304 or server (e.g., a local policy regarding stanza size limits or 4305 acceptable words in messages); the associated error type SHOULD be 4306 "modify". 4308 C: 4309 [ ... the-emacs-manual ... ] 4310 4312 S: 4313 4314 4316 4317 4319 9.3.3.10. not-allowed 4321 The recipient or server does not allow any entity to perform the 4322 action (e.g., sending to entities at a blacklisted domain); the 4323 associated error type SHOULD be "cancel". 4325 C: 4328 4329 4331 E: 4335 4336 4337 4338 4340 9.3.3.11. not-authorized 4342 The sender needs to provide proper credentials before being allowed 4343 to perform the action, or has provided improper credentials; the 4344 associated error type SHOULD be "auth". 4346 C: 4349 4350 4352 E: 4355 4356 4357 4358 4360 9.3.3.12. not-modified 4362 The item requested has not changed since it was last requested; the 4363 associated error type SHOULD be "continue". 4365 C: 4368 4369 4370
4371 some-long-opaque-string 4372
4373
4374
4375
4377 S: 4380 4381 4382
4383 some-long-opaque-string 4384
4385
4386
4387 4388 4389 4390
4392 9.3.3.13. payment-required 4394 The requesting entity is not authorized to access the requested 4395 service because payment is required; the associated error type SHOULD 4396 be "auth". 4398 C: 4402 4403 4404 4405 4407 E: 4411 4412 4414 4415 4417 9.3.3.14. recipient-unavailable 4419 The intended recipient is temporarily unavailable; the associated 4420 error type SHOULD be "wait". 4422 C: 4425 4426 4428 E: 4431 4432 4434 4435 4437 Note: An application MUST NOT return this error if doing so would 4438 provide information about the intended recipient's network 4439 availability to an entity that is not authorized to know such 4440 information; instead it MUST return a 4441 error. 4443 9.3.3.15. redirect 4445 The recipient or server is redirecting requests for this information 4446 to another entity, typically in a temporary fashion (the 4447 condition is used for permanent addressing failures); the associated 4448 error type SHOULD be "modify" and the error stanza SHOULD contain the 4449 alternate address in the XML character data of the 4450 element (which MUST be a URI or IRI at which the entity can be 4451 contacted, typically an XMPP IRI as specified in [XMPP-URI]). 4453 C: 4456 4457 4459 E: 4463 4464 4465 xmpp:characters@conference.example.org 4466 4467 4468 4470 9.3.3.16. registration-required 4472 The requesting entity is not authorized to access the requested 4473 service because prior registration is required; the associated error 4474 type SHOULD be "auth". 4476 C: 4479 4480 4482 E: 4485 4486 4488 4489 4491 9.3.3.17. remote-server-not-found 4493 A remote server or service specified as part or all of the JID of the 4494 intended recipient does not exist; the associated error type SHOULD 4495 be "cancel". 4497 C: 4500 4501 4503 E: 4506 4507 4509 4510 4512 9.3.3.18. remote-server-timeout 4514 A remote server or service specified as part or all of the JID of the 4515 intended recipient (or required to fulfill a request) could not be 4516 contacted within a reasonable amount of time; the associated error 4517 type SHOULD be "wait". 4519 C: 4522 4523 4525 E: 4528 4529 4531 4532 4534 9.3.3.19. resource-constraint 4536 The server or recipient lacks the system resources necessary to 4537 service the request; the associated error type SHOULD be "wait" or 4538 "modify". 4540 C: 4544 4545 4546 4547 4549 E: 4553 4554 4556 4557 4559 9.3.3.20. service-unavailable 4561 The server or recipient does not currently provide the requested 4562 service; the associated error type SHOULD be "cancel". 4564 C: 4566 Hello? 4567 4569 S: 4571 4572 4574 4575 4577 An application MUST return a error instead of 4578 or if sending one of the 4579 latter errors would provide information about the intended 4580 recipient's network availability to an entity that is not authorized 4581 to know such information. 4583 9.3.3.21. subscription-required 4585 The requesting entity is not authorized to access the requested 4586 service because a prior subscription is required; the associated 4587 error type SHOULD be "auth". 4589 C: help 4593 4595 E: 4599 4600 4602 4603 4605 9.3.3.22. undefined-condition 4607 The error condition is not one of those defined by the other 4608 conditions in this list; any error type can be associated with this 4609 condition, and it SHOULD be used only in conjunction with an 4610 application-specific condition. 4612 C: 4616 My lord, dispatch; read o'er these articles. 4617 4618 4621 4623 S: 4627 4631 4634 4635 4636 4638 4639 4642 4643 4644 4646 9.3.3.23. unexpected-request 4648 The recipient or server understood the request but was not expecting 4649 it at this time (e.g., the request was out of order); the associated 4650 error type SHOULD be "wait" or "modify". 4652 C: 4656 4657 4660 4661 4663 E: 4667 4668 4670 4672 4673 4675 9.3.3.24. unknown-sender 4677 The stanza 'from' address specified by a connected client is not 4678 valid for the stream (e.g., the stanza does not include a 'from' 4679 address when multiple resources are bound to the stream as described 4680 under Section 8.6.4); the associated error type SHOULD be "modify". 4682 C: 4683 Wherefore art thou? 4684 4686 S: 4688 Wherefore art thou? 4689 4690 4691 4692 4694 9.3.4. Application-Specific Conditions 4696 As noted, an application MAY provide application-specific stanza 4697 error information by including a properly-namespaced child in the 4698 error element. The application-specific element SHOULD supplement or 4699 further qualify a defined element. Thus, the element will 4700 contain two or three child elements. 4702 4703 4704 4705 4706 4707 4709 4710 4711 4713 4715 [ ... application-specific information ... ] 4716 4717 4718 4719 4721 An entity that receives an application-specific error condition it 4722 does not understand MUST ignore the condition. 4724 9.4. Extended Content 4726 While the message, presence, and IQ stanzas provide basic semantics 4727 for messaging, availability, and request-response interactions, XMPP 4728 uses XML namespaces (see [XML-NAMES] to extend the basic stanza 4729 syntax for the purpose of providing additional functionality. Thus a 4730 message or presence stanza MAY contain one or more optional child 4731 elements specifying content that extends the meaning of the message 4732 (e.g., an XHTML-formatted version of the message body as described in 4733 [XEP-0071]), and an IQ stanza of type "get" or "set" MUST contain one 4734 such child element. This child element MAY have any name and MUST 4735 possess a namespace declaration (other than "jabber:client", "jabber: 4736 server", or "http://etherx.jabber.org/streams") that defines all data 4737 contained within the child element. Such a child element is said to 4738 be EXTENDED CONTENT and its namespace name is said to be an EXTENDED 4739 NAMESPACE. 4741 Support for any given extended namespace is OPTIONAL on the part of 4742 any implementation. If an entity does not understand such a 4743 namespace, the entity's expected behavior depends on whether the 4744 entity is (1) the recipient or (2) an entity that is routing the 4745 stanza to the recipient. 4747 Recipient: If a recipient receives a stanza that contains a child 4748 element it does not understand, it MUST silently ignore that 4749 particular XML data, i.e., it MUST NOT process it or present it to 4750 a user or associated application (if any). In particular: 4751 * If an entity receives a message or presence stanza that 4752 contains XML data qualified by a namespace it does not 4753 understand, the portion of the stanza that qualified by the 4754 unknown namespace MUST be ignored. 4755 * If an entity receives a message stanza whose only child element 4756 is qualified by a namespace it does not understand, it MUST 4757 ignore the entire stanza. 4758 * If an entity receives an IQ stanza of type "get" or "set" 4759 containing a child element qualified by a namespace it does not 4760 understand, the entity MUST return an IQ stanza of type "error" 4761 with an error condition of . 4762 Router: If a routing entity (typically a server) handles a stanza 4763 that contains a child element it does not understand, it MUST 4764 ignore the associated XML data by routing or delivering it 4765 untouched to the recipient. 4767 9.5. Stanza Size 4769 XMPP is optimized for the exchange of relatively large numbers of 4770 relatively small stanzas. A client or server MAY enforce a maximum 4771 stanza size. The maximum stanza size MUST NOT be smaller than 10000 4772 bytes, from the opening "<" character to the closing ">" character. 4773 If an entity receives a stanza that exceeds its maximum stanza size, 4774 it MUST return a stanza error or a stream error. 4777 10. Examples 4779 10.1. Client-to-Server 4781 The following examples show the XMPP data flow for a client 4782 negotiating an XML stream with a server, exchanging XML stanzas, and 4783 closing the negotiated stream. The server is "im.example.com", the 4784 server requires use of TLS, the client authenticates via the SASL 4785 PLAIN mechanism as "juliet@im.example.com", and the client binds a 4786 client-submitted resource to the stream. It is assumed that before 4787 sending the initial stream header, the client has already resolved an 4788 SRV record of _xmpp-client._tcp.im.example.com and has opened a TCP 4789 connection to the advertised port at the resolved IP address. 4791 Note: The alternate steps shown are provided only to illustrate 4792 the protocol for failure cases; they are not exhaustive and would 4793 not necessarily be triggered by the data sent in the examples. 4795 10.1.1. TLS 4797 Step 1: Client initiates stream to server: 4799 C: 4807 Step 2: Server responds by sending a response stream header to 4808 client: 4810 S: 4823 4824 4825 4826 4828 Step 4: Client sends STARTTLS command to server: 4830 C: 4832 Step 5: Server informs client that it is allowed to proceed: 4834 S: 4836 Step 5 (alt): Server informs client that STARTTLS negotiation has 4837 failed and closes both XML stream and TCP connection: 4839 S: 4841 S: 4842 Step 6: Client and server attempt to complete TLS negotiation over 4843 the existing TCP connection (see [TLS] for details). 4845 Step 7: If TLS negotiation is successful, client initiates a new 4846 stream to server: 4848 C: 4856 Step 7 (alt): If TLS negotiation is unsuccessful, server closes TCP 4857 connection. 4859 10.1.2. SASL 4861 Step 8: Server responds by sending a stream header to client along 4862 with any available stream features: 4864 S: 4874 4875 DIGEST-MD5 4876 PLAIN 4877 4878 4879 4881 Step 9: Client selects an authentication mechanism, in this case 4882 [PLAIN]: 4884 C: UjBtMzBSMGNrcw== 4887 Step 10: Server informs client of success: 4889 S: 4891 Step 10 (alt): Server returns error to client: 4893 S: 4894 4895 4897 Step 11: Client initiates a new stream to server: 4899 C: 4921 S: 4922 4923 4924 4925 4927 Upon being so informed that resource binding is mandatory, the client 4928 needs to bind a resource to the stream; here we assume that the 4929 client submits a human-readable text string. 4931 Step 13: Client binds a resource: 4933 C: 4934 4935 balcony 4936 4937 4939 Step 14: Server accepts submitted resource identifier and informs 4940 client of successful resource binding: 4942 S: 4943 4944 4945 juliet@im.example.com/balcony 4946 4947 4948 4950 10.1.4. Stanza Exchange 4952 Now the client is allowed to send XML stanzas over the negotiated 4953 stream. 4955 C: 4958 Art thou not Romeo, and a Montague? 4959 4961 If necessary, sender's server negotiates XML streams with intended 4962 recipient's server (see Section 10.2). 4964 The intended recipient replies and the message is delivered to the 4965 client. 4967 E: 4970 Neither, fair saint, if either thee dislike. 4971 4973 The client can subsequently send and receive an unbounded number of 4974 subsequent XML stanzas over the stream. 4976 10.1.5. Close 4978 Desiring to send no further messages, the client closes the stream. 4980 C: 4982 Consistent with the recommended stream closing handshake, the server 4983 closes the stream as well: 4985 S: 4987 Client now terminates the underlying TCP connection. 4989 10.2. Server-to-Server Examples 4991 The following examples show the data flow for a server negotiating an 4992 XML stream with another server, exchanging XML stanzas, and closing 4993 the negotiated stream. The initiating server ("Server1") is 4994 im.example.com; the receiving server ("Server2") is example.net and 4995 it requires use of TLS; im.example.com presents a certificate and 4996 authenticates via the SASL EXTERNAL mechanism. It is assumed that 4997 before sending the initial stream header, Server1 has already 4998 resolved an SRV record of _xmpp-server._tcp.example.net and has 4999 opened a TCP connection to the advertised port at the resolved IP 5000 address. 5002 Note: The alternate steps shown are provided only to illustrate 5003 the protocol for failure cases; they are not exhaustive and would 5004 not necessarily be triggered by the data sent in the examples. 5006 10.2.1. TLS 5008 Step 1: Server1 initiates stream to Server2: 5010 S1: 5017 Step 2: Server2 responds by sending a response stream header to 5018 Server1: 5020 S2: 5028 Step 3: Server2 sends stream features to Server1: 5030 S2: 5031 5032 5033 5034 5036 Step 4: Server1 sends the STARTTLS command to Server2: 5038 S1: 5040 Step 5: Server2 informs Server1 that it is allowed to proceed: 5042 S2: 5044 Step 5 (alt): Server2 informs Server1 that STARTTLS negotiation has 5045 failed and closes stream: 5047 S2: 5049 S2: 5051 Step 6: Server1 and Server2 attempt to complete TLS negotiation via 5052 TCP (see [TLS] for details). 5054 Step 7: If TLS negotiation is successful, Server1 initiates a new 5055 stream to Server2: 5057 S1: 5064 Step 7 (alt): If TLS negotiation is unsuccessful, Server2 closes TCP 5065 connection. 5067 10.2.2. SASL 5069 Step 8: Server2 sends a response stream header to Server1 along with 5070 available stream features (including a preference for the SASL 5071 EXTERNAL mechanism): 5073 S2: 5081 S2: 5082 5083 EXTERNAL 5084 5085 5086 5088 Step 9: Server1 selects the EXTERNAL mechanism, in this case with an 5089 authorization identity encoded according to [BASE64]: 5091 S1: eG1wcC5leGFtcGxlLmNvbQ 5094 The decoded authorization identity is "im.example.com". 5096 Step 10: Server2 determines that the authorization identity provided 5097 by Server1 matches the information in the presented certificate and 5098 therefore returns success: 5100 S2: 5102 Step 10 (alt): Server2 informs Server1 of failed authentication: 5104 S2: 5105 5106 5108 S2: 5109 Step 11: Server1 initiates a new stream to Server2: 5111 S1: 5118 Step 12: Server2 responds by sending a stream header to Server1 along 5119 with any additional features (or, in this case, an empty features 5120 element): 5122 S2: 5130 S2: 5132 10.2.3. Stanza Exchange 5134 Now Server1 is allowed to send XML stanzas to Server2 over the 5135 negotiated stream; here we assume that the transferred stanzas are 5136 those shown earlier for client-to-server communication, albeit over a 5137 server-to-server stream qualified by the 'jabber:server' namespace. 5139 Server1 sends XML stanza to Server2: 5141 S1: 5144 Art thou not Romeo, and a Montague? 5145 5147 The intended recipient replies and the message is delivered from 5148 Server2 to Server1. 5150 Server2 sends XML stanza to Server1: 5152 S2: 5155 Neither, fair saint, if either thee dislike. 5156 5158 10.2.4. Close 5160 Desiring to send no further messages, Server1 closes the stream. (In 5161 practice, the stream would most likely remain open for some time, 5162 since Server1 and Server2 do not immediately know if the stream will 5163 be needed for further communication.) 5165 S1: 5167 Consistent with the recommended stream closing handshake, Server2 5168 closes the stream as well: 5170 S2: 5172 Server1 now terminates the underlying TCP connection. 5174 11. Server Rules for Processing XML Stanzas 5176 An XMPP server MUST ensure in-order processing of XML stanzas between 5177 any two entities. This includes stanzas sent by a client to its 5178 server for direct processing by the server (e.g., in-order processing 5179 of a roster get and initial presence as described in [rfc3921bis]). 5181 Beyond the requirement for in-order processing, each server 5182 implementation will contain its own logic for processing stanzas it 5183 receives. Such logic determines whether the server needs to ROUTE a 5184 given stanza to another domain, DELIVER it to a local entity 5185 (typically a connected client associated with a local account), or 5186 HANDLE it directly within the server itself. The following rules 5187 apply. 5189 Note: Particular XMPP applications MAY specify delivery rules that 5190 modify or supplement the following rules; for example, a set of 5191 delivery rules for instant messaging and presence applications is 5192 defined in [rfc3921bis]. 5194 11.1. No 'to' Address 5196 11.1.1. Overview 5198 If the stanza possesses no 'to' attribute, the server MUST handle it 5199 directly on behalf of the entity that sent it, where the meaning of 5200 "handle it directly" depends on whether the stanza is message, 5201 presence, or IQ. Because all stanzas received from other servers 5202 MUST possess a 'to' attribute, this rule applies only to stanzas 5203 received from a local entity (such as a client) that is connected to 5204 the server. 5206 11.1.2. Message 5208 If the server receives a message stanza with no 'to' attribute, it 5209 MUST treat the message as if the 'to' address were the bare JID 5210 of the sending entity. 5212 11.1.3. Presence 5214 If the server receives a presence stanza with no 'to' attribute, it 5215 MUST broadcast it to the entities that are subscribed to the sending 5216 entity's presence, if applicable ([rfc3921bis] defines the semantics 5217 of such broadcasting for presence applications). 5219 11.1.4. IQ 5221 If the server receives an IQ stanza with no 'to' attribute, it MUST 5222 process the stanza on behalf of the account from which received the 5223 stanza, as follows: 5225 1. If the IQ stanza is of type "get" or "set" and the server 5226 understands the namespace that qualifies the payload, the server 5227 MUST handle the stanza on behalf of the sending entity or return 5228 an appropriate error to the sending entity. While the meaning of 5229 "handle" is determined by the semantics of the qualifying 5230 namespace, in general the server shall respond to the IQ stanza 5231 of type "get" or "set" by returning an appropriate IQ stanza of 5232 type "result" or "error", responding as if the server were the 5233 bare JID of the sending entity. As an example, if the sending 5234 entity sends an IQ stanza of type "get" where the payload is 5235 qualified by the 'jabber:iq:roster' namespace (as described in 5236 [rfc3921bis]), then the server shall return the roster associated 5237 with the sending entity's bare JID to the particular resource of 5238 the sending entity that requested the roster. 5239 2. If the IQ stanza is of type "get" or "set" and the server does 5240 not understand the namespace that qualifies the payload, the 5241 server MUST return an error to the sending entity, which MUST be 5242 . 5243 3. If the IQ stanza is of type "error" or "result", the server MUST 5244 handle the error or result as appropriate for the request- 5245 response interaction, responding as if the server were the bare 5246 JID of the sending entity. 5248 11.2. Local Domain 5250 If the hostname of the domain identifier portion of the JID contained 5251 in the 'to' attribute matches one of the configured hostnames of the 5252 server itself, the server MUST first determine if the hostname is 5253 serviced by the server or by a specialized local service. If the 5254 latter, the server MUST route the stanza to that service. If the 5255 former, the server MUST proceed as follows. 5257 11.2.1. Mere Domain 5259 If the JID contained in the 'to' attribute is of the form , 5260 then the server MUST either handle the stanza as appropriate for the 5261 stanza kind or return an error stanza to the sender. 5263 11.2.2. Domain with Resource 5265 If the JID contained in the 'to' attribute is of the form , then the server MUST either handle the stanza as 5267 appropriate for the stanza kind or return an error stanza to the 5268 sender. 5270 11.2.3. Node at Domain 5272 Note: For addresses of this type, more detailed rules in the 5273 context of instant messaging and presence applications are 5274 provided in [rfc3921bis]. 5276 11.2.3.1. No Such User 5278 If there is no local account associated with the , how 5279 the stanza shall be processed depends on the stanza type. 5281 o For a message stanza, the server MUST return a stanza error to the sender. 5283 o For a presence stanza, the server SHOULD silently discard the 5284 stanza. 5285 o For an IQ stanza, the server MUST return a 5286 stanza error to the sender. 5288 11.2.3.2. Bare JID 5290 If the JID contained in the 'to' attribute is of the form 5291 , how the stanza shall be processed depends on the 5292 stanza type. 5294 o For a message stanza, if there exists at least one connected 5295 resource for the node the server SHOULD deliver it to at least one 5296 of the connected resources. If there exists no connected 5297 resource, the server MUST either return an error or store the 5298 message offline for delivery when the account next has a connected 5299 resource. 5301 o For a presence stanza, if there exists at least one connected 5302 resource for the node the server SHOULD deliver it to at least one 5303 of the connected resources. If there exists no connected 5304 resource, the server MUST silently discard the stanza. 5305 o For an IQ stanza, the server MUST handle it directly on behalf of 5306 the intended recipient. 5308 11.2.3.3. Full JID 5310 If the JID contained in the 'to' attribute is of the form 5311 and there is no connected resource that 5312 exactly matches the full JID, the stanza shall be processed as if the 5313 JID were of the form . 5315 If the JID contained in the 'to' attribute is of the form 5316 and there is a connected resource that exactly 5317 matches the full JID, the server SHOULD deliver the stanza to that 5318 connected resource. 5320 11.3. Foreign Domain 5322 If the hostname of the domain identifier portion of the JID contained 5323 in the 'to' attribute does not match one of the configured hostnames 5324 of the server itself, the server SHOULD attempt to route the stanza 5325 to the foreign domain (subject to local service provisioning and 5326 security policies regarding inter-domain communication, since such 5327 communication is optional for any given deployment). There are two 5328 possible cases. 5330 11.3.1. Existing Stream 5332 If a server-to-server stream already exists between the two domains, 5333 the sender's server shall attempt to route the stanza to the 5334 authoritative server for the foreign domain over the existing stream. 5336 11.3.2. No Existing Stream 5338 If there exists no server-to-server stream between the two domains, 5339 the sender's server shall proceed as follows: 5341 1. Resolve the hostname of the foreign domain (as defined under 5342 Section 15.4). 5343 2. Negotiate a server-to-server stream between the two domains (as 5344 defined under Section 6 and Section 7). 5345 3. Route the stanza to the authoritative server for the foreign 5346 domain over the newly-established stream. 5348 11.3.3. Error Handling 5350 If routing of a stanza to the intended recipient's server is 5351 unsuccessful, the sender's server MUST return an error to the sender. 5352 If resolution of the foreign domain is unsuccessful, the stanza error 5353 MUST be . If resolution succeeds but 5354 streams cannot be negotiated, the stanza error MUST be . 5357 If stream negotiation with the intended recipient's server is 5358 successful but the foreign server cannot deliver the stanza to the 5359 recipient, the foreign server shall return an appropriate error to 5360 the sender by way of the sender's server. 5362 12. XML Usage 5364 12.1. Restrictions 5366 The Extensible Messaging and Presence Protocol (XMPP) defines a class 5367 of data objects called XML streams as well as the behavior of 5368 computer programs that process XML streams. XMPP is an application 5369 profile or restricted form of the Extensible Markup Language [XML], 5370 and a complete XML stream (including start and end stream tags) is a 5371 conforming XML document. 5373 However, XMPP does not deal with XML documents but with XML streams. 5374 Because XMPP does not require the parsing of arbitrary and complete 5375 XML documents, there is no requirement that XMPP needs to support the 5376 full feature set of [XML]. In particular, the following features of 5377 XML are prohibited in XMPP: 5379 o comments (as defined in Section 2.5 of [XML]) 5380 o processing instructions (Section 2.6 therein) 5381 o internal or external DTD subsets (Section 2.8 therein) 5382 o internal or external entity references (Section 4.2 therein) with 5383 the exception of predefined entities (Section 4.6 therein) 5385 An XMPP implementation MUST behave as follows with regard to these 5386 features: 5388 1. An XMPP implementation MUST NOT inject characters matching such 5389 features into an XML stream. 5390 2. If an XMPP implementation receives characters matching such 5391 features over an XML stream, it MUST return a stream error, which 5392 SHOULD be but MAY be . 5394 12.2. XML Namespace Names and Prefixes 5396 XML namespaces (see [XML-NAMES]) are used within XMPP streams to 5397 create strict boundaries of data ownership. The basic function of 5398 namespaces is to separate different vocabularies of XML elements that 5399 are structurally mixed together. Ensuring that XMPP streams are 5400 namespace-aware enables any allowable XML to be structurally mixed 5401 with any data element within XMPP. XMPP-specific rules for XML 5402 namespace names and prefixes are defined in the following 5403 subsections. 5405 12.2.1. Streams Namespace 5407 A streams namespace declaration is REQUIRED in all XML stream headers 5408 and the name of the streams namespace MUST be 5409 'http://etherx.jabber.org/streams'. If this rule is violated, the 5410 entity that receives the offending stream header MUST return a stream 5411 error to the sending entity, which SHOULD be but 5412 MAY be . 5414 The element names of the element and its and 5415 children MUST be qualified by the streams namespace prefix 5416 in all instances. If this rule is violated, the entity that receives 5417 the offending element MUST return a stream error to the sending 5418 entity, which SHOULD be . 5420 An implementation SHOULD generate only the 'stream:' prefix for these 5421 elements, and for historical reasons MAY accept only the 'stream:' 5422 prefix. If an entity receives a stream header with a streams 5423 namespace prefix it does not accept, it MUST return a stream error to 5424 the sending entity, which SHOULD be but MAY 5425 be . 5427 12.2.2. Default Namespace 5429 A default namespace declaration is REQUIRED and defines the allowable 5430 first-level children of the root stream element. This namespace 5431 declaration MUST be the same for the initial stream and the response 5432 stream so that both streams are qualified consistently. The default 5433 namespace declaration applies to the stream and all first-level child 5434 element sent within a stream unless explicitly qualified by the 5435 streams namespace or another namespace. 5437 A server implementation MUST support the following two default 5438 namespaces: 5440 o jabber:client -- this default namespace is declared when the 5441 stream is used for communication between a client and a server 5442 o jabber:server -- this default namespace is declared when the 5443 stream is used for communication between two servers 5445 A client implementation MUST support the 'jabber:client' default 5446 namespace. 5448 If an implementation accepts a stream that is qualified by the 5449 'jabber:client' or 'jabber:server' namespace, it MUST support the 5450 common attributes (Section 9.1) and basic semantics (Section 9.2) of 5451 all three core stanza types (message, presence, and IQ). 5453 For historical reasons, an implementation MAY refuse to support any 5454 other default namespaces. If an entity receives a stream header with 5455 a default namespace it does not support, it MUST return an stream error. 5458 An implementation MUST NOT generate namespace prefixes for elements 5459 qualified by the default namespace if the default namespace is 5460 'jabber:client' or 'jabber:server'. 5462 Note: The 'jabber:client' and 'jabber:server' namespaces are 5463 nearly identical but are used in different contexts (client-to- 5464 server communication for 'jabber:client' and server-to-server 5465 communication for 'jabber:server'). The only difference between 5466 the two is that the 'to' and 'from' attributes are OPTIONAL on 5467 stanzas sent over XML streams qualified by the 'jabber:client' 5468 namespace, whereas they are REQUIRED on stanzas sent over XML 5469 streams qualified by the 'jabber:server' namespace. 5471 An implementation MAY support a default namespace other than "jabber: 5472 client" or "jabber:server". However, because such namespaces would 5473 define applications other than XMPP, they are to be defined in 5474 separate specifications. 5476 12.2.3. Extended Namespaces 5478 An EXTENDED NAMESPACE is an XML namespace that qualifies extended 5479 content as defined under Section 9.4. For example, in the following 5480 stanza, the extended namespace is 'jabber:iq:roster': 5482 5485 5486 5487 An XML stanza MAY contain XML data qualified by more than one 5488 extended namespace, either at the direct child level of the stanza 5489 (for presence and message stanzas) or in any mix of levels (for all 5490 stanzas). 5492 5493 5496 5497 sha1-hash-of-image 5498 5499 5501 5502 Hello? 5503 5504 5505

Hello? 5506 5507 5508 5510 5513 5514 5515

some-long-opaque-string
5516 5517 5518 5520 An implementation SHOULD NOT generate namespace prefixes for elements 5521 qualified by content (as opposed to stream) namespaces other than the 5522 default namespace. However, if included, the namespace declarations 5523 for those prefixes MUST be included on the stanza root or a child 5524 thereof, not at the level of the stream element (this helps to ensure 5525 that any such namespace declaration is routed and delivered with the 5526 stanza, instead of assumed from the stream). 5528 12.3. Well-Formedness 5530 There are two varieties of well-formedness: 5532 o "XML-well-formedness" in accordance with the definition of "well- 5533 formed" in Section 2.1 of [XML]. 5534 o "Namespace-well-formedness" in accordance with the definition of 5535 "namespace-well-formed" in Section 7 of [XML-NAMES]. 5537 The following rules apply. 5539 An XMPP entity MUST NOT generate data that is not XML-well-formed. 5540 An XMPP entity MUST NOT accept data that is not XML-well-formed; 5541 instead it MUST return an stream error and 5542 close the stream over which the data was received. 5544 An XMPP entity MUST NOT generate data that is not namespace-well- 5545 formed. An XMPP server SHOULD NOT route or deliver data that is not 5546 namespace-well-formed, and SHOULD return a stanza error of or a stream error of in response 5548 to the receipt of such data. 5550 Note: Because these restrictions were underspecified in an earlier 5551 revision of this specification, it is possible that 5552 implementations based on that revision will send data that does 5553 not comply with the restrictions; an entity SHOULD be liberal in 5554 accepting such data. 5556 12.4. Validation 5558 A server is not responsible for ensuring that XML data delivered to a 5559 client or routed to another server is valid, in accordance with the 5560 definition of "valid" provided in Section 2.8 of [XML]. An 5561 implementation MAY choose to accept or provide only validated data, 5562 but such behavior is OPTIONAL. A client SHOULD NOT rely on the 5563 ability to send data that does not conform to the schemas, and SHOULD 5564 ignore any non-conformant elements or attributes on the incoming XML 5565 stream. 5567 Note: The terms "valid" and "well-formed" are distinct in XML. 5569 12.5. Inclusion of Text Declaration 5571 Implementations SHOULD send a text declaration before sending a 5572 stream header. Applications MUST follow the rules provided in [XML] 5573 regarding the circumstances under which a text declaration is 5574 included. 5576 12.6. Character Encoding 5578 Implementations MUST support the UTF-8 transformation of Universal 5579 Character Set [UCS2] characters, as required by [CHARSET] and defined 5580 in [UTF-8]. Implementations MUST NOT attempt to use any other 5581 encoding. If one party to an XML stream detects that the other party 5582 has attempted to send XML data with an encoding other than UTF-8, it 5583 MUST return a stream error, which SHOULD be 5584 but MAY be . 5586 Note: Because it is mandatory for an XMPP implementation to support 5587 all and only the UTF-8 encoding and because UTF-8 always has the same 5588 byte order, an implementation MUST NOT send a byte order mark ("BOM") 5589 at the beginning of the data stream. If an entity receives the 5590 Unicode character U+FEFF anywhere in an XML stream (including as the 5591 first character of the stream), it MUST interpret that character as a 5592 zero width no-break space, not as a byte order mark. 5594 12.7. Whitespace 5596 Except where explicitly disallowed (e.g., during TLS negotiation 5597 (Section 6) and SASL negotiation (Section 7)), either entity MAY send 5598 whitespace within the root stream element as separators between XML 5599 stanzas or between any other first-level elements sent over the 5600 stream. One common use for sending such whitespace is explained 5601 under Section 5.7.3. 5603 12.8. XML Versions 5605 XMPP is an application profile of XML 1.0. A future version of XMPP 5606 might be defined in terms of higher versions of XML, but this 5607 specification addresses XML 1.0 only. 5609 13. Compliance Requirements 5611 This section summarizes the specific aspects of the Extensible 5612 Messaging and Presence Protocol that MUST be supported by servers and 5613 clients in order to be considered compliant implementations, as well 5614 as additional protocol aspects that SHOULD be supported. For 5615 compliance purposes, we draw a distinction between core protocols 5616 (which MUST be supported by any server or client, regardless of the 5617 specific application) and instant messaging and presence protocols 5618 (which MUST be supported only by instant messaging and presence 5619 applications built on top of the core protocols). Compliance 5620 requirements that apply to all servers and clients are specified in 5621 this section; compliance requirements for instant messaging and 5622 presence applications are specified in the corresponding section of 5623 [rfc3921bis]. 5625 13.1. Servers 5627 A server MUST support the following core protocols in order to be 5628 considered compliant: 5630 o Conformance with [IDNA] for domain identifiers, the Nodeprep 5631 (Appendix A) profile of [STRINGPREP] for node identifiers, and the 5632 Resourceprep (Appendix B) profile of [STRINGPREP] for resource 5633 identifiers, as well as enforcement thereof for clients that 5634 authenticate with the server 5635 o XML streams (Section 5), including TLS negotiation (Section 6), 5636 SASL negotiation (Section 7), stream features (Section 5.5), and 5637 Resource Binding (Section 8) 5638 o The basic semantics of the three defined stanza types (i.e., 5639 , , and ) 5640 o Generation (and, where appropriate, handling) of error syntax and 5641 semantics related to streams, TLS, SASL, and XML stanzas 5643 For backward compatibility with the large deployed base of XMPP 5644 servers, server developers are advised to implement the server 5645 dialback protocol first specified in [RFC3920] and now documented in 5646 [XEP-0220], since that protocol is widely used for weak identity 5647 verification of peer servers in the absence of domain certificates. 5649 13.2. Clients 5651 A client MUST support the following core protocols in order to be 5652 considered compliant: 5654 o XML streams (Section 5), including TLS negotiation (Section 6), 5655 SASL negotiation (Section 7), stream features (Section 5.5), and 5656 Resource Binding (Section 8) 5657 o The basic semantics of the three defined stanza types (i.e., 5658 , , and ) 5659 o Handling (and, where appropriate, generation) of error syntax and 5660 semantics related to streams, TLS, SASL, and XML stanzas 5662 In addition, a client SHOULD support the following core protocols: 5664 o Conformance with [IDNA] for domain identifiers, the Nodeprep 5665 (Appendix A) profile of [STRINGPREP] for node identifiers, and the 5666 Resourceprep (Appendix B) profile of [STRINGPREP] for resource 5667 identifiers. 5669 14. Internationalization Considerations 5671 As specified under Section 12.6, XML streams MUST be encoded in 5672 UTF-8. 5674 As specified under Section 5.3, an XML stream SHOULD include an 'xml: 5675 lang' attribute specifying the default language for any XML character 5676 data that is intended to be presented to a human user. As specified 5677 under Section 9.1.5, an XML stanza SHOULD include an 'xml:lang' 5678 attribute if the stanza contains XML character data that is intended 5679 to be presented to a human user. A server SHOULD apply the default 5680 'xml:lang' attribute to stanzas it routes or delivers on behalf of 5681 connected entities, and MUST NOT modify or delete 'xml:lang' 5682 attributes on stanzas it receives from other entities. 5684 As specified under Section 3, a server MUST support and enforce 5685 [IDNA] for domain identifiers, the Nodeprep (Appendix A) profile of 5686 [STRINGPREP] for node identifiers, and the Resourceprep (Appendix B) 5687 profile of [STRINGPREP] for resource identifiers; this enables XMPP 5688 addresses to include a wide variety of Unicode characters outside the 5689 US-ASCII range. 5691 15. Security Considerations 5693 15.1. High Security 5695 For the purposes of XMPP communication (client-to-server and server- 5696 to-server), the term "high security" refers to the use of security 5697 technologies that provide both mutual authentication and integrity 5698 checking; in particular, when using certificate-based authentication 5699 to provide high security, a chain-of-trust SHOULD be established out- 5700 of-band, although a shared certification authority signing 5701 certificates could allow a previously unknown certificate to 5702 establish trust in-band. See Section 15.2 regarding certificate 5703 validation procedures. 5705 Implementations MUST support high security. Service provisioning 5706 SHOULD use high security, subject to local security policies. 5708 15.2. Certificates 5710 Channel encryption of an XML stream using Transport Layer Security as 5711 described under Section 6, and in some cases also authentication as 5712 described under Section 7, is commonly based on a digital certificate 5713 presented by the receiving entity (or, in the case of mutual 5714 authentication, both the receiving entity and the initiating entity). 5715 This section describes best practices regarding the generation of 5716 digital certificates to be presented by XMPP entities and the 5717 verification of digital certificates presented by XMPP entities. 5719 15.2.1. Certificate Generation 5721 15.2.1.1. Server Certificates 5723 In a digital certificate to be presented by an XMPP server (i.e., a 5724 SERVER CERTIFICATE), it is RECOMMENDED for the certificate to include 5725 one or more JIDs (i.e., domain identifiers) associated with domains 5726 serviced at the server. The representations described in the 5727 following sections are RECOMMENDED. These representations are 5728 provided in preference order. 5730 15.2.1.1.1. SRVName 5732 A server's domain identifier SHOULD be represented as an SRVName, 5733 i.e., as an otherName field of type "id-on-dnsSRV" as specified in 5734 [X509-SRV]. 5736 15.2.1.1.2. dNSName 5738 A server's domain identifier SHOULD be represented as a dNSName, 5739 i.e., as a subjectAltName extension of type dNSName. 5741 The dNSName MAY contain the wildcard character '*'. The wildcard 5742 character applies only to the left-most domain name component or 5743 component fragment and matches any single component or component 5744 fragment. For instance, a dNSName of *.example.com matches 5745 foo.example.com but not bar.foo.example.com or example.com itself; 5746 similarly, a dNSName of im*.example.net matches im1.example.net and 5747 im2.example.net but not chat.example.net or example.net itself. 5749 15.2.1.1.3. XmppAddr 5751 A server's domain identifier MAY be represented as an XmppAddr, i.e., 5752 as a UTF8String within an otherName entity inside the subjectAltName, 5753 using the [ASN.1] Object Identifier "id-on-xmppAddr" specified under 5754 Section 15.2.1.3. In server certificates, this representation is 5755 included only for the sake of backward-compatibility. 5757 15.2.1.1.4. Common Name 5759 A server's domain identifier SHOULD NOT be represented as a Common 5760 Name; instead, the Common Name field SHOULD be reserved for 5761 representation of a human-friendly name. 5763 15.2.1.1.5. Examples 5765 For our first (relatively simple) example, consider a company called 5766 "Example Products, Inc." It hosts an XMPP service at 5767 "im.example.com" (i.e., user addresses at the service are of the form 5768 "user@im.example.com"), and SRV lookups for the xmpp-client and xmpp- 5769 server services at "im.example.com" yield one machine, called 5770 "x.example.com", as follows: 5772 _xmpp-client._tcp.im.example.com. 400 IN SRV 20 0 5222 x.example.com 5773 _xmpp-server._tcp.im.example.com. 400 IN SRV 20 0 5269 x.example.com 5775 The certificate presented by x.example.com contains the following 5776 representations: 5778 o An otherName type of SRVName (id-on-dnsSRV) containing an 5779 IA5String (ASCII) string of: "_xmpp-client.im.example.com" 5780 o An otherName type of SRVName (id-on-dnsSRV) containing an 5781 IA5String (ASCII) string of: "_xmpp-server.im.example.com" 5782 o A dNSName containing an ASCII string of "im.example.com" 5783 o An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 5784 string of: "im.example.com" 5785 o A CN containing an ASCII string of "Example Products, Inc." 5787 For our second (more complex) example, consider an ISP called 5788 "Example Internet Services". It hosts an XMPP service at 5789 "example.net" (i.e., user addresses at the service are of the form 5790 "user@example.net"), but SRV lookups for the xmpp-client and xmpp- 5791 server services at "example.net" yield two machines ("x1.example.net" 5792 and "x2.example.net"), as follows: 5794 _xmpp-client._tcp.example.net. 68400 IN SRV 20 0 5222 x1.example.net. 5795 _xmpp-client._tcp.example.net. 68400 IN SRV 20 0 5222 x2.example.net. 5796 _xmpp-server._tcp.example.net. 68400 IN SRV 20 0 5269 x1.example.net. 5797 _xmpp-server._tcp.example.net. 68400 IN SRV 20 0 5269 x2.example.net. 5799 Example Internet Services also hosts chatrooms at chat.example.net, 5800 and provides an xmpp-server SRV record for that service as well (thus 5801 enabling entity from foreign domains to access that service). It 5802 also might provide other such services in the future, so it wishes to 5803 represent a wildcard in its certificate to handle such growth. 5805 The certificate presented by either x1.example.net or x2.example.net 5806 contains the following representations: 5808 o An otherName type of SRVName (id-on-dnsSRV) containing an 5809 IA5String (ASCII) string of: "_xmpp-client.example.net" 5810 o An otherName type of SRVName (id-on-dnsSRV) containing an 5811 IA5String (ASCII) string of: "_xmpp-server.example.net" 5812 o An otherName type of SRVName (id-on-dnsSRV) containing an 5813 IA5String (ASCII) string of: "_xmpp-server.chat.example.net" 5815 o A dNSName containing an ASCII string of "example.net" 5816 o A dNSName containing an ASCII string of "*.example.net" 5817 o An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 5818 string of: "example.net" 5819 o An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 5820 string of: "chat.example.net" 5821 o A CN containing an ASCII string of "Example Internet Services" 5823 15.2.1.2. Client Certificates 5825 In a digital certificate to be presented by an XMPP client controlled 5826 by a human user (i.e., a CLIENT CERTIFICATE), it is RECOMMENDED for 5827 the certificate to include one or more JIDs associated with an XMPP 5828 user. If included, a JID MUST be represented as an XmppAddr, i.e., 5829 as a UTF8String within an otherName entity inside the subjectAltName, 5830 using the [ASN.1] Object Identifier "id-on-xmppAddr" specified under 5831 Section 15.2.1.3. 5833 15.2.1.3. ASN.1 Object Identifier 5835 The [ASN.1] Object Identifier "id-on-xmppAddr" (also called an 5836 XmppAddr) is defined as follows. 5838 id-pkix OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) 5839 dod(6) internet(1) security(5) mechanisms(5) pkix(7) } 5841 id-on OBJECT IDENTIFIER ::= { id-pkix 8 } -- other name forms 5843 id-on-xmppAddr OBJECT IDENTIFIER ::= { id-on 5 } 5845 XmppAddr ::= UTF8String 5847 As an alternative to the "id-on-xmppAddr" notation, this Object 5848 Identifier MAY be represented in dotted display format (i.e., 5849 "1.3.6.1.5.5.7.8.5") or in the Uniform Resource Name notation 5850 specified in [URN-OID] (i.e., "urn:oid:1.3.6.1.5.5.7.8.5"). 5852 Thus for example the JID "juliet@im.example.com" as included in a 5853 certificate could be formatted in any of the following three ways: 5855 id-on-xmppAddr: 5856 subjectAltName=otherName:id-on-xmppAddr;UTF8:juliet@im.example.com 5857 dotted display format: subjectAltName=otherName: 5858 1.3.6.1.5.5.7.8.5;UTF8:juliet@im.example.com 5860 URN notation: subjectAltName=otherName:urn:oid: 5861 1.3.6.1.5.5.7.8.5;UTF8:juliet@im.example.com 5863 Use of the "id-on-xmppAddr" format is RECOMMENDED in the generation 5864 of certificates, but all three formats MUST be supported for the 5865 purpose of certificate validation. 5867 15.2.2. Certificate Validation 5869 When an XMPP entity is presented with a server certificate or client 5870 certificate by a peer for the purpose of encryption or authentication 5871 of XML streams as described under Section 6 and Section 7, the entity 5872 MUST validate the certificate to determine if the certificate shall 5873 be considered a TRUSTED CERTIFICATE, i.e., a certificate that is 5874 acceptable for encryption and/or authentication in accordance with 5875 the XMPP entity's local service policies or configured settings. 5877 For both server certificates and client certificates, the validating 5878 entity MUST verify the integrity of the certificate, MUST verify that 5879 the certificate has been properly signed by the issuing Certificate 5880 Authority, and MUST support certificate revocation messages. An 5881 implementation MUST enable a human user to view information about the 5882 full chain of certificates. 5884 The following sections describe certificate validation rules for 5885 server-to-server and client-to-server streams. 5887 15.2.2.1. Server-to-Server Streams 5889 When an XMPP entity (client or server) validates a certificate 5890 presented by an XMPP server, there are three possible cases, as 5891 discussed in the following sections. 5893 15.2.2.1.1. Case #1 5895 If the server certificate appears to be certified by a chain of 5896 certificates terminating in a trust anchor (as described in Section 5897 6.1 of [X509]), the entity MUST check the certificate for any 5898 instances of the SRVName, dNSName, and XmppAddr (in that order of 5899 preference) as described under Section 15.2.1.1.1, 5900 Section 15.2.1.1.2, and Section 15.2.1.1.3. There are three possible 5901 sub-cases: 5903 Sub-Case #1: The entity finds at least one SRVName, dNSName, or 5904 XmppAddr that matches the hostname to which it attempted to 5905 connect; the entity MUST use this represented domain identifier as 5906 the validated identity of the XMPP server. The server certificate 5907 MUST be checked against the hostname as provided by the entity 5908 (client or server), not the hostname as resolved via the Domain 5909 Name System; e.g., if a user specifies a hostname of "example.net" 5910 but a [DNS-SRV] lookup returns "x1.example.net", the certificate 5911 MUST be checked as "example.net". A user-oriented client MAY 5912 provide a configuration setting that enables a human user to 5913 explicitly specify a hostname to be checked for connection 5914 purposes. 5915 Sub-Case #2: The entity finds no SRVName, dNSName, or XmppAddr that 5916 matches the hostname to which it attempted to connect and a human 5917 user has not permanently accepted the certificate during a 5918 previous connection attempt; the entity MUST NOT use the 5919 represented domain identifier (if any) as the validated identity 5920 of the XMPP server. Instead, if the connecting entity is a user- 5921 oriented client then it MUST either (1) automatically terminate 5922 the connection with a bad certificate error or (2) show the 5923 certificate (including the entire certificate chain) to the user 5924 and give the user the choice of terminating the connecting or 5925 accepting the certificate temporarily (i.e., for this connection 5926 attempt only) or permanently (i.e., for all future connection 5927 attempts) and then continuing with the connection; if a user 5928 permanently accepts a certificate in this way, the client MUST 5929 cache the certificate (or some non-forgeable representation such 5930 as a hash) and in future connection attempts behave as in Sub-Case 5931 #3. (It is the resposibility of the human user to verify the hash 5932 or fingerprint of the certificate with the peer over a trusted 5933 communication layer.) If the connecting entity is an XMPP server 5934 or an automated client, the application SHOULD terminate the 5935 connection (with a bad certificate error) and log the error to an 5936 appropriate audit log; an XMPP server or automated client MAY 5937 provide a configuration setting that disables this check, but MUST 5938 provide a setting that enables the check. 5939 Sub-Case #3: The entity finds no SRVName, dNSName, or XmppAddr that 5940 matches the hostname to which it attempted to connect but a human 5941 user has permanently accepted the certificate during a previous 5942 connection attempt; the entity MUST verify that the cached 5943 certificate was presented and MUST notify the user if the 5944 certificate has changed. 5946 15.2.2.1.2. Case #2 5948 If the server certificate is certified by a Certificate Authority not 5949 known to the entity, the entity MUST proceed as under Case #1, Sub- 5950 Case #2 or Case #1, Sub-Case #3 as appropriate. 5952 15.2.2.1.3. Case #3 5954 If the server certificate is self-signed, the entity MUST proceed as 5955 under Case #1, Sub-Case #2 or Case #1, Sub-Case #3 as appropriate. 5957 15.2.2.2. Client-to-Server Streams 5959 When an XMPP server validates a certificate presented by a client, 5960 there are three possible cases, as discussed in the following 5961 sections. 5963 15.2.2.2.1. Case #1 5965 If the client certificate appears to be certified by a chain of 5966 certificates terminating in a trust anchor (as described in Section 5967 6.1 of [X509]), the server MUST check the certificate for any 5968 instances of the XmppAddr as described under Section 15.2.1.3. There 5969 are three possible sub-cases: 5971 Sub-Case #1: The server finds one XmppAddr for which the domain 5972 identifier portion of the represented JID matches one of the 5973 configured hostnames of the server itself; the server SHOULD use 5974 this represented JID as the validated identity of the client. 5975 Sub-Case #2: The server finds more than one XmppAddr for which the 5976 domain identifier portion of the represented JID matches one of 5977 the configured hostnames of the server itself; the server SHOULD 5978 use one of these represented JIDs as the validated identity of the 5979 client, choosing among them according to local service policies or 5980 based on the 'to' address of the initial stream header. 5981 Sub-Case #3: The server finds no XmppAddrs, or finds at least one 5982 XmppAddr but the domain identifier portion of the represented JID 5983 does not match one of the configured hostnames of the server 5984 itself; the server MUST NOT use the represented JID (if any) as 5985 the validated identity of the client but instead MUST either 5986 validate the identity of the client using other means. 5988 15.2.2.2.2. Case #2 5990 If the client certificate is certified by a Certificate Authority not 5991 known to the server, the server MUST proceed as under Case #1, Sub- 5992 Case #3. 5994 15.2.2.2.3. Case #3 5996 If the client certificate is self-signed, the server MUST proceed as 5997 under Case #1, Sub-Case #3. 5999 15.2.2.3. Use of Certificates in XMPP Extensions 6001 Certificates MAY be used in extensions to XMPP for the purpose of 6002 application-layer encryption or authentication above the level of XML 6003 streams (e.g., for end-to-end encryption). Such extensions shall 6004 define their own certificate handling rules, which at a minimum 6005 SHOULD be consistent with the rules specified herein but MAY specify 6006 additional rules. 6008 15.3. Client-to-Server Communication 6010 A compliant client implementation MUST support both TLS and SASL for 6011 connections to a server. 6013 The TLS protocol for encrypting XML streams (defined under Section 6) 6014 provides a reliable mechanism for helping to ensure the 6015 confidentiality and data integrity of data exchanged between two 6016 entities. 6018 The SASL protocol for authenticating XML streams (defined under 6019 Section 7) provides a reliable mechanism for validating that a client 6020 connecting to a server is who it claims to be. 6022 Client-to-server communication MUST NOT proceed until the DNS 6023 hostname asserted by the server has been resolved as specified under 6024 Section 4. If there is a mismatch between the hostname to which a 6025 client attempted to connect (e.g., "example.net") and the hostname to 6026 which the client actually connects (e.g., "x1.example.net"), the 6027 client MUST warn a human user about the mismatch and the human user 6028 MUST approve the connection before the client proceeds; however, the 6029 client MAY also allow the user to add the presented hostname to a 6030 configured set of accepted hostnames to expedite future connections. 6032 A client's IP address and method of access MUST NOT be made public by 6033 a server, nor are any connections other than the original server 6034 connection required. This helps to protect the client's server from 6035 direct attack or identification by third parties. 6037 15.4. Server-to-Server Communication 6039 A compliant server implementation MUST support both TLS and SASL for 6040 inter-domain communication. 6042 Because service provisioning is a matter of policy, it is optional 6043 for any given domain to communicate with other domains, and server- 6044 to-server communication can be disabled by the administrator of any 6045 given deployment. If a particular domain enables inter-domain 6046 communication, it SHOULD enable high security. 6048 Administrators might want to require use of SASL for server-to-server 6049 communication to ensure both authentication and confidentiality 6050 (e.g., on an organization's private network). Compliant 6051 implementations SHOULD support SASL for this purpose. 6053 Server-to-server communication MUST NOT proceed until the DNS 6054 hostnames asserted by both servers have been resolved as specified 6055 under Section 4. 6057 15.5. Order of Layers 6059 The order of layers in which protocols MUST be stacked is: 6061 1. TCP 6062 2. TLS 6063 3. SASL 6064 4. XMPP 6066 The rationale for this order is that [TCP] is the base connection 6067 layer used by all of the protocols stacked on top of TCP, [TLS] is 6068 often provided at the operating system layer, [SASL] is often 6069 provided at the application layer, and XMPP is the application 6070 itself. 6072 15.6. Mandatory-to-Implement Technologies 6074 At a minimum, all implementations MUST support the following 6075 mechanisms: 6077 for confidentiality only: TLS (using the 6078 TLS_RSA_WITH_3DES_EDE_CBC_SHA cipher) 6079 for both confidentiality and authentication: TLS plus the SASL PLAIN 6080 mechanism (See [PLAIN]) for password-based authentication and TLS 6081 plus the SASL EXTERNAL mechanism (see Appendix A of [SASL]) for 6082 non-password-based authentication (using the 6083 TLS_RSA_WITH_3DES_EDE_CBC_SHA cipher supporting peer certificates) 6085 Naturally, implementations MAY support other ciphers with TLS and MAY 6086 support other SASL mechanisms. 6088 Note: The use of TLS plus SASL PLAIN replaces the SASL DIGEST-MD5 6089 mechanism as XMPP's mandatory-to-implement password-based method 6090 for authentication. For backward-compatibility, implementations 6091 are encouraged to continue supporting the SASL DIGEST-MD5 6092 mechanism as specified in [DIGEST-MD5]. Refer to [PLAIN] for 6093 important security considerations related to the SASL PLAIN 6094 mechanism. 6096 15.7. SASL Downgrade Attacks 6098 Because the initiating entity chooses an acceptable SASL mechanism 6099 from the list presented by the receiving entity, the initiating 6100 entity depends on the receiving entity's list for authentication. 6102 This dependency introduces the possibility of a downgrade attack if 6103 an attacker can gain control of the channel and therefore present a 6104 weak list of mechanisms. To prevent this attack, the parties SHOULD 6105 protect the channel using TLS before attempting SASL negotiation. 6107 15.8. Lack of SASL Channel Binding to TLS 6109 The SASL framework itself does not provide a method for binding SASL 6110 authentication to a security layer providing confidentiality and 6111 integrity protection that was negotiated at a lower layer. Such a 6112 binding is known as a "channel binding" (see [CHANNEL]). Some SASL 6113 mechanisms provide channel bindings. However, if a SASL mechanism 6114 does not provide a channel binding, then the mechanism cannot provide 6115 a way to verify that the source and destination end points to which 6116 the lower layer's security is bound are equivalent to the end points 6117 that SASL is authenticating; furthermore, if the end points are not 6118 identical, then the lower layer's security cannot be trusted to 6119 protect data transmitted between the SASL-authenticated entities. In 6120 such a situation, a SASL security layer SHOULD be negotiated that 6121 effectively ignores the presence of the lower-layer security. 6123 15.9. Use of base64 in SASL 6125 Both the client and the server MUST verify any base64 data received 6126 during SASL negotiation (Section 7). An implementation MUST reject 6127 (not ignore) any characters that are not explicitly allowed by the 6128 base64 alphabet; this helps to guard against creation of a covert 6129 channel that could be used to "leak" information. 6131 An implementation MUST NOT break on invalid input and MUST reject any 6132 sequence of base64 characters containing the pad ('=') character if 6133 that character is included as something other than the last character 6134 of the data (e.g., "=AAA" or "BBBB=CCC"); this helps to guard against 6135 buffer overflow attacks and other attacks on the implementation. 6137 While base 64 encoding visually hides otherwise easily recognized 6138 information (such as passwords), it does not provide any 6139 computational confidentiality. 6141 All uses of base 64 encoding MUST follow the definition in Section 4 6142 of [BASE64] and padding bits MUST be set to zero. 6144 15.10. Stringprep Profiles 6146 XMPP makes use of the [NAMEPREP] profile of [STRINGPREP] for 6147 processing of domain identifiers; for security considerations related 6148 to Nameprep, refer to the appropriate section of [NAMEPREP]. 6150 In addition, XMPP defines two profiles of [STRINGPREP]: Nodeprep 6151 (Appendix A) for node identifiers and Resourceprep (Appendix B) for 6152 resource identifiers. 6154 The Unicode and ISO/IEC 10646 repertoires have many characters that 6155 look similar. In many cases, users of security protocols might 6156 perform visual matching, such as when comparing the names of trusted 6157 third parties. Because it is impossible to map similar-looking 6158 characters without a great deal of context (such as knowing the fonts 6159 used), stringprep does nothing to map similar-looking characters 6160 together, nor to prohibit some characters because they look like 6161 others. 6163 A node identifier can be employed as one part of an entity's address 6164 in XMPP. One common usage is as the username of an instant messaging 6165 user; another is as the name of a multi-user conference room; and 6166 many other kinds of entities could use node identifiers as part of 6167 their addresses. The security of such services could be compromised 6168 based on different interpretations of the internationalized node 6169 identifier; for example, a user entering a single internationalized 6170 node identifier could access another user's account information, or a 6171 user could gain access to a hidden or otherwise restricted chat room 6172 or service. 6174 A resource identifier can be employed as one part of an entity's 6175 address in XMPP. One common usage is as the name for an instant 6176 messaging user's connected resource; another is as the nickname of a 6177 user in a multi-user conference room; and many other kinds of 6178 entities could use resource identifiers as part of their addresses. 6179 The security of such services could be compromised based on different 6180 interpretations of the internationalized resource identifier; for 6181 example, a user could attempt to initiate multiple connections with 6182 the same name, or a user could send a message to someone other than 6183 the intended recipient in a multi-user conference room. 6185 15.11. Address Spoofing 6187 As discussed in [XEP-0165], there are two forms of address spoofing: 6188 forging and mimicking. 6190 15.11.1. Address Forging 6192 In the context of XMPP technologies, address forging occurs when an 6193 entity is able to generate an XML stanza whose 'from' address does 6194 not correspond to the account credentials with which the entity 6195 authenticated onto the network (or an authorization identity provided 6196 during SASL negotiation (Section 7)). For example, address forging 6197 occurs if an entity that authenticated as "juliet@im.example.com" is 6198 able to send XML stanzas from "nurse@im.example.com" or 6199 "romeo@example.net". 6201 Address forging is difficult in XMPP systems, given the requirement 6202 for sending servers to stamp 'from' addresses and for receiving 6203 servers to verify sending domains via server-to-server 6204 authentication. However, address forging is not impossible, since a 6205 rogue server could forge JIDs at the sending domain by ignoring the 6206 stamping requirement. A rogue server could even forge JIDs at other 6207 domains by means of a DNS poisoning attack if [DNSSEC] is not used. 6208 This specification does not define methods for discovering or 6209 counteracting such rogue servers. 6211 15.11.2. Address Mimicking 6213 Address mimicking occus when an entity provides legitimate 6214 authentication credentials for and sends XML stanzas from an account 6215 whose JID appears to a human user to be the same as another JID. For 6216 example, in some XMPP clients the address "paypa1@example.org" 6217 (spelled with the number one as the final character of the node 6218 identifier) might appear to be the same as "paypal@example.org 6219 (spelled with the lower-case version of the letter "L"), especially 6220 on casual visual inspection; this phenomenon is sometimes called 6221 "typejacking". A more sophisticated example of address mimicking 6222 might involve the use of characters from outside the US-ASCII range, 6223 such as the Cherokee characters U+13DA U+13A2 U+13B5 U+13AC U+13A2 6224 U+13AC U+13D2 instead of the US-ASCII characters "STPETER". 6226 In some examples of address mimicking, it is unlikely that the 6227 average user could tell the difference between the real JID and the 6228 fake JID. (Naturally, there is no way to distinguish with full 6229 certainty which is the fake JID and which is the real JID; in some 6230 communication contexts, the JID with Cherokee characters might be the 6231 real JID and the JID with US-ASCII characters might thus appear to be 6232 the fake JID.) Because JIDs can contain almost any Unicode 6233 character, it can be relatively easy to mimic some JIDs in XMPP 6234 systems. The possibility of address mimicking introduces security 6235 vulnerabilities of the kind that have also plagued the World Wide 6236 Web, specifically the phenomenon known as phishing. 6238 Mimicked addresses that involve characters from only one character 6239 set or from the character set typically employed by a particular user 6240 are not easy to combat (e.g., the simple typejacking attack 6241 previously described, which relies on a surface similarity between 6242 the characters "1" and "l" in some presentations). However, mimicked 6243 addresses that involve characters from more than one character set, 6244 or from a character set not typically employed by a particular user, 6245 can be mitigated somewhat through intelligent presentation. In 6246 particular, every human user of an XMPP technology presumably has a 6247 preferred language (or, in some cases, a small set of preferred 6248 languages), which an XMPP application SHOULD gather either explicitly 6249 from the user or implicitly via the operating system of the user's 6250 device. Furthermore, every language has a range (or a small set of 6251 ranges) of characters normally used to represent that language in 6252 textual form. Therefore, an XMPP application SHOULD warn the user 6253 when presenting a JID that uses characters outside the normal range 6254 of the user's preferred language(s). This recommendation is not 6255 intended to discourage communication across language communities; 6256 instead, it recognizes the existence of such language communities and 6257 encourages due caution when presenting unfamiliar character sets to 6258 human users. 6260 For more detailed recommendations regarding prevention of address 6261 mimicking in XMPP systems, refer to [XEP-0165]. 6263 15.12. Firewalls 6265 Communication using XMPP normally occurs over TCP connections on port 6266 5222 (client-to-server) or port 5269 (server-to-server), as 6267 registered with the IANA (see Section 16). Use of these well-known 6268 ports allows administrators to easily enable or disable XMPP activity 6269 through existing and commonly-deployed firewalls. 6271 15.13. Denial of Service 6273 [DOS] defines denial of service as follows: 6275 A Denial-of-Service (DoS) attack is an attack in which one or more 6276 machines target a victim and attempt to prevent the victim from 6277 doing useful work. The victim can be a network server, client or 6278 router, a network link or an entire network, an individual 6279 Internet user or a company doing business using the Internet, an 6280 Internet Service Provider (ISP), country, or any combination of or 6281 variant on these. 6283 [XEP-0205] provides a detailed discussion of potential denial of 6284 service attacks against XMPP systems and best practices for 6285 preventing such attacks. The recommendations include: 6287 1. A server implementation SHOULD enable a server administrator to 6288 limit the number of TCP connections that it will accept from a 6289 given IP address at any one time. If an entity attempts to 6290 connect but the maximum number of TCP connections has been 6291 reached, the receiving server MUST NOT allow the new connection 6292 to proceed. 6294 2. A server implementation SHOULD enable a server administrator to 6295 limit the number of TCP connection attempts that it will accept 6296 from a given IP address in a given time period. (While it is 6297 possible to limit the number of connections at the TCP layer 6298 rather than at the XMPP application layer, this is not advisable 6299 because limits at the TCP layer might result in an inability to 6300 access non-XMPP services.) If an entity attempts to connect but 6301 the maximum number of connections has been reached, the receiving 6302 server MUST NOT allow the new connection to proceed. 6303 3. A server MUST NOT process XML stanzas from clients that have not 6304 yet provided appropriate authentication credentials and MUST NOT 6305 process XML stanzas from peer servers whose identity it has not 6306 either authenticated via SASL or weakly verified via server 6307 dialback (see [XEP-0220]). 6308 4. A server implementation SHOULD enable a server administrator to 6309 limit the number of connected resources it will allow an account 6310 to bind at any one time. If a client attempts to bind a resource 6311 but it has already reached the configured number of allowable 6312 resources, the receiving server MUST return a stanza error. 6314 5. A server implementation SHOULD enable a server administrator to 6315 limit the size of stanzas it will accept from a connected client 6316 or peer server. If a connected resource or peer server sends a 6317 stanza that violates the upper limit, the receiving server SHOULD 6318 NOT process the stanza and instead SHOULD return a 6319 stanza error. Alternatively (e.g., if the sender has sent an 6320 egregiously large stanza), the server MAY instead return a 6321 stream error. 6322 6. A server implementation SHOULD enable a server administrator to 6323 limit the number of XML stanzas that a connected client is 6324 allowed to send to distinct recipients within a given time 6325 period. If a connected client sends too many stanzas to distinct 6326 recipients in a given time period, the receiving server SHOULD 6327 NOT process the stanza and instead SHOULD return an stanza error. 6329 7. A server implementation SHOULD enable a server administrator to 6330 limit the amount of bandwidth it will allow a connected client or 6331 peer server to use in a given time period. 6332 8. A server implementation MAY enable a server administrator to 6333 limit the types of stanzas (based on the extended content 6334 "payload") that it will allow a connected resource or peer server 6335 send over an active connection. Such limits and restrictions are 6336 a matter of deployment policy. 6337 9. A server implementation MAY refuse to route or deliver any stanza 6338 that it considers to be abusive, with or without returning an 6339 error to the sender. 6341 For more detailed recommendations regarding denial of service attacks 6342 in XMPP systems, refer to [XEP-0205]. 6344 15.14. Presence Leaks 6346 One of the core aspects of XMPP is presence: information about the 6347 network availability of an XMPP entity (i.e., whether the entity is 6348 currently online or offline). A PRESENCE LEAK occurs when an 6349 entity's network availability is inadvertently and involuntarily 6350 revealed to a second entity that is not authorized to know the first 6351 entity's network availability. 6353 Although presence is discussed more fully in [rfc3921bis], it is 6354 important to note that an XMPP server MUST NOT leak presence. In 6355 particular at the core XMPP level, real-time addressing and network 6356 availability is associated with a specific connected resource; 6357 therefore, any disclosure of a connected resource's full JID 6358 comprises a presence leak. To help prevent such a presence leak, a 6359 server MUST NOT return different stanza errors if a potential 6360 attacker sends XML stanzas to the entity's bare JID () 6361 or full JID (). 6363 15.15. Directory Harvesting 6365 To help prevent directory harvesting attacks, a server MUST NOT 6366 return different stanza errors if a potential attacker sends XML 6367 stanzas to an existing entity or a nonexistent entity. 6369 16. IANA Considerations 6371 The following sections update the registrations provided in 6372 [RFC3920]. 6374 16.1. XML Namespace Name for TLS Data 6376 A URN sub-namespace for STARTTLS negotiation data in the Extensible 6377 Messaging and Presence Protocol (XMPP) is defined as follows. (This 6378 namespace name adheres to the format defined in [XML-REG].) 6380 URI: urn:ietf:params:xml:ns:xmpp-tls 6381 Specification: XXXX 6382 Description: This is the XML namespace name for STARTTLS negotiation 6383 data in the Extensible Messaging and Presence Protocol (XMPP) as 6384 defined by XXXX. 6386 Registrant Contact: IETF, XMPP Working Group, 6388 16.2. XML Namespace Name for SASL Data 6390 A URN sub-namespace for SASL negotiation data in the Extensible 6391 Messaging and Presence Protocol (XMPP) is defined as follows. (This 6392 namespace name adheres to the format defined in [XML-REG].) 6394 URI: urn:ietf:params:xml:ns:xmpp-sasl 6395 Specification: XXXX 6396 Description: This is the XML namespace name for SASL negotiation 6397 data in the Extensible Messaging and Presence Protocol (XMPP) as 6398 defined by XXXX. 6399 Registrant Contact: IETF, XMPP Working Group, 6401 16.3. XML Namespace Name for Stream Errors 6403 A URN sub-namespace for stream error data in the Extensible Messaging 6404 and Presence Protocol (XMPP) is defined as follows. (This namespace 6405 name adheres to the format defined in [XML-REG].) 6407 URI: urn:ietf:params:xml:ns:xmpp-streams 6408 Specification: XXXX 6409 Description: This is the XML namespace name for stream error data in 6410 the Extensible Messaging and Presence Protocol (XMPP) as defined 6411 by XXXX. 6412 Registrant Contact: IETF, XMPP Working Group, 6414 16.4. XML Namespace Name for Resource Binding 6416 A URN sub-namespace for resource binding in the Extensible Messaging 6417 and Presence Protocol (XMPP) is defined as follows. (This namespace 6418 name adheres to the format defined in [XML-REG].) 6420 URI: urn:ietf:params:xml:ns:xmpp-bind 6421 Specification: XXXX 6422 Description: This is the XML namespace name for resource binding in 6423 the Extensible Messaging and Presence Protocol (XMPP) as defined 6424 by XXXX. 6425 Registrant Contact: IETF, XMPP Working Group, 6427 16.5. XML Namespace Name for Stanza Errors 6429 A URN sub-namespace for stanza error data in the Extensible Messaging 6430 and Presence Protocol (XMPP) is defined as follows. (This namespace 6431 name adheres to the format defined in [XML-REG].) 6432 URI: urn:ietf:params:xml:ns:xmpp-stanzas 6433 Specification: XXXX 6434 Description: This is the XML namespace name for stanza error data in 6435 the Extensible Messaging and Presence Protocol (XMPP) as defined 6436 by XXXX. 6437 Registrant Contact: IETF, XMPP Working Group, 6439 16.6. Nodeprep Profile of Stringprep 6441 The Nodeprep profile of stringprep is defined under Nodeprep 6442 (Appendix A). The IANA has registered Nodeprep in the stringprep 6443 profile registry. 6445 Name of this profile: 6447 Nodeprep 6449 RFC in which the profile is defined: 6451 XXXX 6453 Indicator whether or not this is the newest version of the profile: 6455 This is the first version of Nodeprep 6457 16.7. Resourceprep Profile of Stringprep 6459 The Resourceprep profile of stringprep is defined under Resourceprep 6460 (Appendix B). The IANA has registered Resourceprep in the stringprep 6461 profile registry. 6463 Name of this profile: 6465 Resourceprep 6467 RFC in which the profile is defined: 6469 XXXX 6471 Indicator whether or not this is the newest version of the profile: 6473 This is the first version of Resourceprep 6475 16.8. GSSAPI Service Name 6477 The IANA has registered "xmpp" as a GSSAPI [GSS-API] service name, as 6478 defined under Section 7.5. 6480 16.9. Port Numbers 6482 The IANA has registered "xmpp-client" and "xmpp-server" as keywords 6483 for [TCP] ports 5222 and 5269 respectively. 6485 These ports SHOULD be used for client-to-server and server-to-server 6486 communications respectively, but other ports MAY be used. 6488 17. References 6490 17.1. Normative References 6492 [ABNF] Crocker, D. and P. Overell, "Augmented BNF for Syntax 6493 Specifications: ABNF", STD 68, RFC 5234, January 2008. 6495 [BASE64] Josefsson, S., "The Base16, Base32, and Base64 Data 6496 Encodings", RFC 4648, October 2006. 6498 [CHARSET] Alvestrand, H., "IETF Policy on Character Sets and 6499 Languages", BCP 18, RFC 2277, January 1998. 6501 [DNS] Mockapetris, P., "Domain names - implementation and 6502 specification", STD 13, RFC 1035, November 1987. 6504 [DNS-SRV] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for 6505 specifying the location of services (DNS SRV)", RFC 2782, 6506 February 2000. 6508 [IDNA] Faltstrom, P., Hoffman, P., and A. Costello, 6509 "Internationalizing Domain Names in Applications (IDNA)", 6510 RFC 3490, March 2003. 6512 [LANGTAGS] 6513 Phillips, A. and M. Davis, "Tags for Identifying 6514 Languages", BCP 47, RFC 4646, September 2006. 6516 [NAMEPREP] 6517 Hoffman, P. and M. Blanchet, "Nameprep: A Stringprep 6518 Profile for Internationalized Domain Names (IDN)", 6519 RFC 3491, March 2003. 6521 [PLAIN] Zeilenga, K., "The PLAIN Simple Authentication and 6522 Security Layer (SASL) Mechanism", RFC 4616, August 2006. 6524 [RANDOM] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 6525 Requirements for Security", BCP 106, RFC 4086, June 2005. 6527 [SASL] Melnikov, A. and K. Zeilenga, "Simple Authentication and 6528 Security Layer (SASL)", RFC 4422, June 2006. 6530 [STRINGPREP] 6531 Hoffman, P. and M. Blanchet, "Preparation of 6532 Internationalized Strings ("stringprep")", RFC 3454, 6533 December 2002. 6535 [TCP] Postel, J., "Transmission Control Protocol", STD 7, 6536 RFC 793, September 1981. 6538 [TERMS] Bradner, S., "Key words for use in RFCs to Indicate 6539 Requirement Levels", BCP 14, RFC 2119, March 1997. 6541 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 6542 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 6544 [UCS2] International Organization for Standardization, 6545 "Information Technology - Universal Multiple-octet coded 6546 Character Set (UCS) - Amendment 2: UCS Transformation 6547 Format 8 (UTF-8)", ISO Standard 10646-1 Addendum 2, 6548 October 1996. 6550 [UNICODE] The Unicode Consortium, "The Unicode Standard, Version 6551 3.2.0", 2000. 6553 The Unicode Standard, Version 3.2.0 is defined by The 6554 Unicode Standard, Version 3.0 (Reading, MA, Addison- 6555 Wesley, 2000. ISBN 0-201-61633-5), as amended by the 6556 Unicode Standard Annex #27: Unicode 3.1 6557 (http://www.unicode.org/reports/tr27/) and by the Unicode 6558 Standard Annex #28: Unicode 3.2 6559 (http://www.unicode.org/reports/tr28/). 6561 [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 6562 10646", STD 63, RFC 3629, November 2003. 6564 [UUID] Leach, P., Mealling, M., and R. Salz, "A Universally 6565 Unique IDentifier (UUID) URN Namespace", RFC 4122, 6566 July 2005. 6568 [URI] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 6569 Resource Identifier (URI): Generic Syntax", STD 66, 6570 RFC 3986, January 2005. 6572 [X509] Housley, R., Polk, W., Ford, W., and D. Solo, "Internet 6573 X.509 Public Key Infrastructure Certificate and 6574 Certificate Revocation List (CRL) Profile", RFC 3280, 6575 April 2002. 6577 [X509-SRV] 6578 Santesson, S., "Internet X.509 Public Key Infrastructure 6579 Subject Alternative Name for Expression of Service Name", 6580 RFC 4985, August 2007. 6582 [XML] Paoli, J., Maler, E., Sperberg-McQueen, C., Yergeau, F., 6583 and T. Bray, "Extensible Markup Language (XML) 1.0 (Fourth 6584 Edition)", World Wide Web Consortium Recommendation REC- 6585 xml-20060816, August 2006, 6586 . 6588 [XML-NAMES] 6589 Layman, A., Hollander, D., Tobin, R., and T. Bray, 6590 "Namespaces in XML 1.1 (Second Edition)", World Wide Web 6591 Consortium Recommendation REC-xml-names11-20060816, 6592 August 2006, . 6594 17.2. Informative References 6596 [ACAP] Newman, C. and J. Myers, "ACAP -- Application 6597 Configuration Access Protocol", RFC 2244, November 1997. 6599 [ANONYMOUS] 6600 Zeilenga, K., "Anonymous Simple Authentication and 6601 Security Layer (SASL) Mechanism", RFC 4505, June 2006. 6603 [ASN.1] CCITT, "Recommendation X.208: Specification of Abstract 6604 Syntax Notation One (ASN.1)", 1988. 6606 [CHANNEL] Williams, N., "On the Use of Channel Bindings to Secure 6607 Channels", RFC 5056, November 2007. 6609 [DIGEST-MD5] 6610 Leach, P. and C. Newman, "Using Digest Authentication as a 6611 SASL Mechanism", RFC 2831, May 2000. 6613 [DNSSEC] Arends, R., Austein, R., Larson, M., Massey, D., and S. 6614 Rose, "DNS Security Introduction and Requirements", 6615 RFC 4033, March 2005. 6617 [DNS-TXT] Rosenbaum, R., "Using the Domain Name System To Store 6618 Arbitrary String Attributes", RFC 1464, May 1993. 6620 [DOS] Handley, M., Rescorla, E., and IAB, "Internet Denial-of- 6621 Service Considerations", RFC 4732, December 2006. 6623 [GSS-API] Linn, J., "Generic Security Service Application Program 6624 Interface Version 2, Update 1", RFC 2743, January 2000. 6626 [HTTP] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 6627 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 6628 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 6630 [IMAP] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 6631 4rev1", RFC 3501, March 2003. 6633 [IMP-REQS] 6634 Day, M., Aggarwal, S., and J. Vincent, "Instant Messaging 6635 / Presence Protocol Requirements", RFC 2779, 6636 February 2000. 6638 [IRI] Duerst, M. and M. Suignard, "Internationalized Resource 6639 Identifiers (IRIs)", RFC 3987, January 2005. 6641 [LINKLOCAL] 6642 Cheshire, S., Aboba, B., and E. Guttman, "Dynamic 6643 Configuration of IPv4 Link-Local Addresses", RFC 3927, 6644 May 2005. 6646 [MAILBOXES] 6647 Crocker, D., "MAILBOX NAMES FOR COMMON SERVICES, ROLES AND 6648 FUNCTIONS", RFC 2142, May 1997. 6650 [POP3] Myers, J. and M. Rose, "Post Office Protocol - Version 3", 6651 STD 53, RFC 1939, May 1996. 6653 [PUNYCODE] 6654 Costello, A., "Punycode: A Bootstring encoding of Unicode 6655 for Internationalized Domain Names in Applications 6656 (IDNA)", RFC 3492, March 2003. 6658 [RFC3920] Saint-Andre, P., Ed., "Extensible Messaging and Presence 6659 Protocol (XMPP): Core", RFC 3920, October 2004. 6661 [RFC3921] Saint-Andre, P., Ed., "Extensible Messaging and Presence 6662 Protocol (XMPP): Instant Messaging and Presence", 6663 RFC 3921, October 2004. 6665 [rfc3921bis] 6666 Saint-Andre, P., "Extensible Messaging and Presence 6667 Protocol (XMPP): Instant Messaging and Presence", 6668 draft-saintandre-rfc3921bis-08 (work in progress), 6669 March 2009. 6671 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 2821, 6672 April 2001. 6674 [URN-OID] Mealling, M., "A URN Namespace of Object Identifiers", 6675 RFC 3061, February 2001. 6677 [USINGTLS] 6678 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 6679 RFC 2595, June 1999. 6681 [XEP-0001] 6682 Saint-Andre, P., "XMPP Extension Protocols", XSF XEP 0001, 6683 January 2008. 6685 [XEP-0045] 6686 Saint-Andre, P., "Multi-User Chat", XSF XEP 0045, 6687 July 2007. 6689 [XEP-0060] 6690 Millard, P., Saint-Andre, P., and R. Meijer, "Publish- 6691 Subscribe", XSF XEP 0060, September 2007. 6693 [XEP-0071] 6694 Saint-Andre, P., "XHTML-IM", XSF XEP 0071, September 2007. 6696 [XEP-0077] 6697 Saint-Andre, P., "In-Band Registration", XSF XEP 0077, 6698 January 2006. 6700 [XEP-0124] 6701 Paterson, I., Smith, D., and P. Saint-Andre, 6702 "Bidirectional-streams Over Synchronous HTTP (BOSH)", XSF 6703 XEP 0124, February 2007. 6705 [XEP-0156] 6706 Hildebrand, J. and P. Saint-Andre, "Discovering 6707 Alternative XMPP Connection Methods", XSF XEP 0156, 6708 June 2007. 6710 [XEP-0165] 6711 Saint-Andre, P., "Best Practices to Prevent JID 6712 Mimicking", XSF XEP 0165, July 2007. 6714 [XEP-0174] 6715 Saint-Andre, P., "Link-Local Messaging", XSF XEP 0174, 6716 September 2007. 6718 [XEP-0175] 6719 Saint-Andre, P., "Best Practices for Use of SASL 6720 ANONYMOUS", XSF XEP 0175, September 2006. 6722 [XEP-0178] 6723 Saint-Andre, P. and P. Millard, "Best Practices for Use of 6724 SASL EXTERNAL with Certificates", XSF XEP 0178, 6725 February 2007. 6727 [XEP-0205] 6728 Saint-Andre, P., "Best Practices to Discourage Denial of 6729 Service Attacks", XSF XEP 0205, July 2007. 6731 [XEP-0206] 6732 Paterson, I., "XMPP Over BOSH", XSF XEP 0206, June 2007. 6734 [XEP-0220] 6735 Saint-Andre, P. and J. Miller, "Server Dialback", XSF 6736 XEP 0220, October 2008. 6738 [XEP-0246] 6739 Saint-Andre, P., "End-to-End XML Streams", XSF XEP 0246, 6740 June 2008. 6742 [XML-FRAG] 6743 Grosso, P. and D. Veillard, "XML Fragment Interchange", 6744 World Wide Web Consortium CR CR-xml-fragment-20010212, 6745 February 2001, 6746 . 6748 [XML-REG] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, 6749 January 2004. 6751 [XML-SCHEMA] 6752 Thompson, H., Maloney, M., Mendelsohn, N., and D. Beech, 6753 "XML Schema Part 1: Structures Second Edition", World Wide 6754 Web Consortium Recommendation REC-xmlschema-1-20041028, 6755 October 2004, 6756 . 6758 [XMPP-URI] 6759 Saint-Andre, P., "Internationalized Resource Identifiers 6760 (IRIs) and Uniform Resource Identifiers (URIs) for the 6761 Extensible Messaging and Presence Protocol (XMPP)", 6762 RFC 5122, February 2008. 6764 Appendix A. Nodeprep 6766 A.1. Introduction 6768 This appendix defines the "Nodeprep" profile of stringprep. As such, 6769 it specifies processing rules that will enable users to enter 6770 internationalized node identifiers in the Extensible Messaging and 6771 Presence Protocol (XMPP) and have the highest chance of getting the 6772 content of the strings correct. (An XMPP node identifier is the 6773 optional portion of an XMPP address that precedes an XMPP domain 6774 identifier and the '@' separator; it is often but not exclusively 6775 associated with an instant messaging username.) These processing 6776 rules are intended only for XMPP node identifiers and are not 6777 intended for arbitrary text or any other aspect of an XMPP address. 6779 This profile defines the following, as required by [STRINGPREP]: 6781 o The intended applicability of the profile: internationalized node 6782 identifiers within XMPP 6783 o The character repertoire that is the input and output to 6784 stringprep: Unicode 3.2, specified in Section 2 of this Appendix 6785 o The mappings used: specified in Section 3 6786 o The Unicode normalization used: specified in Section 4 6787 o The characters that are prohibited as output: specified in Section 6788 5 6789 o Bidirectional character handling: specified in Section 6 6791 A.2. Character Repertoire 6793 This profile uses Unicode 3.2 with the list of unassigned code points 6794 being Table A.1, both defined in Appendix A of [STRINGPREP]. 6796 A.3. Mapping 6798 This profile specifies mapping using the following tables from 6799 [STRINGPREP]: 6801 Table B.1 6802 Table B.2 6804 A.4. Normalization 6806 This profile specifies the use of Unicode normalization form KC, as 6807 described in [STRINGPREP]. 6809 A.5. Prohibited Output 6811 This profile specifies the prohibition of using the following tables 6812 from [STRINGPREP]. 6814 Table C.1.1 6815 Table C.1.2 6816 Table C.2.1 6817 Table C.2.2 6818 Table C.3 6819 Table C.4 6820 Table C.5 6821 Table C.6 6822 Table C.7 6823 Table C.8 6824 Table C.9 6826 In addition, the following additional Unicode characters are also 6827 prohibited: 6829 U+0022 (QUOTATION MARK), i.e., " 6830 U+0026 (AMPERSAND), i.e., & 6831 U+0027 (APOSTROPHE), i.e., ' 6832 U+002F (SOLIDUS), i.e., / 6833 U+003A (COLON), i.e., : 6834 U+003C (LESS-THAN SIGN), i.e., < 6835 U+003E (GREATER-THAN SIGN), i.e., > 6836 U+0040 (COMMERCIAL AT), i.e., @ 6838 A.6. Bidirectional Characters 6840 This profile specifies checking bidirectional strings, as described 6841 in Section 6 of [STRINGPREP]. 6843 A.7. Notes 6845 Because the additional characters prohibited by Nodeprep are 6846 prohibited after normalization, an implementation MUST NOT enable a 6847 human user to input any Unicode code point whose decomposition 6848 includes those characters; such code points include but are not 6849 necessarily limited to the following (refer to [UNICODE] for complete 6850 information). 6852 o U+2100 (ACCOUNT OF) 6853 o U+2101 (ADDRESSED TO THE SUBJECT) 6854 o U+2105 (CARE OF) 6855 o U+2106 (CADA UNA) 6856 o U+226E (NOT LESS-THAN) 6857 o U+226F (NOT GREATER-THAN) 6858 o U+2A74 (DOUBLE COLON EQUAL) 6859 o U+FE13 (SMALL COLON) 6860 o U+FE60 (SMALL AMPERSAND) 6861 o U+FE64 (SMALL LESS-THAN SIGN) 6862 o U+FE65 (SMALL GREATER-THAN SIGN) 6863 o U+FE6B (SMALL COMMERCIAL AT) 6864 o U+FF02 (FULLWIDTH QUOTATION MARK) 6865 o U+FF06 (FULLWIDTH AMPERSAND) 6866 o U+FF07 (FULLWIDTH APOSTROPHE) 6867 o U+FF0F (FULLWIDTH SOLIDUS) 6868 o U+FF1A (FULLWIDTH COLON) 6869 o U+FF1C (FULLWIDTH LESS-THAN SIGN) 6870 o U+FF1E (FULLWIDTH GREATER-THAN SIGN) 6871 o U+FF20 (FULLWIDTH COMMERCIAL AT) 6873 Appendix B. Resourceprep 6875 B.1. Introduction 6877 This appendix defines the "Resourceprep" profile of stringprep. As 6878 such, it specifies processing rules that will enable users to enter 6879 internationalized resource identifiers in the Extensible Messaging 6880 and Presence Protocol (XMPP) and have the highest chance of getting 6881 the content of the strings correct. (An XMPP resource identifier is 6882 the optional portion of an XMPP address that follows an XMPP domain 6883 identifier and the '/' separator.) These processing rules are 6884 intended only for XMPP resource identifiers and are not intended for 6885 arbitrary text or any other aspect of an XMPP address. 6887 This profile defines the following, as required by [STRINGPREP]: 6889 o The intended applicability of the profile: internationalized 6890 resource identifiers within XMPP 6891 o The character repertoire that is the input and output to 6892 stringprep: Unicode 3.2, specified in Section 2 of this Appendix 6893 o The mappings used: specified in Section 3 6894 o The Unicode normalization used: specified in Section 4 6895 o The characters that are prohibited as output: specified in Section 6896 5 6897 o Bidirectional character handling: specified in Section 6 6899 B.2. Character Repertoire 6901 This profile uses Unicode 3.2 with the list of unassigned code points 6902 being Table A.1, both defined in Appendix A of [STRINGPREP]. 6904 B.3. Mapping 6906 This profile specifies mapping using the following tables from 6907 [STRINGPREP]: 6909 Table B.1 6911 B.4. Normalization 6913 This profile specifies the use of Unicode normalization form KC, as 6914 described in [STRINGPREP]. 6916 B.5. Prohibited Output 6918 This profile specifies the prohibition of using the following tables 6919 from [STRINGPREP]. 6921 Table C.1.2 6922 Table C.2.1 6923 Table C.2.2 6924 Table C.3 6925 Table C.4 6926 Table C.5 6927 Table C.6 6928 Table C.7 6929 Table C.8 6930 Table C.9 6932 B.6. Bidirectional Characters 6934 This profile specifies checking bidirectional strings, as described 6935 in Section 6 of [STRINGPREP]. 6937 Appendix C. XML Schemas 6939 Because validation of XML streams and stanzas is optional, the 6940 following XML schemas are provided for descriptive purposes only. 6941 These schemas are not normative. 6943 The following schemas formally define various XML namespaces used in 6944 the core XMPP protocols, in conformance with [XML-SCHEMA]. For 6945 schemas defining the 'jabber:client' and 'jabber:server' namespaces, 6946 refer to [rfc3921bis]. 6948 C.1. Streams Namespace 6950 6952 6958 6959 6960 6961 6962 6964 6965 6966 6968 6969 6972 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6999 7000 7001 7002 7003 7005 7006 7007 7008 7009 7012 7015 7016 7017 7019 7021 C.2. Stream Error Namespace 7023 7025 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7085 7086 7087 7088 7089 7091 7092 7093 7094 7096 7097 7098 7099 7100 7102 7104 C.3. STARTTLS Namespace 7106 7108 7114 7115 7116 7117 7118 7119 7120 7121 7123 7125 7127 7128 7129 7130 7131 7133 7135 C.4. SASL Namespace 7137 7138 7144 7145 7146 7147 7151 7152 7153 7154 7155 7158 7159 7160 7162 7164 7165 7166 7167 7168 7171 7172 7173 7174 7176 7178 7180 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7204 7205 7206 7207 7208 7209 7210 7211 7212 7214 7215 7216 7217 7218 7220 7222 C.5. Resource Binding Namespace 7224 7226 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7261 7262 7263 7264 7265 7266 7268 7269 7270 7271 7272 7273 7275 7277 C.6. Stanza Error Namespace 7279 7281 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7341 7342 7343 7344 7345 7346 7347 7348 7349 7351 7352 7353 7354 7355 7357 7359 Appendix D. Contact Addresses 7361 Consistent with [MAILBOXES], an organization that offers an XMPP 7362 service SHOULD provide an Internet mailbox of "XMPP" for inquiries 7363 related to that service, where the host portion of the resulting 7364 mailto URI MUST be the organization's domain, not the domain of the 7365 XMPP service itself (e.g., the XMPP service might be offered at 7366 im.example.com but the Internet mailbox would be ). 7368 Appendix E. Account Provisioning 7370 Account provisioning is out of scope for this specification. 7371 Possible methods for account provisioning include account creation by 7372 a server administrator and in-band account registration using the 7373 'jabber:iq:register' namespace as documented in [XEP-0077]. 7375 Appendix F. Differences From RFC 3920 7377 Based on consensus derived from implementation and deployment 7378 experience as well as formal interoperability testing, the following 7379 substantive modifications were made from RFC 3920. 7381 o Corrected the ABNF syntax for JIDs to prevent zero-length node 7382 identifiers, domain identifiers, and resource identifiers. 7383 o Corrected the nameprep processing rules to require use of the 7384 UseSTD3ASCIIRules flag. 7385 o Recommended or mandated use of the 'from' and 'to' attributes on 7386 stream headers. 7387 o More fully specified stream closing handshake. 7388 o Specified recommended stream reconnection algorithm. 7389 o Specified return of stream error in response to 7390 receipt of prohibited XML features. 7391 o Specified that TLS plus SASL PLAIN is a mandatory-to-implement 7392 technology for client-to-server connections, since implementation 7393 of SASL EXTERNAL is uncommon in XMPP clients, in part because 7394 underlying security features such as end-user X.509 certificates 7395 are not yet widely deployed. 7396 o Added the , , 7397 , , and SASL error conditions to handle error flows mistakenly 7399 left out of RFC 3920 or discussed in RFC 4422 but not in RFC 2222. 7400 o More fully specified binding of multiple resources to the same 7401 stream. 7402 o Added the stanza error condition to provide 7403 appropriate handling of stanzas when multiple resources are bound 7404 to the same stream. 7405 o Added the stanza error condition to enable 7406 potential ETags usage. 7407 o Removed unnecessary requirement for escaping of characters that 7408 map to certain predefined entities, which do not need to be 7409 escaped in XML. 7410 o Clarified process of DNS SRV lookups and fallbacks. 7411 o Clarified handling of SASL security layers. 7412 o Clarified handling of stream features, regularized use of the 7413 child element, and defined use of the 7414 child element. 7415 o Clarified handling of data that violates the well-formedness 7416 definitions for XML 1.0 and XML namespaces. 7417 o Specified security considerations in more detail, especially with 7418 regard to presence leaks and denial of service attacks. 7419 o Moved historical documentation of the server dialback protocol 7420 from this specification to a separate specification maintained by 7421 the XMPP Standards Foundation. 7423 In addition, numerous changes of an editorial nature were made in 7424 order to more fully specify and clearly explain XMPP. 7426 Appendix G. Copying Conditions 7428 Regarding this entire document or any portion of it, the author makes 7429 no guarantees and is not responsible for any damage resulting from 7430 its use. The author grants irrevocable permission to anyone to use, 7431 modify, and distribute it in any way that does not diminish the 7432 rights of anyone else to use, modify, and distribute it, provided 7433 that redistributed derivative works do not contain misleading author 7434 or version information. Derivative works need not be licensed under 7435 similar terms. 7437 Index 7439 B 7440 Bare JID 17 7442 C 7443 Connected Resource 74 7445 D 7446 Domain Identifier 15 7448 E 7449 Entity 14 7450 Error Stanza 89 7451 Extended Content 104 7453 F 7454 Full JID 17 7456 I 7457 Initial Stream 22 7458 IQ Stanza 87 7460 J 7461 Jabber Identifier 14 7463 M 7464 Message Stanza 87 7466 N 7467 Node Identifier 16 7469 P 7470 Presence Stanza 87 7472 R 7473 Resource Identifier 17 7474 Response Stream 22 7476 S 7477 Stream ID 27 7479 W 7480 Whitespace Ping 34 7482 X 7483 XML Stanza 22 7484 XML Stream 21 7486 Author's Address 7488 Peter Saint-Andre 7489 Cisco 7491 Email: psaintan@cisco.com