idnits 2.17.1 draft-ietf-xmpp-3920bis-00.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.i 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 6888 has weird spacing: '...equence xmlns...' == Line 6889 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 date (June 1, 2009) is 5443 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 482 -- Looks like a reference, but probably isn't: '1' on line 1051 ** 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' -- 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: 7 errors (**), 0 flaws (~~), 4 warnings (==), 14 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) June 1, 2009 5 Intended status: Standards Track 6 Expires: December 3, 2009 8 Extensible Messaging and Presence Protocol (XMPP): Core 9 draft-ietf-xmpp-3920bis-00 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 December 3, 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 . . . . . . . . . . . . . . . . . . . . . . 21 88 4.6. Other Bindings . . . . . . . . . . . . . . . . . . . . . 21 89 5. XML Streams . . . . . . . . . . . . . . . . . . . . . . . . . 21 90 5.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 21 91 5.2. Stream Security . . . . . . . . . . . . . . . . . . . . 24 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 . . . . . . . . . . . . . . . . . . . . . . 28 97 5.3.5. version . . . . . . . . . . . . . . . . . . . . . . 29 98 5.3.6. Summary of Stream Attributes . . . . . . . . . . . . 30 99 5.4. Namespace Declarations . . . . . . . . . . . . . . . . . 31 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 . . . . . . . . . . . . . . . . . 34 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 . . . . . . 36 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 . . . . . . . . . . . 76 191 8.4. Server-Generated Resource Identifier . . . . . . . . . . 76 192 8.4.1. Success Case . . . . . . . . . . . . . . . . . . . . 76 193 8.4.2. Error Cases . . . . . . . . . . . . . . . . . . . . 77 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 9. XML Stanzas . . . . . . . . . . . . . . . . . . . . . . . . . 80 203 9.1. Common Attributes . . . . . . . . . . . . . . . . . . . 80 204 9.1.1. to . . . . . . . . . . . . . . . . . . . . . . . . . 80 205 9.1.1.1. Client-to-Server Streams . . . . . . . . . . . . 80 206 9.1.1.2. Server-to-Server Streams . . . . . . . . . . . . 81 207 9.1.2. from . . . . . . . . . . . . . . . . . . . . . . . . 81 208 9.1.2.1. Client-to-Server Streams . . . . . . . . . . . . 81 209 9.1.2.2. Server-to-Server Streams . . . . . . . . . . . . 82 210 9.1.3. id . . . . . . . . . . . . . . . . . . . . . . . . . 82 211 9.1.4. type . . . . . . . . . . . . . . . . . . . . . . . . 83 212 9.1.5. xml:lang . . . . . . . . . . . . . . . . . . . . . . 83 213 9.2. Basic Semantics . . . . . . . . . . . . . . . . . . . . 84 214 9.2.1. Message Semantics . . . . . . . . . . . . . . . . . 84 215 9.2.2. Presence Semantics . . . . . . . . . . . . . . . . . 84 216 9.2.3. IQ Semantics . . . . . . . . . . . . . . . . . . . . 85 217 9.3. Stanza Errors . . . . . . . . . . . . . . . . . . . . . 86 218 9.3.1. Rules . . . . . . . . . . . . . . . . . . . . . . . 86 219 9.3.2. Syntax . . . . . . . . . . . . . . . . . . . . . . . 87 220 9.3.3. Defined Conditions . . . . . . . . . . . . . . . . . 88 221 9.3.3.1. bad-request . . . . . . . . . . . . . . . . . . . 88 222 9.3.3.2. conflict . . . . . . . . . . . . . . . . . . . . 88 223 9.3.3.3. feature-not-implemented . . . . . . . . . . . . . 89 224 9.3.3.4. forbidden . . . . . . . . . . . . . . . . . . . . 89 225 9.3.3.5. gone . . . . . . . . . . . . . . . . . . . . . . 90 226 9.3.3.6. internal-server-error . . . . . . . . . . . . . . 90 227 9.3.3.7. item-not-found . . . . . . . . . . . . . . . . . 91 228 9.3.3.8. jid-malformed . . . . . . . . . . . . . . . . . . 91 229 9.3.3.9. not-acceptable . . . . . . . . . . . . . . . . . 92 230 9.3.3.10. not-allowed . . . . . . . . . . . . . . . . . . . 92 231 9.3.3.11. not-authorized . . . . . . . . . . . . . . . . . 93 232 9.3.3.12. not-modified . . . . . . . . . . . . . . . . . . 93 233 9.3.3.13. payment-required . . . . . . . . . . . . . . . . 94 234 9.3.3.14. policy-violation . . . . . . . . . . . . . . . . 95 235 9.3.3.15. recipient-unavailable . . . . . . . . . . . . . . 95 236 9.3.3.16. redirect . . . . . . . . . . . . . . . . . . . . 96 237 9.3.3.17. registration-required . . . . . . . . . . . . . . 97 238 9.3.3.18. remote-server-not-found . . . . . . . . . . . . . 97 239 9.3.3.19. remote-server-timeout . . . . . . . . . . . . . . 97 240 9.3.3.20. resource-constraint . . . . . . . . . . . . . . . 98 241 9.3.3.21. service-unavailable . . . . . . . . . . . . . . . 98 242 9.3.3.22. subscription-required . . . . . . . . . . . . . . 99 243 9.3.3.23. undefined-condition . . . . . . . . . . . . . . . 99 244 9.3.3.24. unexpected-request . . . . . . . . . . . . . . . 100 245 9.3.4. Application-Specific Conditions . . . . . . . . . . 101 246 9.4. Extended Content . . . . . . . . . . . . . . . . . . . . 102 247 9.5. Stanza Size . . . . . . . . . . . . . . . . . . . . . . 103 248 10. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 103 249 10.1. Client-to-Server . . . . . . . . . . . . . . . . . . . . 103 250 10.1.1. TLS . . . . . . . . . . . . . . . . . . . . . . . . 104 251 10.1.2. SASL . . . . . . . . . . . . . . . . . . . . . . . . 105 252 10.1.3. Resource Binding . . . . . . . . . . . . . . . . . . 106 253 10.1.4. Stanza Exchange . . . . . . . . . . . . . . . . . . 107 254 10.1.5. Close . . . . . . . . . . . . . . . . . . . . . . . 108 255 10.2. Server-to-Server Examples . . . . . . . . . . . . . . . 108 256 10.2.1. TLS . . . . . . . . . . . . . . . . . . . . . . . . 108 257 10.2.2. SASL . . . . . . . . . . . . . . . . . . . . . . . . 110 258 10.2.3. Stanza Exchange . . . . . . . . . . . . . . . . . . 111 259 10.2.4. Close . . . . . . . . . . . . . . . . . . . . . . . 112 260 11. Server Rules for Processing XML Stanzas . . . . . . . . . . . 112 261 11.1. No 'to' Address . . . . . . . . . . . . . . . . . . . . 112 262 11.1.1. Overview . . . . . . . . . . . . . . . . . . . . . . 112 263 11.1.2. Message . . . . . . . . . . . . . . . . . . . . . . 113 264 11.1.3. Presence . . . . . . . . . . . . . . . . . . . . . . 113 265 11.1.4. IQ . . . . . . . . . . . . . . . . . . . . . . . . . 113 266 11.2. Local Domain . . . . . . . . . . . . . . . . . . . . . . 113 267 11.2.1. Mere Domain . . . . . . . . . . . . . . . . . . . . 114 268 11.2.2. Domain with Resource . . . . . . . . . . . . . . . . 114 269 11.2.3. Node at Domain . . . . . . . . . . . . . . . . . . . 114 270 11.2.3.1. No Such User . . . . . . . . . . . . . . . . . . 114 271 11.2.3.2. Bare JID . . . . . . . . . . . . . . . . . . . . 114 272 11.2.3.3. Full JID . . . . . . . . . . . . . . . . . . . . 115 273 11.3. Foreign Domain . . . . . . . . . . . . . . . . . . . . . 115 274 11.3.1. Existing Stream . . . . . . . . . . . . . . . . . . 115 275 11.3.2. No Existing Stream . . . . . . . . . . . . . . . . . 115 276 11.3.3. Error Handling . . . . . . . . . . . . . . . . . . . 116 277 12. XML Usage . . . . . . . . . . . . . . . . . . . . . . . . . . 116 278 12.1. Restrictions . . . . . . . . . . . . . . . . . . . . . . 116 279 12.2. XML Namespace Names and Prefixes . . . . . . . . . . . . 117 280 12.2.1. Streams Namespace . . . . . . . . . . . . . . . . . 117 281 12.2.2. Default Namespace . . . . . . . . . . . . . . . . . 117 282 12.2.3. Extended Namespaces . . . . . . . . . . . . . . . . 118 283 12.3. Well-Formedness . . . . . . . . . . . . . . . . . . . . 119 284 12.4. Validation . . . . . . . . . . . . . . . . . . . . . . . 120 285 12.5. Inclusion of Text Declaration . . . . . . . . . . . . . 120 286 12.6. Character Encoding . . . . . . . . . . . . . . . . . . . 120 287 12.7. Whitespace . . . . . . . . . . . . . . . . . . . . . . . 121 288 12.8. XML Versions . . . . . . . . . . . . . . . . . . . . . . 121 289 13. Compliance Requirements . . . . . . . . . . . . . . . . . . . 121 290 13.1. Servers . . . . . . . . . . . . . . . . . . . . . . . . 122 291 13.2. Clients . . . . . . . . . . . . . . . . . . . . . . . . 122 292 14. Internationalization Considerations . . . . . . . . . . . . . 122 293 15. Security Considerations . . . . . . . . . . . . . . . . . . . 123 294 15.1. High Security . . . . . . . . . . . . . . . . . . . . . 123 295 15.2. Certificates . . . . . . . . . . . . . . . . . . . . . . 123 296 15.2.1. Certificate Generation . . . . . . . . . . . . . . . 124 297 15.2.1.1. Server Certificates . . . . . . . . . . . . . . . 124 298 15.2.1.2. Client Certificates . . . . . . . . . . . . . . . 126 299 15.2.1.3. ASN.1 Object Identifier . . . . . . . . . . . . . 126 300 15.2.2. Certificate Validation . . . . . . . . . . . . . . . 127 301 15.2.2.1. Server-to-Server Streams . . . . . . . . . . . . 127 302 15.2.2.2. Client-to-Server Streams . . . . . . . . . . . . 129 303 15.2.2.3. Use of Certificates in XMPP Extensions . . . . . 130 304 15.3. Client-to-Server Communication . . . . . . . . . . . . . 130 305 15.4. Server-to-Server Communication . . . . . . . . . . . . . 130 306 15.5. Order of Layers . . . . . . . . . . . . . . . . . . . . 131 307 15.6. Mandatory-to-Implement Technologies . . . . . . . . . . 131 308 15.7. SASL Downgrade Attacks . . . . . . . . . . . . . . . . . 132 309 15.8. Lack of SASL Channel Binding to TLS . . . . . . . . . . 132 310 15.9. Use of base64 in SASL . . . . . . . . . . . . . . . . . 132 311 15.10. Stringprep Profiles . . . . . . . . . . . . . . . . . . 133 312 15.11. Address Spoofing . . . . . . . . . . . . . . . . . . . . 134 313 15.11.1. Address Forging . . . . . . . . . . . . . . . . . . 134 314 15.11.2. Address Mimicking . . . . . . . . . . . . . . . . . 134 315 15.12. Firewalls . . . . . . . . . . . . . . . . . . . . . . . 135 316 15.13. Denial of Service . . . . . . . . . . . . . . . . . . . 135 317 15.14. Presence Leaks . . . . . . . . . . . . . . . . . . . . . 137 318 15.15. Directory Harvesting . . . . . . . . . . . . . . . . . . 137 319 16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 137 320 16.1. XML Namespace Name for TLS Data . . . . . . . . . . . . 138 321 16.2. XML Namespace Name for SASL Data . . . . . . . . . . . . 138 322 16.3. XML Namespace Name for Stream Errors . . . . . . . . . . 138 323 16.4. XML Namespace Name for Resource Binding . . . . . . . . 138 324 16.5. XML Namespace Name for Stanza Errors . . . . . . . . . . 139 325 16.6. Nodeprep Profile of Stringprep . . . . . . . . . . . . . 139 326 16.7. Resourceprep Profile of Stringprep . . . . . . . . . . . 139 327 16.8. GSSAPI Service Name . . . . . . . . . . . . . . . . . . 140 328 16.9. Port Numbers . . . . . . . . . . . . . . . . . . . . . . 140 329 17. References . . . . . . . . . . . . . . . . . . . . . . . . . 140 330 17.1. Normative References . . . . . . . . . . . . . . . . . . 140 331 17.2. Informative References . . . . . . . . . . . . . . . . . 142 332 Appendix A. Nodeprep . . . . . . . . . . . . . . . . . . . . . . 146 333 A.1. Introduction . . . . . . . . . . . . . . . . . . . . . . 146 334 A.2. Character Repertoire . . . . . . . . . . . . . . . . . . 146 335 A.3. Mapping . . . . . . . . . . . . . . . . . . . . . . . . 146 336 A.4. Normalization . . . . . . . . . . . . . . . . . . . . . 147 337 A.5. Prohibited Output . . . . . . . . . . . . . . . . . . . 147 338 A.6. Bidirectional Characters . . . . . . . . . . . . . . . . 147 339 A.7. Notes . . . . . . . . . . . . . . . . . . . . . . . . . 147 340 Appendix B. Resourceprep . . . . . . . . . . . . . . . . . . . . 148 341 B.1. Introduction . . . . . . . . . . . . . . . . . . . . . . 148 342 B.2. Character Repertoire . . . . . . . . . . . . . . . . . . 149 343 B.3. Mapping . . . . . . . . . . . . . . . . . . . . . . . . 149 344 B.4. Normalization . . . . . . . . . . . . . . . . . . . . . 149 345 B.5. Prohibited Output . . . . . . . . . . . . . . . . . . . 149 346 B.6. Bidirectional Characters . . . . . . . . . . . . . . . . 149 347 Appendix C. XML Schemas . . . . . . . . . . . . . . . . . . . . 149 348 C.1. Streams Namespace . . . . . . . . . . . . . . . . . . . 150 349 C.2. Stream Error Namespace . . . . . . . . . . . . . . . . . 151 350 C.3. STARTTLS Namespace . . . . . . . . . . . . . . . . . . . 153 351 C.4. SASL Namespace . . . . . . . . . . . . . . . . . . . . . 154 352 C.5. Resource Binding Namespace . . . . . . . . . . . . . . . 156 353 C.6. Stanza Error Namespace . . . . . . . . . . . . . . . . . 156 354 Appendix D. Contact Addresses . . . . . . . . . . . . . . . . . 158 355 Appendix E. Account Provisioning . . . . . . . . . . . . . . . . 158 356 Appendix F. Differences From RFC 3920 . . . . . . . . . . . . . 159 357 Appendix G. Copying Conditions . . . . . . . . . . . . . . . . . 160 358 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 359 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 161 361 1. Introduction 363 1.1. Overview 365 The Extensible Messaging and Presence Protocol (XMPP) is an 366 application profile of the Extensible Markup Language [XML] for 367 streaming XML data in close to real time between any two (or more) 368 network-aware entities. XMPP is typically used to exchange messages, 369 share presence information, and engage in structured request-response 370 interactions. The basic syntax and semantics of XMPP were developed 371 originally within the Jabber open-source community, mainly in 1999. 372 In late 2002, the XMPP Working Group was chartered with developing an 373 adaptation of the core Jabber protocol that would be suitable as an 374 IETF instant messaging (IM) and presence technology. As a result of 375 work by the XMPP WG, [RFC3920] and [RFC3921] were published in 376 October 2004, representing the most complete definition of XMPP at 377 that time. 379 As a result of extensive implementation and deployment experience 380 with XMPP since 2004, as well as more formal interoperability testing 381 carried out under the auspices of the XMPP Standards Foundation 382 (XSF), this document reflects consensus from the XMPP developer 383 community regarding XMPP's core XML streaming technology. In 384 particular, this document incorporates the following backward- 385 compatible changes from RFC 3920: 387 o Incorporated corrections and errata 388 o Added examples throughout 389 o Clarified and more completely specified matters that were 390 underspecified 391 o Modified text to reflect updated technologies for which XMPP is a 392 using protocol, e.g., Transport Layer Security (TLS) and the 393 Simple Authentication and Security Layer (SASL) 394 o Defined several additional stream, stanza, and SASL error 395 conditions 396 o Removed the deprecated DIGEST-MD5 SASL mechanism [DIGEST-MD5] as a 397 mandatory-to-implement technology 398 o Added the TLS plus the SASL PLAIN mechanism [PLAIN] as a 399 mandatory-to-implement technology 400 o Defined of optional support for multiple resources over the same 401 connection 402 o Transferred historical documentation for the server dialback 403 protocol from this specification to a separate specification 405 Therefore, this document defines the core features of XMPP 1.0, thus 406 obsoleting RFC 3920. 408 Note: [xmpp-im] defines the XMPP features needed to provide the 409 basic instant messaging and presence functionality that is 410 described in [IMP-REQS]. 412 1.2. Functional Summary 414 This non-normative section provides a developer-friendly, functional 415 summary of XMPP; refer to the sections that follow for a normative 416 definition of XMPP. 418 The purpose of XMPP is to enable the exchange of relatively small 419 pieces of structured data (called "XML stanzas") over a network 420 between any two (or more) entities. XMPP is implemented using a 421 client-server architecture, wherein a client needs to connect to a 422 server in order to gain access to the network and thus be allowed to 423 exchange XML stanzas with other entities (which can be associated 424 with other servers). The process whereby a client connects to a 425 server, exchanges XML stanzas, and ends the connection is: 427 1. Determine the hostname and port at which to connect 428 2. Open a TCP connection 429 3. Open an XML stream 430 4. Complete TLS negotiation for channel encryption (recommended) 431 5. Complete SASL negotiation for authentication 432 6. Bind a resource to the stream 433 7. Exchange an unbounded number of XML stanzas with other entities 434 on the network 435 8. Close the XML stream 436 9. Close the TCP connection 438 Within XMPP, one server can optionally connect to another server to 439 enable inter-domain or inter-server communication. For this to 440 happen, the two servers need to negotiate a connection between 441 themselves and then exchange XML stanzas; the process for doing so 442 is: 444 1. Determine the hostname and port at which to connect 445 2. Open a TCP connection 446 3. Open an XML stream 447 4. Complete TLS negotiation for channel encryption (recommended) 448 5. Complete SASL negotiation for authentication * 449 6. Exchange an unbounded number of XML stanzas both directly for the 450 servers and indirectly on behalf of entities associated with each 451 server (e.g., connected clients) 452 7. Close the XML stream 453 8. Close the TCP connection 454 * Note: Depending on local service policies, it is possible that a 455 deployed server will use the older server dialback protocol to 456 provide weak identity verification in cases where SASL negotiation 457 would not result in strong authentication (e.g., because TLS 458 negotiation was not mandated by the peer server, or because the 459 certificate presented by the peer server during TLS negotiation is 460 self-signed and thus provides only weak identity); for details, 461 see [XEP-0220]. 463 In the sections following discussion of XMPP architecture and XMPP 464 addresses, this document specifies how clients connect to servers and 465 specifies the basic semantics of XML stanzas. However, this document 466 does not define the "payloads" of the XML stanzas that might be 467 exchanged once a connection is successfully established; instead, 468 those payloads are defined by various XMPP extensions. For example, 469 [xmpp-im] defines extensions for basic instant messaging and presence 470 functionality. In addition, various specifications produced in the 471 XSF's XEP series [XEP-0001] define extensions for a wide range of 472 more advanced functionality. 474 1.3. Conventions 476 The following capitalized keywords are to be interpreted as described 477 in [TERMS]: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; 478 "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", 479 "OPTIONAL". 481 The term "whitespace" is used to refer to any character that matches 482 production [3] content of [XML], i.e., any instance of SP, HT, CR, 483 and LF. 485 Following the "XML Notation" used in [IRI] to represent characters 486 that cannot be rendered in ASCII-only documents, some examples in 487 this document use the form "&#x...." as a notational device to 488 represent Unicode characters (e.g., the string "ř" stands for 489 the Unicode character LATIN SMALL LETTER R WITH CARON). 491 In examples, lines have been wrapped for improved readability, 492 "[...]" means elision, and the following prepended strings are used 493 (these prepended strings are not to be sent over the wire): 495 o C: = a client 496 o E: = any XMPP entity 497 o I: = an initiating entity 498 o P: = a peer server 499 o R: = a receiving entity 500 o S: = a server 501 o S1: = server1 502 o S2: = server2 504 1.4. Acknowledgements 506 The editor of this document finds it impossible to appropriately 507 acknowledge the many individuals who have provided comments regarding 508 the protocols defined herein. However, thanks are due to those who 509 have who have provided implementation feedback, bug reports, requests 510 for clarification, and suggestions for improvement since the 511 publication of the RFC this document supersedes. The editor has 512 endeavored to address all such feedback, but is solely responsible 513 for any remaining errors and ambiguities. 515 1.5. Discussion Venue 517 The document editor and the broader XMPP developer community welcome 518 discussion and comments related to the topics presented in this 519 document. The preferred forum is the mailing 520 list, for which archives and subscription information are available 521 at . 523 2. Architecture 525 2.1. Overview 527 XMPP assumes a client-server architecture, wherein a client utilizing 528 XMPP accesses a server (normally over a [TCP] connection) and servers 529 can also communicate with each other over TCP connections. 531 A simplified architectural diagram for a typical deployment is shown 532 here, where the entities have the following significance: 534 o romeo@example.net -- an XMPP user. 535 o example.net -- an XMPP server. 536 o im.example.com -- an XMPP server. 537 o juliet@im.example.com -- an XMPP user. 539 example.net ---------------- im.example.com 540 | | 541 | | 542 romeo@example.net juliet@im.example.com 543 Note: Architectures that employ XML streams (Section 5) and XML 544 stanzas (Section 9) but that establish peer-to-peer connections 545 directly between clients using technologies based on [LINKLOCAL] 546 have been deployed, but such architectures are not XMPP and are 547 best described as "XMPP-like"; for details, see [XEP-0174]. In 548 addition, XML streams can be established end-to-end over any 549 reliable transport, including extensions to XMPP itself; however, 550 such methods are out of scope for this specification. 552 2.2. Server 554 A SERVER is an entity whose primary responsibilities are to: 556 o Manage XML streams (Section 5) with local clients and deliver XML 557 stanzas (Section 9) to those clients over the negotiated XML 558 streams. 559 o Subject to local service policies on server-to-server 560 communication, manage XML streams (Section 5) with foreign servers 561 and route XML stanzas (Section 9) to those servers over the 562 negotiated XML streams. 564 Depending on the application, the secondary responsibilities of an 565 XMPP server can include: 567 o Storing XML data that is used by clients (e.g., contact lists for 568 users of XMPP-based instant messaging and presence applications as 569 defined in [xmpp-im]); in this case, the relevant XML stanza is 570 handled directly by the server itself on behalf of the client and 571 is not routed to a foreign server or delivered to a local entity. 572 o Hosting local services that also use XMPP as the basis for 573 communication but that provide additional functionality beyond 574 that defined in this document or in [xmpp-im]; examples include 575 multi-user conferencing services as specified in [XEP-0045] and 576 publish-subscribe services as specified in [XEP-0060]. 578 2.3. Client 580 A CLIENT is an entity that establishes an XML stream with a server by 581 authenticating using the credentials of a local account and that then 582 completes resource binding (Section 8) in order to enable delivery of 583 XML stanzas via the server to the client. A client then uses XMPP to 584 communicate with its server, other clients, and any other accessible 585 entities on a network. Multiple clients can connect simultaneously 586 to a server on behalf of a local account, where each client is 587 differentiated by the resource identifier portion of an XMPP address 588 (e.g., vs. ), as defined under 589 Section 3 and Section 8. The RECOMMENDED port for TCP connections 590 between a client and a server is 5222, as registered with the IANA 591 (see Section 16.9). 593 2.4. Network 595 Because each server is identified by a network address and because 596 server-to-server communication is a straightforward extension of the 597 client-to-server protocol, in practice the system consists of a 598 network of servers that inter-communicate. Thus, for example, 599 is able to exchange messages, presence, and 600 other information with . This pattern is familiar 601 from messaging protocols (such as [SMTP]) that make use of network 602 addressing standards. Communication between any two servers is 603 OPTIONAL. The RECOMMENDED port for TCP connections between servers 604 is 5269, as registered with the IANA (see Section 16.9). 606 3. Addresses 608 3.1. Overview 610 An ENTITY is anything that is network-addressable and that can 611 communicate using XMPP. For historical reasons, the native address 612 of an XMPP entity is called a JABBER IDENTIFIER or JID. A valid JID 613 contains a set of ordered elements formed of an XMPP node identifier, 614 domain identifier, and resource identifier. 616 The syntax for a JID is defined as follows using the Augmented 617 Backus-Naur Form as specified in [ABNF]. 619 jid = [ node "@" ] domain [ "/" resource ] 620 node = 1*(nodepoint) 621 ; a "nodepoint" is a UTF-8 encoded Unicode code 622 ; point that satisfies the Nodeprep profile of 623 ; stringprep 624 domain = fqdn / address-literal 625 fqdn = *(ldhlabel ".") toplabel 626 ldhlabel = letdig [*61(ldh) letdig] 627 toplabel = ALPHA *61(ldh) letdig 628 letdig = ALPHA / DIGIT 629 ldh = ALPHA / DIGIT / "-" 630 address-literal = IPv4address / IPv6address 631 ; the "IPv4address" and "IPv6address" rules are 632 ; defined in RFC 3986 633 resource = 1*(resourcepoint) 634 ; a "resourcepoint" is a UTF-8 encoded Unicode 635 ; code point that satisfies the Resourceprep 636 ; profile of stringprep 638 All JIDs are based on the foregoing structure. One common use of 639 this structure is to identify a messaging and presence account, the 640 server that hosts the account, and a connected resource (e.g., a 641 specific device) in the form of . However, 642 node types other than clients are possible; for example, a specific 643 chat room offered by a multi-user conference service (see [XEP-0045]) 644 could be addressed as (where "room" is the name of the 645 chat room and "service" is the hostname of the multi-user conference 646 service) and a specific occupant of such a room could be addressed as 647 (where "nick" is the occupant's room nickname). 648 Many other JID types are possible (e.g., could be a 649 server-side script or service). 651 Each allowable portion of a JID (node identifier, domain identifier, 652 and resource identifier) MUST NOT be more than 1023 bytes in length, 653 resulting in a maximum total size (including the '@' and '/' 654 separators) of 3071 bytes. 656 Note: While the format of a JID is consistent with [URI], an 657 entity's address on an XMPP network MUST be represented as a JID 658 (without a URI scheme) and not a [URI] or [IRI] as specified in 659 [XMPP-URI]; the latter specification is provided only for 660 identification and interaction outside the context of the XMPP 661 wire protocol itself. 663 3.2. Domain Identifier 665 The DOMAIN IDENTIFIER portion of a JID is that portion after the '@' 666 character (if any) and before the '/' character (if any); it is the 667 primary identifier and is the only REQUIRED element of a JID (a mere 668 domain identifier is a valid JID). Typically a domain identifier 669 identifies the "home" server to which clients connect for XML routing 670 and data management functionality. However, it is not necessary for 671 an XMPP domain identifier to identify an entity that provides core 672 XMPP server functionality (e.g., a domain identifier can identity an 673 entity such as a multi-user conference service, a publish-subscribe 674 service, or a user directory). 676 Note: A single server can service multiple domain identifiers, 677 i.e., multiple local domains; this is typically referred to as 678 virtual hosting. 680 The domain identifier for every server or service that will 681 communicate over a network SHOULD be a fully qualified domain name 682 (see [DNS]); while the domain identifier MAY be either an Internet 683 Protocol (IPv4 or IPv6) address or a text label that is resolvable on 684 a local network (commonly called an "unqualified hostname"), it is 685 possible that domain identifiers that are IP addresses will not be 686 acceptable to other services for the sake of interdomain 687 communication. Furthermore, domain identifiers that are unqualified 688 hostnames MUST NOT be used on public networks but MAY be used on 689 private networks. 691 Note: If the domain identifier includes a final character 692 considered to be a label separator (dot) by [IDNA] or [DNS], this 693 character MUST be stripped from the domain identifier before the 694 JID of which it is a part is used for the purpose of routing an 695 XML stanza, comparing against another JID, or constructing an 696 [XMPP-URI]; in particular, the character MUST be stripped before 697 any other canonicalization steps are taken, such as application of 698 the [NAMEPREP] profile of [STRINGPREP] or completion of the 699 ToASCII operation as described in [IDNA]. 701 A domain identifier MUST be an "internationalized domain name" as 702 defined in [IDNA], that is, "a domain name in which every label is an 703 internationalized label". When preparing a text label (consisting of 704 a sequence of Unicode code points) for representation as an 705 internationalized label in the process of constructing an XMPP domain 706 identifier or comparing two XMPP domain identifiers, an application 707 MUST ensure that for each text label it is possible to apply without 708 failing the ToASCII operation specified in [IDNA] with the 709 UseSTD3ASCIIRules flag set (thus forbidding ASCII code points other 710 than letters, digits, and hyphens). If the ToASCII operation can be 711 applied without failing, then the label is an internationalized 712 label. An internationalized domain name (and therefore an XMPP 713 domain identifier) is constructed from its constituent 714 internationalized labels by following the rules specified in [IDNA]. 716 Note: The ToASCII operation includes application of the [NAMEPREP] 717 profile of [STRINGPREP] and encoding using the algorithm specified 718 in [PUNYCODE]; for details, see [IDNA]. Although the output of 719 the ToASCII operation is not used in XMPP, it MUST be possible to 720 apply that operation without failing. 722 3.3. Node Identifier 724 The NODE IDENTIFIER portion of a JID is an optional secondary 725 identifier placed before the domain identifier and separated from the 726 latter by the '@' character. Typically a node identifier uniquely 727 identifies the entity requesting and using network access provided by 728 a server (i.e., a local account), although it can also represent 729 other kinds of entities (e.g., a chat room associated with a multi- 730 user conference service). The entity represented by an XMPP node 731 identifier is addressed within the context of a specific domain. 733 A node identifier MUST NOT be zero bytes in length and, as for all 734 portions of a JID, MUST NOT be more than 1023 bytes in length. 736 A node identifier MUST be formatted such that the Nodeprep profile of 737 [STRINGPREP] can be applied without failing (see Appendix A). Before 738 comparing two node identifiers, an application MUST first ensure that 739 the Nodeprep profile has been applied to each identifier (the profile 740 need not be applied each time a comparison is made, as long as it has 741 been applied before comparison). 743 3.4. Resource Identifier 745 The RESOURCE IDENTIFIER portion of a JID is an optional tertiary 746 identifier placed after the domain identifier and separated from the 747 latter by the '/' character. A resource identifier can modify either 748 a address or a mere address. Typically a 749 resource identifier uniquely identifies a specific connection (e.g., 750 a device or location) or object (e.g., a participant in a multi-user 751 conference room) belonging to the entity associated with an XMPP node 752 identifier at a local domain. 754 When an XMPP address does not include a resource identifier (i.e., 755 when it is of the form or ), it is referred to 756 as a BARE JID. When an XMPP address includes a resource identifier 757 (i.e., when it is of the form or 758 ), is referred to as a FULL JID. 760 A resource identifier MUST NOT be zero bytes in length and, as for 761 all portions of a JID, MUST NOT be more than 1023 bytes in length. 763 A resource identifier MUST be formatted such that the Resourceprep 764 profile of [STRINGPREP] can be applied without failing (see 765 Appendix B). Before comparing two resource identifiers, an 766 application MUST first ensure that the Resourceprep profile has been 767 applied to each identifier (the profile need not be applied each time 768 a comparison is made, as long as it has been applied before 769 comparison). 771 Note: For historical reasons, the term "resource identifier" is 772 used in XMPP to refer to the optional portion of an XMPP address 773 that follows the domain identifier and the "/" separator 774 character; this use of the term "resource identifier" is not to be 775 confused with the meanings of "resource" and "identifier" provided 776 in Section 1.1 of [URI]. 778 XMPP entities SHOULD consider resource identifiers to be opaque 779 strings and SHOULD NOT impute meaning to any given resource 780 identifier. In paticular, the use of the '/' character as a 781 separator between the domain identifier and the resource identifier 782 does not imply that resource identifiers are hierarchical in the way 783 that, say, HTTP addresses are hierarchical; thus for example an XMPP 784 address of the form does not identify a 785 resource "bar" that exists below a resource "foo" in a hierarchy of 786 resources associated with the entity "node@domain". 788 3.5. Determination of Addresses 790 After the parties to an XML stream have completed the appropriate 791 aspects of stream negotiation (typically SASL negotiation (Section 7) 792 and, if appropriate, resource binding (Section 8)) the receiving 793 entity for a stream MUST determine the initiating entity's JID. 795 For server-to-server communication, the initiating server's JID MUST 796 be the authorization identity (as defined by [SASL]), either (1) as 797 directly communicated by the initiating server during SASL 798 negotiation (Section 7) or (2) as derived by the receiving server 799 from the authentication identity if no authorization identity was 800 specified during SASL negotiation (Section 7). (For information 801 about the determination of addresses in the absence of SASL 802 negotiation when the older server dialback protocol is used, see 803 [XEP-0220].) 805 For client-to-server communication, the client's bare JID 806 () MUST be the authorization identity (as defined by 807 [SASL]), either (1) as directly communicated by the client during 808 SASL negotiation (Section 7) or (2) as derived by the server from the 809 authentication identity if no authorization identity was specified 810 during SASL negotiation (Section 7). The resource identifier portion 811 of the full JID () MUST be the resource 812 identifier negotiated by the client and server during resource 813 binding (Section 8). 815 The receiving entity MUST ensure that the resulting JID (including 816 node identifier, domain identifier, resource identifier, and 817 separator characters) conforms to the rules and formats defined 818 earlier in this section; to meet this restriction, the receiving 819 entity MAY replace the JID sent by the initiating entity with the 820 canonicalized JID as determined by the receiving entity. 822 4. TCP Binding 824 4.1. Scope 826 As XMPP is defined in this specification, an initiating entity 827 (client or server) MUST open a Transmission Control Protocol [TCP] 828 connection at the receiving entity (server) before it negotiates XML 829 streams with the receiving entity. The rules specified in the 830 following sections apply to the TCP binding. 832 4.2. Hostname Resolution 834 Before opening the TCP connection, the initiating entity first MUST 835 resolve the Domain Name System (DNS) hostname associated with the 836 receiving entity and determine the appropriate TCP port for 837 communication with the receiving entity. The process is: 839 1. Attempt to resolve the hostname using (a) a [DNS-SRV] Service of 840 "xmpp-client" (for client-to-server connections) or "xmpp-server" 841 (for server-to-server connections) and (b) a Proto of "tcp", 842 resulting in resource records such as "_xmpp- 843 client._tcp.example.net." or "_xmpp-server._tcp.im.example.com.". 844 The result of the SRV lookup will be one or more combinations of 845 a port and hostname, which hostnames the initiating entity MUST 846 resolve according to returned SRV record weight (if the result of 847 the SRV lookup is a single RR with a Target of ".", i.e. the root 848 domain, the initiating entity MUST abort SRV processing but 849 SHOULD attempt a fallback resolution as described below). The 850 initiating entity uses the IP address(es) from the first 851 successfully resolved hostname (with the corresponding port 852 number returned by the SRV lookup) in order to connect to the 853 receiving entity. If the initiating entity fails to connect 854 using one of the IP addresses, the initiating entity uses the 855 next resolved IP address to connect. If the initiating entity 856 fails to connect using all resolved IP addresses, then the 857 initiating entity repeats the process of resolution and 858 connection for the next hostname returned by the SRV lookup. 859 2. If the SRV lookup aborts or fails, the fallback SHOULD be a 860 normal IPv4 or IPv6 address record resolution to determine the IP 861 address, where the port used is the "xmpp-client" port of 5222 862 for client-to-server connections or the "xmpp-server" port 5269 863 for server-to-server connections. 864 3. For client-to-server connections, the fallback MAY be a [DNS-TXT] 865 lookup for alternative connection methods, for example as 866 described in [XEP-0156]. 868 Note: If the initiating entity has been explicitly configured to 869 associate a particular hostname (and potentially port) with the 870 original hostname of the receiving entity (say, to "hardcode" an 871 association between an original hostname of example.net and a 872 configured hostname and of webcm.example.com:80), the initiating 873 entity SHALL use the configured name instead of performing the 874 foregoing resolution process on the original name. 876 Note: Many XMPP servers are implemented in such a way that they 877 can host additional services (beyond those defined in this 878 specification and [xmpp-im]) at hostnames that are subdomains of 879 the hostname of the main XMPP service (e.g., 880 conference.example.net for a [XEP-0045] service associated with 881 the example.net XMPP service) or subdomains of the first-level 882 domain of the underlying host (e.g., muc.example.com for a 883 [XEP-0045] service associated with the im.example.com XMPP 884 service). If an entity from a remote domain wishes to use such 885 additional services, it would generate an appropriate XML stanza 886 and the remote domain itself would attempt to resolve the 887 service's hostname via an SRV lookup on resource records such as 888 "_xmpp-server._tcp.conference.example.net." or "_xmpp- 889 server._tcp.muc.example.com.". Therefore if a service wishes to 890 enable entities from remote domains to access these additional 891 services, it needs to advertise the appropriate "_xmpp-server" SRV 892 records in addition to the "_xmpp-server" record for its main XMPP 893 service. 895 4.3. Client-to-Server Communication 897 Because a client is subordinate to a server and therefore a client 898 authenticates to the server but the server does not necessarily 899 authenticate to the client, it is necessary to have only one TCP 900 connection between client and server. Thus the server MUST allow the 901 client to share a single TCP connection for XML stanzas sent from 902 client to server and from server to client (i.e., the inital stream 903 and response stream as specified under Section 5). 905 4.4. Server-to-Server Communication 907 Because two servers are peers and therefore each peer MUST 908 authenticate with the other, the servers MUST use two TCP 909 connections: one for XML stanzas sent from the first server to the 910 second server and another (initiated by the second server) for XML 911 stanzas from the second server to the first server. 913 This rule applies only to XML stanzas (Section 9). Therefore during 914 STARTTLS negotiation (Section 6) and SASL negotiation (Section 7) the 915 servers would use one TCP connection, but after stream setup that TCP 916 connection would be used only for the initiating server to send XML 917 stanzas to the receiving server. In order for the receiving server 918 to send XML stanzas to the initiating server, the receiving server 919 would need to reverse the roles and negotiate an XML stream from the 920 receiving server to the initiating server. 922 4.5. Reconnection 924 It can happen that an XMPP server goes offline while servicing TCP 925 connections from local clients and from other servers. Because the 926 number of such connections can be quite large, the reconnection 927 algorithm employed by entities that seek to reconnect can have a 928 significant impact on software and network performance. The 929 following guidelines are RECOMMENDED: 931 o The time to live (TTL) specified in Domain Name System records 932 MUST be honored, even if DNS results are cached; if the TTL has 933 not expired, an entity that seeks to reconnect MUST NOT re-resolve 934 the server hostname before reconnecting. 935 o The time that expires before an entity first seeks to reconnect 936 MUST be randomized (e.g., so that all clients do not attempt to 937 reconnect exactly 30 seconds after being disconnected). 938 o If the first reconnection attempt does not succeed, an entity MUST 939 back off increasingly on the time between subsequent reconnection 940 attempts. 942 Note: Because it is possible that a disconnected entity cannot 943 determine the cause of disconnection (e.g., because there was no 944 explicit stream error) or does not require a new stream for 945 immediate communication (e.g., because the stream was idle and 946 therefore timed out), it SHOULD NOT assume that is needs to 947 reconnect immediately. 949 4.6. Other Bindings 951 There is no necessary coupling of an XML stream to a TCP connection. 952 For example, two entities could connect to each other via another 953 transport, such as [HTTP] as specified in [XEP-0124] and [XEP-0206]. 954 Although this specification neither encourages nor discourages other 955 bindings, it defines only a binding of XMPP to TCP. 957 5. XML Streams 959 5.1. Overview 961 Two fundamental concepts make possible the rapid, asynchronous 962 exchange of relatively small payloads of structured information 963 between presence-aware entities: XML streams and XML stanzas. These 964 terms are defined as follows. 966 Definition of XML Stream: An XML STREAM is a container for the 967 exchange of XML elements between any two entities over a network. 968 The start of an XML stream is denoted unambiguously by an opening 969 STREAM HEADER (i.e., an XML tag with appropriate 970 attributes and namespace declarations), while the end of the XML 971 stream is denoted unambiguously by a closing XML tag. 972 During the life of the stream, the entity that initiated it can 973 send an unbounded number of XML elements over the stream, either 974 elements used to negotiate the stream (e.g., to complete TLS 975 negotiation (Section 6) or SASL negotiation (Section 7)) or XML 976 stanzas. The INITIAL STREAM is negotiated from the initiating 977 entity (typically a client or server) to the receiving entity 978 (typically a server), and can be seen as corresponding to the 979 initiating entity's "connection" or "session" with the receiving 980 entity. The initial stream enables unidirectional communication 981 from the initiating entity to the receiving entity; in order to 982 enable information exchange from the receiving entity to the 983 initiating entity, the receiving entity MUST negotiate a stream in 984 the opposite direction (the RESPONSE STREAM). 985 Definition of XML Stanza: An XML STANZA is a discrete semantic unit 986 of structured information that is sent from one entity to another 987 over an XML stream, and is the basic unit of meaning in XMPP. An 988 XML stanza exists at the direct child level of the root 989 element; the start of any XML stanza is denoted unambiguously by 990 the element start tag at depth=1 of the XML stream (e.g., 991 ), and the end of any XML stanza is denoted 992 unambiguously by the corresponding close tag at depth=1 (e.g., 993 ). The only XML stanzas defined herein are the 994 , , and elements qualified by the 995 default namespace for the stream, as described under Section 9; 996 for example, an XML element sent for the purpose of TLS 997 negotiation (Section 6) or SASL negotiation (Section 7) is not 998 considered to be an XML stanza, nor is a stream error or a stream 999 feature. An XML stanza MAY contain child elements (with 1000 accompanying attributes, elements, and XML character data) as 1001 necessary in order to convey the desired information, which MAY be 1002 qualified by any XML namespace (see [XML-NAMES] as well as 1003 Section 9.4 herein). 1005 Consider the example of a client's connection to a server. In order 1006 to connect to a server, a client initiates an XML stream by sending a 1007 stream header to the server, optionally preceded by a text 1008 declaration specifying the XML version and the character encoding 1009 supported (see Section 12.5 and Section 12.6). Subject to local 1010 policies and service provisioning, the server then replies with a 1011 second XML stream back to the client, again optionally preceded by a 1012 text declaration. Once the client has completed SASL negotiation 1013 (Section 7) and resource binding (Section 8), the client can send an 1014 unbounded number of XML stanzas over the stream. When the client 1015 desires to close the stream, it simply sends a closing tag 1016 to the server as further described under Section 5.7. 1018 In essence, then, an XML stream acts as an envelope for all the XML 1019 stanzas sent during a connection. We can represent this in a 1020 simplistic fashion as follows. 1022 +--------------------+ 1023 | | 1024 |--------------------| 1025 | | 1026 | | 1027 | | 1028 |--------------------| 1029 | | 1030 | | 1031 | | 1032 |--------------------| 1033 | | 1034 | | 1035 | | 1036 |--------------------| 1037 | | 1038 | | 1039 | | 1040 |--------------------| 1041 | [ ... ] | 1042 |--------------------| 1043 | | 1044 +--------------------+ 1046 Note: Those who are accustomed to thinking of XML in a document- 1047 centric manner might view a client's connection to a server as 1048 consisting of two open-ended XML documents: one from the client to 1049 the server and one from the server to the client. On this 1050 analogy, the two XML streams can be considered equivalent to two 1051 "documents" (matching production [1] content of [XML]) that are 1052 built up through the accumulation of XML stanzas, the root 1053 element can be considered equivalent to the "document 1054 entity" for each "document" (as described in Section 4.8 of 1055 [XML]), and the XML stanzas sent over the streams can be 1056 considered equivalent to "fragments" of the "documents" as 1057 described in [XML-FRAG]. However, this perspective is merely an 1058 analogy; XMPP does not deal in documents and fragments but in 1059 streams and stanzas. 1061 5.2. Stream Security 1063 For the purpose of stream security, both Transport Layer Security 1064 (see Section 6) and the Simple Authentication and Security Layer (see 1065 Section 7) are mandatory to implement. Use of these technologies 1066 results in high security as described under Section 15.1. 1068 The initial stream and the response stream MUST be secured 1069 separately, although security in both directions MAY be established 1070 via mechanisms that provide mutual authentication. 1072 The initiating entity MUST NOT attempt to send XML stanzas 1073 (Section 9) over the stream before the stream has been authenticated. 1074 However, if it does attempt to do so, the receiving entity MUST NOT 1075 accept such stanzas and MUST return a stream error. 1076 This rule applies to XML stanzas only (i.e., , , 1077 and elements qualified by the default namespace) and not to XML 1078 elements used for stream negotiation (e.g., elements used to complete 1079 TLS negotiation (Section 6) or SASL negotiation (Section 7)). 1081 5.3. Stream Attributes 1083 The attributes of the root element are defined in the 1084 following sections. 1086 Note: The attributes of the root element are not 1087 prepended by a 'stream:' prefix because, as explained in 1088 [XML-NAMES], "[d]efault namespace declarations do not apply 1089 directly to attribute names; the interpretation of unprefixed 1090 attributes is determined by the element on which they appear." 1092 5.3.1. from 1094 The 'from' attribute communicates an XMPP identity of the entity 1095 sending the stream element. 1097 Note: It is possible for an entity to have more than one XMPP 1098 identity (e.g., in the case of a server that provides virtual 1099 hosting). It is also possible that an entity does not know the 1100 XMPP identity of the principal controlling the entity (e.g., 1101 because the XMPP identity is assigned at a level other than the 1102 XMPP application layer, as in the General Security Service 1103 Application Program Interface [GSS-API]). 1105 For initial stream headers in client-to-server communication, if the 1106 client knows the XMPP identity of the principal controlling the 1107 client (typically an account name of the form ), then it 1108 MAY include the 'from' attribute and set its value to that identity; 1109 if not, then it MUST NOT include the 'from' attribute. Note: 1110 Including the XMPP identity before the stream is protected via TLS 1111 can expose that identity to eavesdroppers. 1113 I: 1114 1122 For initial stream headers in server-to-server communication, a 1123 server MUST include the 'from' attribute and MUST set its value to a 1124 hostname serviced by the initiating entity. 1126 I: 1127 1135 For response stream headers in both client-to-server and server-to- 1136 server communication, the receiving entity MUST include the 'from' 1137 attribute and MUST set its value to a hostname serviced by the 1138 receiving entity (which MAY be a hostname other than that specified 1139 in the 'to' attribute of the initial stream header). 1141 R: 1142 1151 Whether or not the 'from' attribute is included, each entity MUST 1152 verify the identity of the other entity before exchanging XML stanzas 1153 with it (see Section 15.3 and Section 15.4). 1155 Note: It is possible that implementations based on an earlier 1156 revision of this specification will not include the 'from' address 1157 on stream headers; an entity SHOULD be liberal in accepting such 1158 stream headers. 1160 5.3.2. to 1162 For initial stream headers in both client-to-server and server-to- 1163 server communication, the initiating entity MUST include the 'to' 1164 attribute and MUST set its value to a hostname that the initiating 1165 entity knows or expects the receiving entity to service. 1167 I: 1168 1176 For response stream headers in client-to-server communication, if the 1177 client included a 'from' attribute in the initial stream header then 1178 the server MUST include a 'to' attribute in the response stream 1179 header and MUST set its value to the bare JID specified in the 'from' 1180 attribute of the initial stream header. If the client did not 1181 include a 'from' attribute in the initial stream header then the 1182 server MUST NOT include a 'to' attribute in the response stream 1183 header. 1185 R: 1186 1195 For response stream headers in server-to-server communication, the 1196 receiving entity MUST include a 'to' attribute in the response stream 1197 header and MUST set its value to the hostname specified in the 'from' 1198 attribute of the initial stream header. 1200 R: 1201 1210 Whether or not the 'to' attribute is included, each entity MUST 1211 verify the identity of the other entity before exchanging XML stanzas 1212 with it (see Section 15.3 and Section 15.4). 1214 Note: It is possible that implementations based on an earlier 1215 revision of this specification will not include the 'to' address 1216 on stream headers; an entity SHOULD be liberal in accepting such 1217 stream headers. 1219 5.3.3. id 1221 The 'id' attribute communicates a unique identifier for the stream. 1222 This identifier is called a STREAM ID. The stream ID MUST be 1223 generated by the receiving entity when it sends a response stream 1224 header, MUST BE unique within the receiving application (normally a 1225 server), and MUST be both unpredictable and nonrepeating because it 1226 can be security-critical (see [RANDOM] for recommendations regarding 1227 randomness for security purposes). 1229 For initial stream headers, the initiating entity MUST NOT include 1230 the 'id' attribute; however, if the 'id' attribute is included, the 1231 receiving entity MUST silently ignore it. 1233 For response stream headers, the receiving entity MUST include the 1234 'id' attribute. 1236 R: 1237 1246 5.3.4. xml:lang 1248 The 'xml:lang' attribute communicates an entity's preferred or 1249 default language for any human-readable XML character data to be sent 1250 over the stream. The syntax of this attribute is defined in Section 1251 2.12 of [XML]; in particular, the value of the 'xml:lang' attribute 1252 MUST conform to the NMTOKEN datatype (as defined in Section 2.3 of 1253 [XML]) and MUST conform to the language identifier format defined in 1254 [LANGTAGS]. 1256 For initial stream headers, the initiating entity SHOULD include the 1257 'xml:lang' attribute. 1259 I: 1260 1268 For response stream headers, the receiving entity MUST include the 1269 'xml:lang' attribute. If the initiating entity included an 'xml: 1270 lang' attribute in its initial stream header and the receiving entity 1271 supports that language in the human-readable XML character data that 1272 it generates and sends to the initiating entity (e.g., in the 1273 element for stream and stanza errors), the value of the 'xml:lang' 1274 attribute MUST be identifier for the initiating entity's preferred 1275 language; if the receiving entity supports a language that closely 1276 matches the initiating entity's preferred language (e.g., "de" 1277 instead of "de-CH"), then the value of the 'xml:lang' attribute 1278 SHOULD be the identifier for the matching language but MAY be the 1279 identifier for the default language of the receiving entity; if the 1280 receiving entity does not support the initiating entity's preferred 1281 language or a closely matching language (or the initiating entity did 1282 not include the 'xml:lang' attribute in its initial stream header), 1283 then the value of the 'xml:lang' attribute MUST be the identifier for 1284 the default language of the receiving entity. 1286 R: 1287 1296 If the initiating entity included the 'xml:lang' attribute in its 1297 initial stream header, the receiving entity SHOULD remember that 1298 value as the default xml:lang for all stanzas sent by the initiating 1299 entity. As described under Section 9.1.5, the initiating entity MAY 1300 include the 'xml:lang' attribute in any XML stanzas it sends over the 1301 stream. If the initiating entity does not include the 'xml:lang' 1302 attribute in any such stanza, the receiving entity SHOULD add the 1303 'xml:lang' attribute to the stanza, whose value MUST be the 1304 identifier for the language preferred by the initiating entity (even 1305 if the receiving entity does not support that language for human- 1306 readable XML character data it generates and sends to the initiating 1307 entity, such as in stream or stanza errors). If the initiating 1308 entity includes the 'xml:lang' attribute in any such stanza, the 1309 receiving entity MUST NOT modify or delete it. 1311 5.3.5. version 1313 The inclusion of the version attribute set to a value of at least 1314 "1.0" signals support for the stream-related protocols defined in 1315 this specification, including (TLS negotiation (Section 6), SASL 1316 negotiation (Section 7), Section 5.5, and stream errors 1317 (Section 5.8). 1319 The version of XMPP specified herein is "1.0"; in particular, XMPP 1320 1.0 encapsulates the stream-related protocols as well as the basic 1321 semantics of the three defined XML stanza types (, 1322 , and ). 1324 The numbering scheme for XMPP versions is ".". The 1325 major and minor numbers MUST be treated as separate integers and each 1326 number MAY be incremented higher than a single digit. Thus, "XMPP 1327 2.4" would be a lower version than "XMPP 2.13", which in turn would 1328 be lower than "XMPP 12.3". Leading zeros (e.g., "XMPP 6.01") MUST be 1329 ignored by recipients and MUST NOT be sent. 1331 The major version number will be incremented only if the stream and 1332 stanza formats or required actions have changed so dramatically that 1333 an older version entity would not be able to interoperate with a 1334 newer version entity if it simply ignored the elements and attributes 1335 it did not understand and took the actions specified in the older 1336 specification. 1338 The minor version number will be incremented only if significant new 1339 capabilities have been added to the core protocol (e.g., a newly 1340 defined value of the 'type' attribute for message, presence, or IQ 1341 stanzas). The minor version number MUST be ignored by an entity with 1342 a smaller minor version number, but MAY be used for informational 1343 purposes by the entity with the larger minor version number (e.g., 1344 the entity with the larger minor version number would simply note 1345 that its correspondent would not be able to understand that value of 1346 the 'type' attribute and therefore would not send it). 1348 The following rules apply to the generation and handling of the 1349 'version' attribute within stream headers: 1351 1. The initiating entity MUST set the value of the 'version' 1352 attribute in the initial stream header to the highest version 1353 number it supports (e.g., if the highest version number it 1354 supports is that defined in this specification, it MUST set the 1355 value to "1.0"). 1356 2. The receiving entity MUST set the value of the 'version' 1357 attribute in the response stream header to either the value 1358 supplied by the initiating entity or the highest version number 1359 supported by the receiving entity, whichever is lower. The 1360 receiving entity MUST perform a numeric comparison on the major 1361 and minor version numbers, not a string match on 1362 ".". 1363 3. If the version number included in the response stream header is 1364 at least one major version lower than the version number included 1365 in the initial stream header and newer version entities cannot 1366 interoperate with older version entities as described, the 1367 initiating entity SHOULD generate an 1368 stream error. 1369 4. If either entity receives a stream header with no 'version' 1370 attribute, the entity MUST consider the version supported by the 1371 other entity to be "0.9" and SHOULD NOT include a 'version' 1372 attribute in the response stream header. 1374 5.3.6. Summary of Stream Attributes 1376 The following table summarizes the attributes of the root 1377 element. 1379 +----------+--------------------------+-------------------------+ 1380 | | initiating to receiving | receiving to initiating | 1381 +----------+--------------------------+-------------------------+ 1382 | to | JID of receiver | JID of initiator | 1383 | from | JID of initiator | JID of receiver | 1384 | id | silently ignored | stream identifier | 1385 | xml:lang | default language | default language | 1386 | version | XMPP 1.0+ supported | XMPP 1.0+ supported | 1387 +----------+--------------------------+-------------------------+ 1389 5.4. Namespace Declarations 1391 The stream element MUST possess both a streams namespace declaration 1392 and a default namespace declaration (as "namespace declaration" is 1393 defined in [XML-NAMES]). For detailed information regarding the 1394 streams namespace and default namespace, see Section 12.2. 1396 5.5. Stream Features 1398 If the initiating entity includes the 'version' attribute set to a 1399 value of at least "1.0" in the initial stream header, after sending 1400 the response stream header the receiving entity MUST send a 1401 child element (prefixed by the streams namespace prefix) 1402 to the initiating entity in order to announce any stream-level 1403 features that can be negotiated or capabilities that otherwise need 1404 to be advertised. 1406 R: 1407 1415 R: 1416 1417 1418 1419 1421 Stream features are used mainly to advertise TLS negotiation 1422 (Section 6), SASL negotiation (Section 7), and resource binding 1423 (Section 8); however, stream features also can be used to advertise 1424 features associated with various XMPP extensions. 1426 If it is mandatory for a feature to be successfully negotiated before 1427 the initiating entity will be allowed to proceed with the sending of 1428 XML stanzas or with further steps of the stream negotiation, the 1429 advertisement of that feature SHOULD include an empty 1430 child element but MAY include neither a element not an 1431 element (i.e., features default to required). 1433 R: 1434 1435 1436 1438 1440 If successful negotiation of a feature is discretionary, the 1441 advertisement of that feature MUST include an empty child 1442 element. 1444 R: 1445 1446 1447 1448 1450 If an entity does not understand or support a feature that has been 1451 advertised, it MUST still inspect the feature advertisement to 1452 determine if negotiation of the feature is mandatory. If negotiation 1453 of an unsupported feature is mandatory (as determined by inclusion of 1454 the child element or the absence of an child 1455 element), then the entity MUST abort the stream negotiation process. 1456 If negotiation of an unsupported feature is discretionary (as 1457 determined by inclusion of the child element or the 1458 absence of a child element), the entity MUST silently ignore the 1459 associated feature advertisement and proceed with the stream 1460 negotiation process. 1462 Note: Implementations based on an earlier revision of this 1463 specification do not include the child element and 1464 they include the child element only in the case of the 1465 STARTTLS feature. Entities MUST accept stream feature 1466 advertisements without the child elements, and SHOULD consider 1467 consider negotiation of such features to be discretionary. 1469 If it is necessary for a feature to be successfully negotiated before 1470 the initiating entity is allowed to proceed with the sending a non- 1471 security-related feature or with further steps of the stream 1472 negotiation, the receiving entity SHOULD NOT advertise any other 1473 stream features until the mandatory feature has been successfully 1474 negotiated; however, if the mandatory feature is security-critical 1475 (e.g., STARTTLS or SASL) then the receiving entity MUST NOT advertise 1476 any other stream features until the security-critical feature has 1477 been successfully negotiated. 1479 The order of child elements contained in any given 1480 element is not significant. 1482 After completing negotiation of any stream feature (even stream 1483 features that do not require a stream restart), the receiving entity 1484 MUST send an updated list of stream features to the initiating 1485 entity. However, if there are no features to be advertised then the 1486 receiving entity MUST send an empty element. 1488 R: 1489 1498 R: 1500 At any time after stream establishment, the receiving entity MAY send 1501 additional or modified stream feature advertisements (e.g., because a 1502 new feature has been enabled). 1504 5.6. Restarts During Stream Negotiation 1506 Certain stream features require the initiating entity to send a new 1507 initial stream header on successful negotiation of the feature (e.g., 1508 after successful negotiation of TLS or SASL). Both parties MUST 1509 consider the previous stream to be replaced on successful feature 1510 negotiation but MUST NOT terminate the underlying TCP connection; 1511 instead, the parties MUST reuse the existing connection, which might 1512 be in a new state (e.g., encrypted as a result of TLS negotiation). 1513 When the receiving entity receives the new initial stream header, it 1514 MUST generate a new stream ID (instead of re-using the old stream ID) 1515 before sending a new response stream header. 1517 5.7. Closing a Stream 1519 An XML stream between two entities can be closed because a stream 1520 error has occurred or in some cases in the absence of an error. 1521 Where feasible, it is preferable to close a stream only if a stream 1522 error has occurred. 1524 A stream is closed by sending a closing tag over the TCP 1525 connection. 1527 S: 1529 After an entity sends a closing stream tag, it MUST NOT send further 1530 data over that stream. 1532 5.7.1. With Stream Error 1534 If a stream error has occurred, the entity that detects the error 1535 MUST close the stream as described under Section 5.8.1. 1537 5.7.2. Without Stream Error 1539 At any time after XML streams have been negotiated between two 1540 entities, either entity MAY close its stream to the other party in 1541 the absence of a stream error by sending a closing stream tag. 1543 P: 1545 The entity that sends the closing stream tag SHOULD wait for the 1546 other party to also close its stream. 1548 S: 1550 However, the entity that sends the first closing stream tag MAY 1551 consider both streams to be void if the other party does not send its 1552 closing stream tag within a reasonable amount of time (where the 1553 definition of "reasonable" is a matter of implementation or 1554 deployment). 1556 After the entity that sent the first closing stream tag receives a 1557 reciprocal closing stream tag from the other party (or if it 1558 considers the stream to be void after a reasonable amount of time), 1559 it MUST terminate the underlying TCP connection or connections. 1561 5.7.3. Handling of Idle Streams 1563 An XML stream can become idle, i.e., neither entity has sent XMPP 1564 traffic over the stream for some period of time. The idle timeout 1565 period is a matter of implementation and local service policy; 1566 however, it is RECOMMENDED to be liberal in accepting idle streams, 1567 since experience has shown that doing so improves the reliability of 1568 communications over XMPP networks. In particular, it is typically 1569 more efficient to maintain a stream between two servers than it is to 1570 aggressively timeout such a stream, especially with regard to 1571 synchronization of presence information as described in [xmpp-im]; 1572 therefore it is RECOMMENDED to maintain such a stream since 1573 experience has shown that server-to-server streams are cyclical and 1574 typically need to be re-established every 24 to 48 hours if they are 1575 timed out. 1577 An XML stream can appear idle at the XMPP level because the 1578 underlying TCP connection has become idle (e.g., a client's network 1579 connection has been lost). The typical method for detecting an idle 1580 TCP connection is to send a space character (U+0020) over the TCP 1581 connection between XML stanzas, which is allowed for XML streams as 1582 described under Section 12.7. The sending of such a space character 1583 is called a WHITESPACE PING. The time between such whitespace pings 1584 (or other connection-testing methods) is a matter of implementation 1585 and local service policy; however, it is RECOMMENDED that these pings 1586 be sent not more than once every 60 seconds. 1588 To close an idle stream with a local client or remote server, a 1589 server MUST close the stream without error as explained under 1590 Section 5.7.2. 1592 5.8. Stream Errors 1594 The root stream element MAY contain an child element that is 1595 prefixed by the streams namespace prefix. The error child shall be 1596 sent by a compliant entity if it perceives that a stream-level error 1597 has occurred. 1599 5.8.1. Rules 1601 The following rules apply to stream-level errors. 1603 5.8.1.1. Stream Errors Are Unrecoverable 1605 Stream-level errors are unrecoverable. Therefore, if an error occurs 1606 at the level of the stream, the entity that detects the error MUST 1607 send a element with an appropriate child element that 1608 specifies the error condition and at the same time send a closing 1609 tag. 1611 C: 1613 S: 1614 1616 1617 1619 The entity that generates the stream error then SHOULD immediately 1620 terminate the underlying TCP connection, although it MAY wait until 1621 after it receives a closing tag from the entity to which it 1622 sent the stream error. 1624 C: 1626 5.8.1.2. Stream Errors Can Occur During Setup 1628 If the error is triggered by the initial stream header, the receiving 1629 entity MUST still send the opening tag, include the 1630 element as a child of the stream element, and send the closing 1631 tag (preferably all at the same time). 1633 C: 1634 1642 S: 1643 1652 1654 1655 1657 5.8.1.3. Stream Errors When the Host is Unspecified or Unknown 1659 If the initiating entity provides no 'to' attribute or provides an 1660 unknown host in the 'to' attribute and the error occurs during stream 1661 setup, the receiving entity SHOULD provide an authoritative hostname 1662 in the 'from' attribute of the stream header sent before termination, 1663 but absent such an authoritative hostname MAY instead simply populate 1664 the response stream's 'from' attribute with the value of the initial 1665 stream header's 'to' attribute (where the value of the 'from' 1666 attribute MAY be empty if the initiating entity provided no 'to' 1667 attribute). 1669 C: 1670 1678 S: 1679 1687 1688 1690 1691 1693 5.8.2. Syntax 1695 The syntax for stream errors is as follows, where "defined-condition" 1696 is a placeholder for one of the conditions defined under 1697 Section 5.8.3. 1699 1700 1701 [ 1703 [ ... descriptive text ... ] 1704 ] 1705 [application-specific condition element] 1706 1708 The element: 1710 o MUST contain a child element corresponding to one of the defined 1711 stream error conditions (Section 5.8.3); this element MUST be 1712 qualified by the 'urn:ietf:params:xml:ns:xmpp-streams' namespace. 1713 o MAY contain a child element containing XML character data 1714 that describes the error in more detail; this element MUST be 1715 qualified by the 'urn:ietf:params:xml:ns:xmpp-streams' namespace 1716 and SHOULD possess an 'xml:lang' attribute specifying the natural 1717 language of the XML character data. 1718 o MAY contain a child element for an application-specific error 1719 condition; this element MUST be qualified by an application- 1720 defined namespace, and its structure is defined by that namespace 1721 (see Section 5.8.4). 1723 The element is OPTIONAL. If included, it MUST be used only 1724 to provide descriptive or diagnostic information that supplements the 1725 meaning of a defined condition or application-specific condition. It 1726 MUST NOT be interpreted programmatically by an application. It MUST 1727 NOT be used as the error message presented to a human user, but MAY 1728 be shown in addition to the error message associated with the defined 1729 condition element (and, optionally, the application-specific 1730 condition element). 1732 5.8.3. Defined Stream Error Conditions 1734 The following stream-level error conditions are defined. 1736 5.8.3.1. bad-format 1738 The entity has sent XML that cannot be processed. 1740 (In the following example, the client sends an XMPP message that is 1741 not well-formed XML.) 1743 C: 1744 No closing body tag! 1745 1747 S: 1748 1750 1751 1753 This error MAY be used instead of the more specific XML-related 1754 errors, such as , , , , and . However, 1756 the more specific errors are RECOMMENDED. 1758 5.8.3.2. bad-namespace-prefix 1760 The entity has sent a namespace prefix that is unsupported, or has 1761 sent no namespace prefix on an element that requires such a prefix 1762 (see Section 12.2). 1764 (In the following example, the client specifies a namespace prefix of 1765 "foobar" for the XML streams namespace.) 1767 C: 1768 1775 S: 1776 1784 1785 1787 1788 1790 5.8.3.3. conflict 1792 The server is either (1) closing the existing stream for this entity 1793 because a new stream has been initiated that conflicts with the 1794 existing stream, or (2) is refusing a new stream for this entity 1795 because allowing the new stream would conflict with an existing 1796 stream (e.g., because the server allows only a certain number of 1797 connections from the same IP address). 1799 C: 1800 1807 S: 1808 1816 1817 1819 1820 1822 5.8.3.4. connection-timeout 1824 The entity has not generated any traffic over the stream for some 1825 period of time (configurable according to a local service policy) and 1826 therefore the connection is being dropped. 1828 P: 1829 1831 1832 1834 5.8.3.5. host-gone 1836 The value of the 'to' attribute provided in the initial stream header 1837 corresponds to a hostname that is no longer serviced by the receiving 1838 entity. 1840 (In the following example, the peer specifies a 'to' address of 1841 "foo.im.example.com" when connecting to the "im.example.com" server, 1842 but the server no longer hosts a service at that address.) 1843 P: 1844 1851 S: 1852 1860 1861 1863 1864 1866 5.8.3.6. host-unknown 1868 The value of the 'to' attribute provided in the initial stream header 1869 does not correspond to a hostname that is serviced by the receiving 1870 entity. 1872 (In the following example, the peer specifies a 'to' address of 1873 "example.org" when connecting to the "im.example.com" server, but the 1874 server knows nothing of that address.) 1875 P: 1876 1883 S: 1884 1892 1893 1895 1896 1898 5.8.3.7. improper-addressing 1900 A stanza sent between two servers lacks a 'to' or 'from' attribute, 1901 the 'from' or 'to' attribute has no value, or the value is not a 1902 valid XMPP address. 1904 (In the following example, the peer sends a stanza without a 'to' 1905 address.) 1907 P: 1908 Wherefore art thou? 1909 1911 S: 1912 1914 1915 1917 5.8.3.8. internal-server-error 1919 The server has experienced a misconfiguration or an otherwise- 1920 undefined internal error that prevents it from servicing the stream. 1922 S: 1923 1925 1926 1928 5.8.3.9. invalid-from 1930 The JID or hostname provided in a 'from' address is not a valid JID 1931 or does not match an authorized JID or validated domain as negotiated 1932 between servers via SASL or server dialback, or as negotiated between 1933 a client and a server via authentication and resource binding. 1935 (In the following example, a peer that has authenticated only as 1936 "example.net" attempts to send a stanza from an address at 1937 "example.org".) 1939 P: 1940 Neither, fair saint, if either thee dislike. 1941 1943 S: 1944 1946 1947 1949 5.8.3.10. invalid-id 1951 The stream ID or server dialback ID is invalid or does not match an 1952 ID previously provided. 1954 (In the following example, the server dialback ID is invalid; see 1955 [XEP-0220].) 1957 P: 1963 S: 1964 1966 1967 1969 5.8.3.11. invalid-namespace 1971 The streams namespace name is something other than 1972 "http://etherx.jabber.org/streams" (see Section 12.2) or the default 1973 namespace is not supported (e.g., something other than "jabber: 1974 client" or "jabber:server"). 1976 (In the following example, the client specifies a streams namespace 1977 of 'http://wrong.namespace.example.org/'.) 1979 C: 1980 1987 S: 1988 1996 1997 1999 2000 2002 5.8.3.12. invalid-xml 2004 The entity has sent invalid XML over the stream to a server that 2005 performs validation (see Section 12.4). 2007 (In the following example, the peer attempts to send an IQ stanza of 2008 type "subscribe" but the XML schema defines no such value for the 2009 'type' attribute.) 2010 P: 2014 2015 2017 S: 2018 2020 2021 2023 5.8.3.13. not-authorized 2025 The entity has attempted to send XML stanzas before the stream has 2026 been authenticated, or otherwise is not authorized to perform an 2027 action related to stream negotiation; the receiving entity MUST NOT 2028 process the offending stanza before sending the stream error. 2030 (In the following example, the client attempts to send XML stanzas 2031 before authenticating with the server.) 2032 C: 2033 2040 S: 2041 2051 Wherefore art thou? 2052 2054 S: 2055 2057 2058 2060 5.8.3.14. policy-violation 2062 The entity has violated some local service policy (e.g., the stanza 2063 exceeds a configured size limit); the server MAY choose to specify 2064 the policy in the element or in an application-specific 2065 condition element. 2067 (In the following example, the client sends an XMPP message that is 2068 too large according to the server's local service policy.) 2070 C: 2071 [ ... the-emacs-manual ... ] 2072 2074 S: 2075 2077 2079 S: 2081 5.8.3.15. remote-connection-failed 2083 The server is unable to properly connect to a remote entity that is 2084 required for authentication or authorization, such as a remote 2085 authentication database or (in server dialback) the authoritative 2086 server. 2088 C: 2089 2096 S: 2097 2105 2106 2108 2109 2111 5.8.3.16. resource-constraint 2113 The server lacks the system resources necessary to service the 2114 stream. 2116 C: 2117 2124 S: 2125 2133 2134 2136 2137 2139 5.8.3.17. restricted-xml 2141 The entity has attempted to send restricted XML features such as a 2142 comment, processing instruction, DTD subset, or XML entity reference 2143 (see Section 12.1). 2145 (In the following example, the client sends an XMPP message 2146 containing an XML comment.) 2148 C: 2149 2150 This message has no subject. 2151 2153 S: 2154 2156 2157 2159 5.8.3.18. see-other-host 2161 The server will not provide service to the initiating entity but is 2162 redirecting traffic to another host; the XML character data of the 2163 element returned by the server SHOULD specify the 2164 alternate hostname or IP address at which to connect, which SHOULD be 2165 a valid domain identifier but MAY also include a port number. When 2166 it receives a see-other-host stream error, the initiating entity 2167 SHOULD cleanly handle the disconnection and then reconnect to the 2168 host specified in the element; if no port is 2169 specified, the initiating entity SHOULD perform a [DNS-SRV] lookup on 2170 the provided domain identifier but MAY assume that it can connect to 2171 that domain identifier at the standard XMPP ports (i.e., 5222 for 2172 client-to-server connections and 5269 for server-to-server 2173 connections). 2175 C: 2176 2183 S: 2184 2192 2193 2195 im.example.com:9090 2196 2197 2198 2200 5.8.3.19. system-shutdown 2202 The server is being shut down and all active streams are being 2203 closed. 2205 S: 2206 2208 2209 2211 5.8.3.20. undefined-condition 2213 The error condition is not one of those defined by the other 2214 conditions in this list; this error condition SHOULD be used only in 2215 conjunction with an application-specific condition. 2217 S: 2218 2220 2221 2222 2224 5.8.3.21. unsupported-encoding 2226 The initiating entity has encoded the stream in an encoding that is 2227 not supported by the server (see Section 12.6) or has otherwise 2228 improperly encoded the stream (e.g., by violating the rules of the 2229 [UTF-8] encoding). 2231 (In the following example, the client attempts to encode data using 2232 UTF-16 instead of UTF-8.) 2234 C: 2235 2242 S: 2243 2252 2254 2255 2257 5.8.3.22. unsupported-stanza-type 2259 The initiating entity has sent a first-level child of the stream that 2260 is not supported by the server or consistent with the default 2261 namespace. 2263 (In the following example, the client attempts to send an XML stanza 2264 of when the default namespace is "jabber:client".) 2266 C: 2267 2268 2269 2270 Soliloquy 2271 2272 To be, or not to be: that is the question: 2273 Whether 'tis nobler in the mind to suffer 2274 The slings and arrows of outrageous fortune, 2275 Or to take arms against a sea of troubles, 2276 And by opposing end them? 2277 2278 2280 tag:denmark.example,2003:entry-32397 2281 2003-12-13T18:30:02Z 2282 2003-12-13T18:30:02Z 2283 2284 2285 2286 2288 S: 2289 2291 2292 2294 5.8.3.23. unsupported-version 2296 The value of the 'version' attribute provided by the initiating 2297 entity in the stream header specifies a version of XMPP that is not 2298 supported by the server; the server MAY specify the version(s) it 2299 supports in the element. 2301 (In the following example, the client specifies an XMPP version of 2302 "11.0" but the server supports only version "1.0" and "1.1".) 2303 C: 2304 2311 S: 2312 2321 2323 2324 1.0, 1.1 2325 2326 2327 2329 5.8.3.24. xml-not-well-formed 2331 The initiating entity has sent XML that violates the well-formedness 2332 rules of [XML] or [XML-NAMES]. 2334 (In the following example, the client sends an XMPP message that is 2335 not well-formed XML.) 2337 C: 2338 No closing body tag! 2339 2341 S: 2342 2344 2345 2347 5.8.4. Application-Specific Conditions 2349 As noted, an application MAY provide application-specific stream 2350 error information by including a properly-namespaced child in the 2351 error element. The application-specific element SHOULD supplement or 2352 further qualify a defined element. Thus the element will 2353 contain two or three child elements. 2355 C: 2356 2357 My keyboard layout is: 2359 QWERTYUIOP{}| 2360 ASDFGHJKL:" 2361 ZXCVBNM<>? 2362 2363 2365 S: 2366 2368 2369 Some special application diagnostic information! 2370 2371 2372 2373 2375 5.9. Simplified Stream Examples 2377 This section contains two simplified examples of a stream-based 2378 connection between a client and a server; these examples are included 2379 for the purpose of illustrating the concepts introduced thus far. 2381 A basic connection: 2383 C: 2384 2393 2402 [ ... channel encryption ... ] 2404 [ ... authentication ... ] 2406 [ ... resource binding ... ] 2408 C: 2411 Art thou not Romeo, and a Montague? 2412 2414 S: 2417 Neither, fair saint, if either thee dislike. 2418 2420 C: 2422 S: 2423 A connection gone bad: 2425 C: 2426 2434 S: 2435 2444 [ ... channel encryption ... ] 2446 [ ... authentication ... ] 2448 [ ... resource binding ... ] 2450 C: 2453 No closing body tag! 2454 2456 S: 2457 2459 2460 2462 More detailed examples are provided under Section 10. 2464 6. STARTTLS Negotiation 2465 6.1. Overview 2467 XMPP includes a method for securing the stream from tampering and 2468 eavesdropping. This channel encryption method makes use of the 2469 Transport Layer Security [TLS] protocol, specifically a "STARTTLS" 2470 extension that is modelled after similar extensions for the [IMAP], 2471 [POP3], and [ACAP] protocols as described in [USINGTLS]. The XML 2472 namespace name for the STARTTLS extension is 2473 'urn:ietf:params:xml:ns:xmpp-tls'. 2475 Support for STARTTLS is REQUIRED in XMPP client and server 2476 implementations. An administrator of a given deployment MAY require 2477 the use of TLS for client-to-server communication, server-to-server 2478 communication, or both. A deployed client SHOULD use TLS to secure 2479 its stream with a server prior to attempting the completion of SASL 2480 negotiation (Section 7), and deployed servers SHOULD use TLS between 2481 two domains for the purpose of securing server-to-server 2482 communication. 2484 6.2. Rules 2486 6.2.1. Data Formatting 2488 During STARTTLS negotiation, the entities MUST NOT send any 2489 whitespace within the root stream element as separators between XML 2490 elements (i.e., from the last character of the element 2491 qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' namespace at 2492 depth=1 of the stream as sent by the initiating entity until the last 2493 character of the element qualified by the 2494 'urn:ietf:params:xml:ns:xmpp-tls' namespace at depth=1 of the stream 2495 as sent by the receiving entity). This prohibition helps to ensure 2496 proper security layer byte precision. Any such whitespace shown in 2497 the STARTTLS examples provided in this document is included only for 2498 the sake of readability. 2500 6.2.2. Order of Negotiation 2502 If the initiating entity chooses to use TLS, STARTTLS negotiation 2503 MUST be completed before proceeding to SASL negotiation (Section 7); 2504 this order of negotiation is required to help safeguard 2505 authentication information sent during SASL negotiation, as well as 2506 to make it possible to base the use of the SASL EXTERNAL mechanism on 2507 a certificate (or other credentials) provided during prior TLS 2508 negotiation. 2510 6.3. Process 2512 6.3.1. Exchange of Stream Headers and Stream Features 2514 The initiating entity resolves the hostname of the receiving entity 2515 as specified under Section 4, opens a TCP connection to the 2516 advertised port at the resolved IP address, and sends an initial 2517 stream header to the receiving entity; if the initiating entity is 2518 capable of STARTTLS negotiation, it MUST include the 'version' 2519 attribute set to a value of at least "1.0" in the initial stream 2520 header. 2522 I: 2530 The receiving entity MUST send a response stream header to the 2531 initiating entity over the TCP connection opened by the initiating 2532 entity; if the receiving entity is capable of STARTTLS negotiation, 2533 it MUST include the 'version' attribute set to a value of at least 2534 "1.0" in the response stream header. 2536 R: element qualified by the 2549 'urn:ietf:params:xml:ns:xmpp-tls' namespace. 2551 If the receiving entity considers STARTTLS negotiation to be 2552 discretionary, the element MUST contain an empty 2553 child element. 2555 R: 2556 2557 2558 2559 2561 If the receiving entity considers STARTTLS negotiation to be 2562 mandatory, the element MUST contain an empty 2563 child element. 2565 R: 2566 2567 2568 2569 2571 6.3.2. Initiation of STARTTLS Negotiation 2573 6.3.2.1. STARTTLS Command 2575 In order to begin the STARTTLS negotiation, the initiating entity 2576 issues the STARTTLS command (i.e., a element qualified by 2577 the 'urn:ietf:params:xml:ns:xmpp-tls' namespace) to instruct the 2578 receiving entity that it wishes to begin a STARTTLS negotiation to 2579 secure the stream. 2581 I: 2583 The receiving entity MUST reply with either a element 2584 (proceed case) or a element (failure case) qualified by 2585 the 'urn:ietf:params:xml:ns:xmpp-tls' namespace. 2587 6.3.2.2. Failure Case 2589 If the failure case occurs, the receiving entity MUST return a 2590 element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' 2591 namespace, terminate the XML stream, and terminate the underlying TCP 2592 connection. 2594 R: 2596 R: 2598 Causes for the failure case include but are not limited to: 2600 1. The initiating entity has sent a malformed STARTTLS command. 2602 2. The receiving entity does not offer STARTTLS negotiation either 2603 temporarily or permanently. 2604 3. The receiving entity cannot complete STARTTLS negotiation because 2605 of an internal error. 2607 Note: STARTTLS failure is not triggered by TLS errors such as bad 2608 certificate or unknown certificate authority; those errors are 2609 generated and handled during the TLS negotiation itself as 2610 described in [TLS]. 2612 If the failure case occurs, the initiating entity MAY attempt to 2613 reconnect as explained under Section 4.5. 2615 6.3.2.3. Proceed Case 2617 If the proceed case occurs, the receiving entity MUST return a 2618 element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' 2619 namespace. 2621 R: 2623 The receiving entity MUST consider the TLS negotiation to have begun 2624 immediately after sending the closing '>' character of the 2625 element to the initiating entity. The initiating entity MUST 2626 consider the TLS negotiation to have begun immediately after 2627 receiving the closing '>' character of the element from 2628 the receiving entity. 2630 The entities now proceed to TLS negotiation as explained in the next 2631 section. 2633 6.3.3. TLS Negotiation 2635 6.3.3.1. Rules 2637 In order to complete TLS negotiation over the TCP connection, the 2638 entities MUST follow the process defined in [TLS]. 2640 The following rules apply: 2642 1. The entities MUST NOT send any further XML data until the TLS 2643 negotiation has either failed or succeeded. 2644 2. The receiving entity MUST present a certificate. 2645 3. The receiving entity SHOULD send a certificate request to the 2646 initiating entity so that mutual authentication will be possible. 2647 4. The initiating entity MUST validate the certificate to determine 2648 if the TLS negotiation shall succeed; see Section 15.2.2 2649 regarding certificate validation procedures. 2651 5. The receiving entity SHOULD choose which certificate to present 2652 based on the 'to' attribute of the initial stream header. 2654 Note: See Section 15.6 regarding ciphers that MUST be supported 2655 for TLS; naturally, other ciphers MAY be supported as well. 2657 6.3.3.2. TLS Failure 2659 If the TLS negotiation results in failure, the receiving entity MUST 2660 terminate the TCP connection. 2662 The receiving entity MUST NOT send a closing tag before 2663 terminating the TCP connection, since the receiving entity and 2664 initiating entity MUST consider the original stream to be replaced 2665 upon failure of the TLS negotiation. 2667 6.3.3.3. TLS Success 2669 If the TLS negotiation is successful, then the entities MUST proceed 2670 as follows. 2672 1. The receiving entity MUST discard any knowledge obtained in an 2673 insecure manner from the initiating entity before TLS took 2674 effect. 2675 2. The initiating entity MUST discard any knowledge obtained in an 2676 insecure manner from the receiving entity before TLS took effect. 2677 3. The initiating entity MUST send a new initial stream header to 2678 the receiving entity over the encrypted connection. 2680 I: 2688 Note: The initiating entity MUST NOT send a closing tag 2689 before sending the new initial stream header, since the receiving 2690 entity and initiating entity MUST consider the original stream to 2691 be replaced upon success of the TLS negotiation. 2692 4. The receiving entity MUST respond with a new response stream 2693 header over the encrypted connection. 2695 R: 2710 2711 EXTERNAL 2712 PLAIN 2713 2714 2715 2717 7. SASL Negotiation 2719 7.1. Overview 2721 XMPP includes a method for authenticating a stream by means of an 2722 XMPP-specific profile of the Simple Authentication and Security Layer 2723 protocol (see [SASL]). SASL provides a generalized method for adding 2724 authentication support to connection-based protocols, and XMPP uses 2725 an XML namespace profile of SASL that conforms to the profiling 2726 requirements of [SASL]. 2728 Support for SASL negotiation is REQUIRED in XMPP client and server 2729 implementations. 2731 7.2. Rules 2733 7.2.1. Mechanism Preferences 2735 Any entity that will act as a SASL client or a SASL server MUST 2736 maintain an ordered list of its preferred SASL mechanisms according 2737 to the client or server, where the list is ordered by the perceived 2738 strength of the mechanisms. A server MUST offer and a client MUST 2739 try SASL mechanisms in the order of their perceived strength. For 2740 example, if the server offers the ordered list "PLAIN DIGEST-MD5 2741 GSSAPI" or "DIGEST-MD5 GSSAPI PLAIN" but the client's ordered list is 2742 "GSSAPI DIGEST-MD5", the client shall try GSSAPI first and then 2743 DIGEST-MD5 but shall never try PLAIN (since PLAIN is not on its 2744 list). 2746 7.2.2. Mechanism Offers 2748 If the receiving entity considers TLS negotiation (Section 6) to be 2749 mandatory before use of a particular SASL authentication mechanism 2750 will be acceptable, the receiving entity MUST NOT advertise that 2751 mechanism in its list of available SASL authentication mechanisms 2752 prior to successful TLS negotiation. 2754 If during prior TLS negotiation the initiating entity presented a 2755 certificate that is acceptable to the receiving entity for purposes 2756 of strong identity verification in accordance with local service 2757 policies, the receiving entity MUST offer the SASL EXTERNAL mechanism 2758 to the initiating entity during SASL negotiation (refer to [SASL]) 2759 and SHOULD prefer that mechanism. However, the EXTERNAL mechanism 2760 MAY be offered under other circumstances as well. 2762 See Section 15.6 regarding mechanisms that MUST be supported; 2763 naturally, other SASL mechanisms MAY be supported as well. Best 2764 practices for the use of several SASL mechanisms in the context of 2765 XMPP are described in [XEP-0175] and [XEP-0178]. 2767 7.2.3. Data Formatting 2769 The following data formattting rules apply to the SASL negotiation: 2771 1. During SASL negotiation, the entities MUST NOT send any 2772 whitespace within the root stream element as separators between 2773 XML elements (i.e., from the last character of the 2774 element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' 2775 namespace at depth=1 of the stream as sent by the initiating 2776 entity until the last character of the element 2777 qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace at 2778 depth=1 of the stream as sent by the receiving entity). This 2779 prohibition helps to ensure proper security layer byte precision. 2780 Any such whitespace shown in the SASL examples provided in this 2781 document is included only for the sake of readability. 2782 2. Any XML character data contained within the XML elements MUST be 2783 encoded using base64, where the encoding adheres to the 2784 definition in Section 4 of [BASE64] and where the padding bits 2785 are set to zero. 2786 3. As formally specified in the XML schema for the 2787 'urn:ietf:params:xml:ns:xmpp-sasl' namespace under Appendix C.4, 2788 the receiving entity MAY include one or more application-specific 2789 child elements inside the element to provide 2790 information that might be needed by the initiating entity in 2791 order to complete successful SASL negotiation using one or more 2792 of the offered mechanisms; however, the syntax and semantics of 2793 all such elements are out of scope for this specification. 2795 7.2.4. Security Layers 2797 Upon successful SASL negotiation that involves negotiation of a 2798 security layer, both the initiating entity and the receiving MUST 2799 discard any application-layer state (i.e, state from the XMPP layer, 2800 excluding state from the TLS negotiation or SASL negotiation). 2802 7.2.5. Simple Usernames 2804 It is possible that provision of a "simple username" is supported by 2805 the selected SASL mechanism (e.g., this is supported by the DIGEST- 2806 MD5 and CRAM-MD5 mechanisms but not by the EXTERNAL and GSSAPI 2807 mechanisms). The simple username provided during authentication MUST 2808 be as follows: 2810 Client-to-server communication: The initiating entity's registered 2811 account name, i.e., a user name or node name as described under 2812 Section 3.3 (this is not a bare JID of the form but 2813 only the node portion of the JID). The simple username MUST 2814 adhere to the Nodeprep (Appendix A) profile of [STRINGPREP]. 2815 Server-to-server communication: The initiating entity's sending 2816 domain, i.e., IP address or fully qualified domain name as 2817 contained in an XMPP domain identifier. The simple username MUST 2818 adhere to the [NAMEPREP] profile of [STRINGPREP]. 2820 7.2.6. Authorization Identities 2822 If the initiating entity wishes to act on behalf of another entity 2823 and the selected SASL mechanism supports transmission of an 2824 authorization identity, the initiating entity MUST provide an 2825 authorization identity during SASL negotiation. If the initiating 2826 entity does not wish to act on behalf of another entity, it MUST NOT 2827 provide an authorization identity. As specified in [SASL], the 2828 initiating entity MUST NOT provide an authorization identity unless 2829 the authorization identity is different from the default 2830 authorization identity derived from the authentication identity. If 2831 provided, the value of the authorization identity MUST be a bare JID 2832 of the form (i.e., an XMPP domain identifier only) for 2833 servers and a bare JID of the form (i.e., node 2834 identifier and domain identifier) for clients. 2836 Note: The authorization identity communited during SASL 2837 negotiation is used to determine the canonical address for the 2838 initiating client or server according to the receiving server, as 2839 described under Section 3.5. 2841 7.2.7. Realms 2843 The receiving entity MAY include a realm when negotiating certain 2844 SASL mechanisms. If the receiving entity does not communicate a 2845 realm, the initiating entity MUST NOT assume that any realm exists. 2846 The realm MUST be used only for the purpose of authentication; in 2847 particular, an initiating entity MUST NOT attempt to derive an XMPP 2848 hostname from the realm information provided by the receiving entity. 2850 7.2.8. Round Trips 2852 [SASL] specifies that a using protocol such as XMPP can define two 2853 methods by which the protocol can save round trips where allowed for 2854 the SASL mechanism: 2856 1. When the SASL client (the XMPP "initiating entity") requests an 2857 authentication exchange, it can include "initial response" data 2858 with its request if appropriate for the SASL mechanism in use. 2859 In XMPP this is done by including the initial response as the XML 2860 character data of the element. 2861 2. At the end of the authentication exchange, the SASL server (the 2862 XMPP "receiving entity") can include "additional data with 2863 success" if appropriate for the SASL mechanism in use. In XMPP 2864 this is done by including the additional data as the XML 2865 character data of the element. 2867 For the sake of protocol efficiency, it is RECOMMENDED for XMPP 2868 clients and servers to use these methods, however they MUST support 2869 the less efficient modes as well. 2871 7.3. Process 2873 The process for SASL negotiation is as follows. 2875 7.3.1. Exchange of Stream Headers and Stream Features 2877 If SASL negotiation follows successful STARTTLS negotation 2878 (Section 6), then the SASL negotiation occurs over the encrypted 2879 stream that has already been negotiated. If not, the initiating 2880 entity resolves the hostname of the receiving entity as specified 2881 under Section 4, opens a TCP connection to the advertised port at the 2882 resolved IP address, and sends an initial stream header to the 2883 receiving entity; if the initiating entity is capable of STARTTLS 2884 negotiation, it MUST include the 'version' attribute set to a value 2885 of at least "1.0" in the initial stream header. 2887 I: 2895 The receiving entity MUST send a response stream header to the 2896 initiating entity; if the receiving entity is capable of SASL 2897 negotiation, it MUST include the 'version' attribute set to a value 2898 of at least "1.0" in the response stream header. 2900 R: element qualified by the 2913 'urn:ietf:params:xml:ns:xmpp-sasl' namespace. 2915 The element MUST contain one child element 2916 for each authentication mechanism the receiving entity offers to the 2917 initiating entity. The order of elements in the XML 2918 indicates the preference order of the SASL mechanisms according to 2919 the receiving entity; however the initiating entity MUST maintain its 2920 own preference order independent of the preference order of the 2921 receiving entity. 2923 R: 2924 2925 EXTERNAL 2926 PLAIN 2927 2928 2929 2931 If the receiving entity considers SASL negotiation to be 2932 discretionary, the element MUST contain an empty 2933 child element. 2935 R: 2936 2937 EXTERNAL 2938 PLAIN 2939 2940 2941 2943 If the receiving entity considers SASL negotiation to be mandatory, 2944 the element MUST contain an empty child 2945 element. 2947 R: 2948 2949 EXTERNAL 2950 PLAIN 2951 2952 2953 2955 7.3.2. Initiation 2957 In order to begin the SASL negotiation, the initiating entity sends 2958 an element qualified by the 2959 'urn:ietf:params:xml:ns:xmpp-sasl' namespace and includes an 2960 appropriate value for the 'mechanism' attribute. This element MAY 2961 contain XML character data (in SASL terminology, the "initial 2962 response") if the mechanism supports or requires it; if the 2963 initiating entity needs to send a zero-length initial response, it 2964 MUST transmit the response as a single equals sign character ("="), 2965 which indicates that the response is present but contains no data. 2967 I: UjBtMzBSMGNrcw== 2970 7.3.3. Challenge-Response Sequence 2972 If necessary, the receiving entity challenges the initiating entity 2973 by sending a element qualified by the 2974 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY 2975 contain XML character data (which MUST be generated in accordance 2976 with the definition of the SASL mechanism chosen by the initiating 2977 entity). 2979 The initiating entity responds to the challenge by sending a 2980 element qualified by the 2981 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY 2982 contain XML character data (which MUST be generated in accordance 2983 with the definition of the SASL mechanism chosen by the initiating 2984 entity). 2986 If necessary, the receiving entity sends more challenges and the 2987 initiating entity sends more responses. 2989 This series of challenge/response pairs continues until one of three 2990 things happens: 2992 o The initiating entity aborts the handshake. 2993 o The receiving entity reports failure of the handshake. 2994 o The receiving entity reports success of the handshake. 2996 These scenarios are described in the following sections. 2998 7.3.4. Abort 3000 The initiating entity aborts the handshake by sending an 3001 element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' 3002 namespace. 3004 I: 3006 Upon receiving an element, the receiving entity MUST return 3007 a element qualified by the 3008 'urn:ietf:params:xml:ns:xmpp-sasl' namespace and containing an 3009 child element. 3011 R: 3012 3013 3015 7.3.5. Failure 3017 The receiving entity reports failure of the handshake by sending a 3018 element qualified by the 3019 'urn:ietf:params:xml:ns:xmpp-sasl' namespace (the particular cause of 3020 failure MUST be communicated in an appropriate child element of the 3021 element as defined under Section 7.4). 3023 R: 3024 3025 3027 Where appropriate for the chosen SASL mechanism, the receiving entity 3028 SHOULD allow a configurable but reasonable number of retries (at 3029 least 2 and no more than 5); this enables the initiating entity 3030 (e.g., an end-user client) to tolerate incorrectly-provided 3031 credentials (e.g., a mistyped password) without being forced to 3032 reconnect. 3034 If the initiating entity attempts a reasonable number of retries with 3035 the same SASL mechanism and all attempts fail, it MAY fall back to 3036 the next mechanism in its ordered list by sending a new 3037 request to the receiving entity. If there are no remaining 3038 mechanisms in its list, the initiating entity SHOULD instead send an 3039 element to the receiving entity. 3041 If the initiating entity exceeds the number of retries, the receiving 3042 entity MUST return a stream error (which SHOULD be but MAY be ). 3045 7.3.6. Success 3047 The receiving entity reports success of the handshake by sending a 3048 element qualified by the 3049 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY 3050 contain XML character data (in SASL terminology, "additional data 3051 with success") if the chosen SASL mechanism supports or requires it; 3052 if the receiving entity needs to send additional data of zero length, 3053 it MUST transmit the data as a single equals sign character ("="). 3055 R: 3057 Note: The authorization identity communited during SASL 3058 negotiation is used to determine the canonical address for the 3059 initiating client or server according to the receiving server, as 3060 described under Section 3.5. 3062 Upon receiving the element, the initiating entity MUST 3063 initiate a new stream over the existing TCP connection by sending a 3064 new initial stream header to the receiving entity. 3066 I: tag 3075 before sending the new initial stream header, since the receiving 3076 entity and initiating entity MUST consider the original stream to 3077 be replaced upon sending or receiving the element. 3079 Upon receiving the new initial stream header from the initiating 3080 entity, the receiving entity MUST respond by sending a new response 3081 XML stream header to the initiating entity. 3083 R: 3092 The receiving entity MUST also send stream features, containing any 3093 further available features or containing no features (via an empty 3094 element). 3096 R: 3097 3098 3099 3100 3102 7.4. SASL Errors 3104 The syntax of SASL errors is as follows: 3106 3107 3108 [ 3109 OPTIONAL descriptive text 3110 ] 3111 3113 Where "defined-condition" is one of the SASL-related error conditions 3114 defined in the following sections. 3116 Inclusion of a defined condition is REQUIRED. 3118 Inclusion of the element is OPTIONAL, and can be used to 3119 provide application-specific information about the error condition, 3120 which information MAY be displayed to a human but only as a 3121 supplement to the defined condition. 3123 7.4.1. aborted 3125 The receiving entity acknowledges an element sent by the 3126 initiating entity; sent in reply to the element. 3128 I: 3130 R: 3131 3132 3134 7.4.2. account-disabled 3136 The account of the initiating entity has been temporarily disabled; 3137 sent in reply to an element (with or without initial response 3138 data) or a element. 3140 I: UjBtMzBSMGNrcw== 3143 R: 3144 3145 Call 212-555-1212 for assistance. 3146 3148 7.4.3. credentials-expired 3150 The authentication failed because the initiating entity provided 3151 credentials that have expired; sent in reply to a element 3152 or an element with initial response data. 3154 I: 3155 [ ... ] 3156 3158 R: 3159 3160 3162 7.4.4. encryption-required 3164 The mechanism requested by the initiating entity cannot be used 3165 unless the underlying stream is encrypted; sent in reply to an 3166 element (with or without initial response data). 3168 I: UjBtMzBSMGNrcw== 3171 R: 3172 3173 3175 7.4.5. incorrect-encoding 3177 The data provided by the initiating entity could not be processed 3178 because the [BASE64] encoding is incorrect (e.g., because the 3179 encoding does not adhere to the definition in Section 4 of [BASE64]); 3180 sent in reply to a element or an element with 3181 initial response data. 3183 I: [ ... ] 3186 R: 3187 3188 3190 7.4.6. invalid-authzid 3192 The authzid provided by the initiating entity is invalid, either 3193 because it is incorrectly formatted or because the initiating entity 3194 does not have permissions to authorize that ID; sent in reply to a 3195 element or an element with initial response data. 3197 I: 3198 [ ... ] 3199 3201 R: 3202 3203 3205 7.4.7. invalid-mechanism 3207 The initiating entity did not provide a mechanism or requested a 3208 mechanism that is not supported by the receiving entity; sent in 3209 reply to an element. 3211 I: 3214 R: 3215 3217 3219 7.4.8. malformed-request 3221 The request is malformed (e.g., the element includes initial 3222 response data but the mechanism does not allow that, or the data sent 3223 violates the syntax for the specified SASL mechanism); sent in reply 3224 to an , , , or element. 3226 (In the following example, the XML character data of the 3227 element contains more than 255 UTF-8-encoded Unicode characters and 3228 therefore violates the "token" production for the SASL ANONYMOUS 3229 mechanism as specified in [ANONYMOUS].) 3231 I: [ ... some-long-token ... ] 3234 R: 3235 3236 3238 7.4.9. mechanism-too-weak 3240 The mechanism requested by the initiating entity is weaker than 3241 server policy permits for that initiating entity; sent in reply to an 3242 element (with or without initial response data). 3244 I: UjBtMzBSMGNrcw== 3247 R: 3248 3249 3251 7.4.10. not-authorized 3253 The authentication failed because the initiating entity did not 3254 provide proper credentials or the receiving entity has detected an 3255 attack but wishes to disclose as little information as possible to 3256 the attacker; sent in reply to a element or an 3257 element with initial response data. 3259 I: 3260 [ ... ] 3261 3263 R: 3264 3266 3268 Note: This error condition includes but is not limited to the case 3269 of incorrect credentials or an unknown username. In order to 3270 discourage directory harvest attacks, no differentiation is made 3271 between incorrect credentials and an unknown username. 3273 7.4.11. temporary-auth-failure 3275 The authentication failed because of a temporary error condition 3276 within the receiving entity, and it is advisable for the initiating 3277 entity to try again later; sent in reply to an element or a 3278 element. 3280 I: 3281 [ ... ] 3282 3284 R: 3285 3286 3288 7.4.12. transition-needed 3290 The authentication failed because the mechanism cannot be used until 3291 the initiating entity provides (for one time only) a plaintext 3292 password so that the receiving entity can build a hashed password for 3293 use in future authentication attempts; sent in reply to an 3294 element with or without initial response data. 3296 I: [ ... ] 3299 R: 3300 3301 3303 Note: An XMPP client MUST treat a error with 3304 extreme caution, SHOULD NOT provide a plaintext password over an 3305 XML stream that is not encrypted via Transport Layer Security, and 3306 MUST warn a human user before allowing the user to provide a 3307 plaintext password over an unencrypted connection. 3309 7.5. SASL Definition 3311 The profiling requirements of [SASL] require that the following 3312 information be supplied by the definition of a using protocol. 3314 service name: "xmpp" 3315 initiation sequence: After the initiating entity provides an opening 3316 XML stream header and the receiving entity replies in kind, the 3317 receiving entity provides a list of acceptable authentication 3318 methods. The initiating entity chooses one method from the list 3319 and sends it to the receiving entity as the value of the 3320 'mechanism' attribute possessed by an element, optionally 3321 including an initial response to avoid a round trip. 3322 exchange sequence: Challenges and responses are carried through the 3323 exchange of elements from receiving entity to 3324 initiating entity and elements from initiating entity 3325 to receiving entity. The receiving entity reports failure by 3326 sending a element and success by sending a 3327 element; the initiating entity aborts the exchange by sending an 3328 element. Upon successful negotiation, both sides 3329 consider the original XML stream to be closed and new stream 3330 headers are sent by both entities. 3331 security layer negotiation: The security layer takes effect 3332 immediately after sending the closing '>' character of the 3333 element for the receiving entity, and immediately after 3334 receiving the closing '>' character of the element for 3335 the initiating entity. The order of layers is first [TCP], then 3336 [TLS], then [SASL], then XMPP. 3337 use of the authorization identity: The authorization identity can be 3338 used in XMPP to denote the non-default of a client 3339 or the sending of a server; an empty string is equivalent 3340 to an absent authorization identity. 3342 8. Resource Binding 3344 8.1. Overview 3346 After a client authenticates with a server, it MUST bind a specific 3347 resource to the stream so that the server can properly address the 3348 client (see Section 3). That is, there MUST be an XMPP resource 3349 identifier associated with the bare JID () of the 3350 client, so that the address for use over that stream is a full JID of 3351 the form . This ensures that the server can 3352 deliver XML stanzas to and receive XML stanzas from the client (see 3353 Section 11). 3355 After a client has bound a resource to the stream, it is referred to 3356 as a CONNECTED RESOURCE. A server SHOULD allow an entity to maintain 3357 multiple connected resources simultaneously, where each connected 3358 resource is associated with a distinct XML stream and differentiated 3359 from the other connected resources by a distinct resource identifier; 3360 however, a server MUST enable the administrator of an XMPP service to 3361 limit the number of connected resources in order to prevent certain 3362 denial of service attacks as described under Section 15.13. 3364 If, before completing the resource binding step, the client attempts 3365 to send an outbound XML stanza (i.e., a stanza not directed to the 3366 server itself or to the client's own account), the server MUST NOT 3367 process the stanza and MUST either ignore the stanza or return a 3368 stream error to the client. 3370 Support for resource binding is REQUIRED in XMPP client and server 3371 implementations. 3373 8.2. Advertising Support 3375 Upon sending a new response stream header to the client after 3376 successful SASL negotiation, the server MUST include a 3377 element qualified by the 'urn:ietf:params:xml:ns:xmpp-bind' namespace 3378 in the stream features it presents to the client; this 3379 element MUST include an empty element to explicitly 3380 indicate that it is mandatory for the client to complete resource 3381 binding at this stage of the stream negotiation process. 3383 Note: The server MUST NOT include the resource binding stream 3384 feature until after the client has authenticated, typically by 3385 means of 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. 3554 3. Disallow the newly-requested resource and maintain the current 3555 resource. 3557 Which of these the server does is up to the implementation, although 3558 it is RECOMMENDED to implement case #1. 3560 S: 3561 3562 3563 juliet@im.example.com/balcony 4db06f06-1ea4-11dc-aca3-000bcd821bfb 3564 3565 3566 3568 In case #2, the server MUST send a stream error to the 3569 current resource and return an IQ stanza of type "result" (indicating 3570 success) to the newly-requested resource. 3572 S: 3574 In case #3, the server MUST send a stanza error to the 3575 newly-requested resource but maintain the XML stream for that 3576 connection so that the newly-requested resource has an opportunity to 3577 negotiate a non-conflicting resource identifier before sending 3578 another request for resource binding. 3580 S: 3581 3582 3583 3584 3586 8.5.3. Retries 3588 If an error occurs when a client submits a resource identifier, the 3589 server SHOULD allow a configurable but reasonable number of retries 3590 (at least 2 and no more than 5); this enables the client to tolerate 3591 incorrectly-provided resource identifiers (e.g., bad data formats or 3592 duplicate text strings) without being forced to reconnect. 3594 After the client has reached the retry limit, the server MUST return 3595 a stream error to the client. 3597 9. XML Stanzas 3599 After a client has connected to a server or two servers have 3600 connected to each other, either party can send XML stanzas over the 3601 negotiated stream. Three kinds of XML stanza are defined for the 3602 'jabber:client' and 'jabber:server' namespaces: , 3603 , and . In addition, there are five common 3604 attributes for these stanza types. These common attributes, as well 3605 as the basic semantics of the three stanza types, are defined herein; 3606 more detailed information regarding the syntax of XML stanzas for 3607 instant messaging and presence applications is provided in [xmpp-im], 3608 and for other applications in the relevant XMPP extension 3609 specifications. 3611 A server MUST NOT process a partial stanza and MUST NOT attach 3612 meaning to the transmission timing of any part of a stanza (before 3613 receipt of the close tag). 3615 Support for the XML stanza syntax and semantics defined herein is 3616 REQUIRED in XMPP client and server implementations. 3618 9.1. Common Attributes 3620 The following five attributes are common to message, presence, and IQ 3621 stanzas. 3623 9.1.1. to 3625 The 'to' attribute specifies the JID of the intended recipient for 3626 the stanza. 3628 3629 Art thou not Romeo, and a Montague? 3630 3632 For information about server processing of inbound and outbound XML 3633 stanzas based on the nature of the 'to' address, refer to Section 11. 3635 9.1.1.1. Client-to-Server Streams 3637 The following rules apply to inclusion of the 'to' attribute in the 3638 context of XML streams qualified by the 'jabber:client' namespace 3639 (i.e., client-to-server streams). 3641 1. A stanza with a specific intended recipient MUST possess a 'to' 3642 attribute whose value is an XMPP address. 3644 2. A stanza sent from a client to a server for direct processing by 3645 the server on behalf of the client (e.g., presence sent to the 3646 server for broadcasting to other entities) MUST NOT possess a 3647 'to' attribute. 3649 9.1.1.2. Server-to-Server Streams 3651 The following rules apply to inclusion of the 'to' attribute in the 3652 context of XML streams qualified by the 'jabber:server' namespace 3653 (i.e., server-to-server streams). 3655 1. A stanza MUST possess a 'to' attribute whose value is an XMPP 3656 address; if a server receives a stanza that does not meet this 3657 restriction, it MUST generate an stream 3658 error. 3659 2. The domain identifier portion of the JID in the 'to' atttribute 3660 MUST match a hostname serviced by the receiving server; if a 3661 server receives a stanza that does not meet this restriction, it 3662 MUST generate a or stream error. 3664 9.1.2. from 3666 The 'from' attribute specifies the JID of the sender. 3668 3670 Art thou not Romeo, and a Montague? 3671 3673 9.1.2.1. Client-to-Server Streams 3675 The following rules apply to the 'from' attribute in the context of 3676 XML streams qualified by the 'jabber:client' namespace (i.e., client- 3677 to-server streams). 3679 1. When the server receives an XML stanza from a client and the 3680 stanza does not include a 'from' attribute, the server MUST add a 3681 'from' attribute to the stanza, where the value of the 'from' 3682 attribute is the full JID () determined by 3683 the server for the connected resource that generated the stanza 3684 (see Section 3.5), or the bare JID () in the case of 3685 subscription-related presence stanzas (see [xmpp-im]). 3686 2. When the server receives an XML stanza from a client and the 3687 stanza includes a 'from' attribute, the server MUST either (a) 3688 validate that the value of the 'from' attribute provided by the 3689 client is that of a connected resource for the associated entity 3690 or (b) override the provided 'from' attribute by adding a 'from' 3691 attribute as specified under Rule #1. 3693 3. When the server generates a stanza from the server for delivery 3694 to the client on behalf of the account of the connected client 3695 (e.g., in the context of data storage services provided by the 3696 server on behalf of the client), the stanza MUST either (a) not 3697 include a 'from' attribute or (b) include a 'from' attribute 3698 whose value is the account's bare JID (). 3699 4. When the server generates a stanza from the server itself for 3700 delivery to the client, the stanza MUST include a 'from' 3701 attribute whose value is the bare JID (i.e., ) of the 3702 server. 3703 5. A server MUST NOT send to the client a stanza without a 'from' 3704 attribute if the stanza was not generated by the server (e.g., if 3705 it was generated by another client or another server); therefore, 3706 when a client receives a stanza that does not include a 'from' 3707 attribute, it MUST assume that the stanza is from the server to 3708 which the client is connected. 3710 9.1.2.2. Server-to-Server Streams 3712 The following rules apply to the 'from' attribute in the context of 3713 XML streams qualified by the 'jabber:server' namespace (i.e., server- 3714 to-server streams). 3716 1. A stanza MUST possess a 'from' attribute whose value is an XMPP 3717 address; if a server receives a stanza that does not meet this 3718 restriction, it MUST generate an stream 3719 error. 3720 2. The domain identifier portion of the JID contained in the 'from' 3721 attribute MUST match the hostname of the sending server (or any 3722 validated domain thereof) as communicated in the SASL negotiation 3723 (see Section 7), server dialback (see [XEP-0220], or similar 3724 means; if a server receives a stanza that does not meet this 3725 restriction, it MUST generate an stream error. 3727 Enforcement of these rules helps to prevent certain denial of service 3728 attacks as described under Section 15.13. 3730 9.1.3. id 3732 The 'id' attribute MAY be used by a sending entity for internal 3733 tracking of stanzas that it sends and receives (especially for 3734 tracking the request-response interaction inherent in the semantics 3735 of IQ stanzas). The value of the 'id' attribute MAY be unique 3736 globally, within a domain, or within a stream. The semantics of IQ 3737 stanzas impose additional restrictions; see Section 9.2.3. 3739 9.1.4. type 3741 The 'type' attribute specifies the purpose or context of the message, 3742 presence, or IQ stanza. The particular allowable values for the 3743 'type' attribute vary depending on whether the stanza is a message, 3744 presence, or IQ stanza. The defined values for message and presence 3745 stanzas are specific to instant messaging and presence applications 3746 and therefore are specified in [xmpp-im], whereas the values for IQ 3747 stanzas specify the role of an IQ stanza in a structured request- 3748 response exchange and therefore are specified under Section 9.2.3. 3749 The only 'type' value common to all three stanzas is "error"; see 3750 Section 9.3. 3752 9.1.5. xml:lang 3754 A stanza SHOULD possess an 'xml:lang' attribute (as defined in 3755 Section 2.12 of [XML]) if the stanza contains XML character data that 3756 is intended to be presented to a human user (as explained in 3757 [CHARSET], "internationalization is for humans"). The value of the 3758 'xml:lang' attribute specifies the default language of any such 3759 human-readable XML character data. 3761 3762 dnd 3763 Wooing Juliet 3764 3766 The value of the 'xml:lang' attribute MAY be overridden by the 'xml: 3767 lang' attribute of a specific child element. 3769 3770 dnd 3771 Wooing Juliet 3772 Dvořím se Julii 3773 3781 dnd 3782 Wooing Juliet 3783 3785 S: 3788 dnd 3789 Wooing Juliet 3790 3792 If an inbound stanza received received by a client or server does not 3793 possess an 'xml:lang' attribute, an implementation MUST assume that 3794 the default language is that specified for the stream as defined 3795 under Section 5.3.4. 3797 The value of the 'xml:lang' attribute MUST conform to the NMTOKEN 3798 datatype (as defined in Section 2.3 of [XML]) and MUST conform to the 3799 format defined in [LANGTAGS]. 3801 A server MUST NOT modify or delete 'xml:lang' attributes on stanzas 3802 it receives from other entities. 3804 9.2. Basic Semantics 3806 9.2.1. Message Semantics 3808 The stanza can be seen as a "push" mechanism whereby one 3809 entity pushes information to another entity, similar to the 3810 communications that occur in a system such as email. All message 3811 stanzas SHOULD possess a 'to' attribute that specifies the intended 3812 recipient of the message; upon receiving such a stanza, a server 3813 SHOULD route or deliver it to the intended recipient (see Section 11 3814 for general routing and delivery rules related to XML stanzas). 3816 9.2.2. Presence Semantics 3818 The stanza can be seen as a specialized broadcast or 3819 "publish-subscribe" mechanism, whereby multiple entities receive 3820 information (in this case, network availability information) about an 3821 entity to which they have subscribed. In general, a publishing 3822 entity (client) SHOULD send a presence stanza with no 'to' attribute, 3823 in which case the server to which the entity is connected SHOULD 3824 broadcast that stanza to all subscribed entities. However, a 3825 publishing entity MAY also send a presence stanza with a 'to' 3826 attribute, in which case the server SHOULD route or deliver that 3827 stanza to the intended recipient. See Section 11 for general routing 3828 and delivery rules related to XML stanzas, and [xmpp-im] for rules 3829 specific to presence applications. 3831 9.2.3. IQ Semantics 3833 Info/Query, or IQ, is a request-response mechanism, similar in some 3834 ways to the Hypertext Transfer Protocol [HTTP]. The semantics of IQ 3835 enable an entity to make a request of, and receive a response from, 3836 another entity. The data content of the request and response is 3837 defined by the schema or other structural definition associated with 3838 the XML namespace that qualifies the direct child element of the IQ 3839 element (see Section 9.4), and the interaction is tracked by the 3840 requesting entity through use of the 'id' attribute. Thus, IQ 3841 interactions follow a common pattern of structured data exchange such 3842 as get/result or set/result (although an error can be returned in 3843 reply to a request if appropriate): 3845 Requesting Responding 3846 Entity Entity 3847 ---------- ---------- 3848 | | 3849 | | 3850 | [ ... payload ... ] | 3851 | | 3852 | -------------------------> | 3853 | | 3854 | | 3855 | [ ... payload ... ] | 3856 | | 3857 | <------------------------- | 3858 | | 3859 | | 3860 | [ ... payload ... ] | 3861 | | 3862 | -------------------------> | 3863 | | 3864 | | 3865 | [ ... condition ... ] | 3866 | | 3867 | <------------------------- | 3868 | | 3870 To enforce these semantics, the following rules apply: 3872 1. The 'id' attribute is REQUIRED for IQ stanzas. 3873 2. The 'type' attribute is REQUIRED for IQ stanzas. The value MUST 3874 be one of the following (if the value is other than one of the 3875 following strings, the recipient or an intermediate router MUST 3876 return a stanza error of ): 3877 * get -- The stanza requests information, inquires about what 3878 data is needed in order to complete further operations, etc. 3879 * set -- The stanza provides data that is needed for an 3880 operation to be completed, sets new values, replaces existing 3881 values, etc. 3882 * result -- The stanza is a response to a successful get or set 3883 request. 3884 * error -- The stanza reports an error that has occurred 3885 regarding processing or delivery of a previously-sent get or 3886 set request (see Section 9.3). 3887 3. An entity that receives an IQ request of type "get" or "set" MUST 3888 reply with an IQ response of type "result" or "error". The 3889 response MUST preserve the 'id' attribute of the request. 3890 4. An entity that receives a stanza of type "result" or "error" MUST 3891 NOT respond to the stanza by sending a further IQ response of 3892 type "result" or "error"; however, the requesting entity MAY send 3893 another request (e.g., an IQ of type "set" to provide required 3894 information discovered through a get/result pair). 3895 5. An IQ stanza of type "get" or "set" MUST contain exactly one 3896 child element, which specifies the semantics of the particular 3897 request. 3898 6. An IQ stanza of type "result" MUST include zero or one child 3899 elements. 3900 7. An IQ stanza of type "error" MAY include the child element 3901 contained in the associated "get" or "set" and MUST include an 3902 child; for details, see Section 9.3. 3904 9.3. Stanza Errors 3906 Stanza-related errors are handled in a manner similar to stream 3907 errors (Section 5.8). Unlike stream errors, stanza errors are 3908 recoverable; therefore they do not result in termination of the XML 3909 stream and underlying TCP connection. Instead, the entity that 3910 discovers the error condition returns an ERROR STANZA to the sender, 3911 i.e., a stanza of the same kind (message, presence, or IQ) whose 3912 'type' attribute is set to a value of "error" and which contains an 3913 child element that specifies the error condition. The 3914 specified error condition provides a hint regarding actions that the 3915 sender can take to remedy the error if possible. 3917 9.3.1. Rules 3919 The following rules apply to stanza errors: 3921 1. The receiving or processing entity that detects an error 3922 condition in relation to a stanza SHOULD return an error stanza 3923 (and MUST do so for IQ stanzas). 3925 2. The entity that generates an error stanza MAY include the 3926 original XML sent so that the sender can inspect and, if 3927 necessary, correct the XML before attempting to resend. 3928 3. An error stanza MUST contain an child element. 3929 4. An child MUST NOT be included if the 'type' attribute 3930 has a value other than "error" (or if there is no 'type' 3931 attribute). 3932 5. An entity that receives an error stanza MUST NOT respond to the 3933 stanza with a further error stanza; this helps to prevent 3934 looping. 3936 9.3.2. Syntax 3938 The syntax for stanza-related errors is: 3940 3941 [OPTIONAL to include sender XML here] 3942 3943 3944 [ 3946 OPTIONAL descriptive text 3947 ] 3948 [OPTIONAL application-specific condition element] 3949 3950 3952 The "stanza-kind" MUST be one of message, presence, or iq. 3954 The "error-type MUST be one of the following: 3956 o auth -- retry after providing credentials 3957 o cancel -- do not retry (the error cannot be remedied) 3958 o continue -- proceed (the condition was only a warning) 3959 o modify -- retry after changing the data sent 3960 o wait -- retry after waiting (the error is temporary) 3962 The element: 3964 o MUST contain a child element corresponding to one of the stanza 3965 error conditions defined under Section 9.3.3; this element MUST be 3966 qualified by the 'urn:ietf:params:xml:ns:xmpp-stanzas' namespace. 3967 o MAY contain a child element containing XML character data 3968 that describes the error in more detail; this element MUST be 3969 qualified by the 'urn:ietf:params:xml:ns:xmpp-stanzas' namespace 3970 and SHOULD possess an 'xml:lang' attribute specifying the natural 3971 language of the XML character data. 3973 o MAY contain a child element for an application-specific error 3974 condition; this element MUST be qualified by an application- 3975 specific namespace that defines the syntax and semantics of the 3976 element. 3978 The element is OPTIONAL. If included, it MUST be used only 3979 to provide descriptive or diagnostic information that supplements the 3980 meaning of a defined condition or application-specific condition. It 3981 MUST NOT be interpreted programmatically by an application. It MUST 3982 NOT be used as the error message presented to a human user, but MAY 3983 be shown in addition to the error message associated with the defined 3984 condition element (and, optionally, the application-specific 3985 condition element). 3987 9.3.3. Defined Conditions 3989 The following conditions are defined for use in stanza errors. 3991 9.3.3.1. bad-request 3993 The sender has sent a stanza containing XML that does not conform to 3994 the appropriate schema or that cannot be processed (e.g., an IQ 3995 stanza that includes an unrecognized value of the 'type' attribute, 3996 or an element that is qualified by a recognized namespace but that 3997 violates the defined syntax for the element); the associated error 3998 type SHOULD be "modify". 4000 C: 4004 4005 4007 S: 4011 4012 4013 4014 4016 9.3.3.2. conflict 4018 Access cannot be granted because an existing resource exists with the 4019 same name or address; the associated error type SHOULD be "cancel". 4021 C: 4022 4023 balcony 4024 4025 4027 S: 4028 4029 4030 4031 4033 9.3.3.3. feature-not-implemented 4035 The feature represented in the XML stanza is not implemented by the 4036 intended recipient or an intermediate server and therefore the stanza 4037 cannot be processed (e.g., the entity understands the namespace but 4038 does not recognize the element name); the associated error type 4039 SHOULD be "cancel" or "modify". 4041 C: 4045 4046 4047 4048 4050 E: 4054 4055 4057 4060 4061 4063 9.3.3.4. forbidden 4065 The requesting entity does not possess the required permissions to 4066 perform the action; the associated error type SHOULD be "auth". 4068 C: 4071 4072 4074 E: 4078 4079 4080 4081 4083 9.3.3.5. gone 4085 The recipient or server can no longer be contacted at this address, 4086 typically on a permanent basis; the associated error type SHOULD be 4087 "cancel" or "modify" and the error stanza SHOULD include a new 4088 address as the XML character data of the element (which MUST 4089 be a URI or IRI at which the entity can be contacted, typically an 4090 XMPP IRI as specified in [XMPP-URI]). 4092 C: 4095 4096 4098 E: 4102 4103 4104 xmpp:conference.example.com 4105 4106 4107 4109 9.3.3.6. internal-server-error 4111 The server could not process the stanza because of a misconfiguration 4112 or an otherwise-undefined internal server error; the associated error 4113 type SHOULD be "wait" or "cancel". 4115 C: 4118 4119 4121 E: 4125 4126 4128 4129 4131 9.3.3.7. item-not-found 4133 The addressed JID or item requested cannot be found; the associated 4134 error type SHOULD be "cancel" or "modify". 4136 C: 4139 S: 4142 4143 4144 4145 4147 Note: An application MUST NOT return this error if doing so would 4148 provide information about the intended recipient's network 4149 availability to an entity that is not authorized to know such 4150 information; instead it MUST return a 4151 error. 4153 9.3.3.8. jid-malformed 4155 The sending entity has provided or communicated an XMPP address 4156 (e.g., a value of the 'to' attribute) or aspect thereof (e.g., an 4157 XMPP resource identifier) that does not adhere to the syntax defined 4158 under Section 3; the associated error type SHOULD be "modify". 4160 C: 4163 4164 4166 E: 4170 4171 4173 4174 4176 9.3.3.9. not-acceptable 4178 The recipient or server understands the request but is refusing to 4179 process it because it does not meet criteria defined by the recipient 4180 or server (e.g., a local policy regarding stanza size limits or 4181 acceptable words in messages); the associated error type SHOULD be 4182 "modify". 4184 C: 4185 [ ... the-emacs-manual ... ] 4186 4188 S: 4189 4190 4192 4193 4195 9.3.3.10. not-allowed 4197 The recipient or server does not allow any entity to perform the 4198 action (e.g., sending to entities at a blacklisted domain); the 4199 associated error type SHOULD be "cancel". 4201 C: 4204 4205 4207 E: 4211 4212 4213 4214 4216 9.3.3.11. not-authorized 4218 The sender needs to provide proper credentials before being allowed 4219 to perform the action, or has provided improper credentials; the 4220 associated error type SHOULD be "auth". 4222 C: 4225 4226 4228 E: 4231 4232 4233 4234 4236 9.3.3.12. not-modified 4238 The item requested has not changed since it was last requested; the 4239 associated error type SHOULD be "continue". 4241 C: 4244 4245 4246
4247 some-long-opaque-string 4248
4249
4250
4251
4253 S: 4256 4257 4258
4259 some-long-opaque-string 4260
4261
4262
4263 4264 4265 4266
4268 9.3.3.13. payment-required 4270 The requesting entity is not authorized to access the requested 4271 service because payment is required; the associated error type SHOULD 4272 be "auth". 4274 C: 4278 4279 4280 4281 4283 E: 4287 4288 4290 4291 4293 9.3.3.14. policy-violation 4295 The entity has violated some local service policy (e.g., the stanza 4296 exceeds a configured size limit); the server MAY choose to specify 4297 the policy in the element or in an application-specific 4298 condition element; the associated error type SHOULD be "modify" or 4299 "wait" depending on the policy being violated. 4301 (In the following example, the client sends an XMPP message that is 4302 too large according to the server's local service policy.) 4304 C: 4305 [ ... the-emacs-manual ... ] 4306 4308 S: 4309 4310 4312 4313 4315 9.3.3.15. recipient-unavailable 4317 The intended recipient is temporarily unavailable; the associated 4318 error type SHOULD be "wait". 4320 C: 4323 4324 4326 E: 4329 4330 4332 4333 4335 Note: An application MUST NOT return this error if doing so would 4336 provide information about the intended recipient's network 4337 availability to an entity that is not authorized to know such 4338 information; instead it MUST return a 4339 error. 4341 9.3.3.16. redirect 4343 The recipient or server is redirecting requests for this information 4344 to another entity, typically in a temporary fashion (the 4345 condition is used for permanent addressing failures); the associated 4346 error type SHOULD be "modify" and the error stanza SHOULD contain the 4347 alternate address in the XML character data of the 4348 element (which MUST be a URI or IRI at which the entity can be 4349 contacted, typically an XMPP IRI as specified in [XMPP-URI]). 4351 C: 4354 4355 4357 E: 4361 4362 4363 xmpp:characters@conference.example.org 4364 4365 4366 4368 9.3.3.17. registration-required 4370 The requesting entity is not authorized to access the requested 4371 service because prior registration is required; the associated error 4372 type SHOULD be "auth". 4374 C: 4377 4378 4380 E: 4383 4384 4386 4387 4389 9.3.3.18. remote-server-not-found 4391 A remote server or service specified as part or all of the JID of the 4392 intended recipient does not exist; the associated error type SHOULD 4393 be "cancel". 4395 C: 4398 4399 4401 E: 4404 4405 4407 4408 4410 9.3.3.19. remote-server-timeout 4412 A remote server or service specified as part or all of the JID of the 4413 intended recipient (or required to fulfill a request) could not be 4414 contacted within a reasonable amount of time; the associated error 4415 type SHOULD be "wait". 4417 C: 4420 4421 4423 E: 4426 4427 4429 4430 4432 9.3.3.20. resource-constraint 4434 The server or recipient lacks the system resources necessary to 4435 service the request; the associated error type SHOULD be "wait" or 4436 "modify". 4438 C: 4442 4443 4444 4445 4447 E: 4451 4452 4454 4455 4457 9.3.3.21. service-unavailable 4459 The server or recipient does not currently provide the requested 4460 service; the associated error type SHOULD be "cancel". 4462 C: 4464 Hello? 4465 4467 S: 4469 4470 4472 4473 4475 An application MUST return a error instead of 4476 or if sending one of the 4477 latter errors would provide information about the intended 4478 recipient's network availability to an entity that is not authorized 4479 to know such information. 4481 9.3.3.22. subscription-required 4483 The requesting entity is not authorized to access the requested 4484 service because a prior subscription is required; the associated 4485 error type SHOULD be "auth". 4487 C: help 4491 4493 E: 4497 4498 4500 4501 4503 9.3.3.23. undefined-condition 4505 The error condition is not one of those defined by the other 4506 conditions in this list; any error type can be associated with this 4507 condition, and it SHOULD be used only in conjunction with an 4508 application-specific condition. 4510 C: 4514 My lord, dispatch; read o'er these articles. 4515 4516 4519 4521 S: 4525 4529 4532 4533 4534 4536 4537 4540 4541 4542 4544 9.3.3.24. unexpected-request 4546 The recipient or server understood the request but was not expecting 4547 it at this time (e.g., the request was out of order); the associated 4548 error type SHOULD be "wait" or "modify". 4550 C: 4554 4555 4558 4559 4561 E: 4565 4566 4568 4570 4571 4573 9.3.4. Application-Specific Conditions 4575 As noted, an application MAY provide application-specific stanza 4576 error information by including a properly-namespaced child in the 4577 error element. The application-specific element SHOULD supplement or 4578 further qualify a defined element. Thus, the element will 4579 contain two or three child elements. 4581 4582 4583 4584 4585 4586 4587 4588 4589 4591 4593 [ ... application-specific information ... ] 4594 4595 4596 4597 4599 An entity that receives an application-specific error condition it 4600 does not understand MUST ignore the condition. 4602 9.4. Extended Content 4604 While the message, presence, and IQ stanzas provide basic semantics 4605 for messaging, availability, and request-response interactions, XMPP 4606 uses XML namespaces (see [XML-NAMES] to extend the basic stanza 4607 syntax for the purpose of providing additional functionality. Thus a 4608 message or presence stanza MAY contain one or more optional child 4609 elements specifying content that extends the meaning of the message 4610 (e.g., an XHTML-formatted version of the message body as described in 4611 [XEP-0071]), and an IQ stanza of type "get" or "set" MUST contain one 4612 such child element. This child element MAY have any name and MUST 4613 possess a namespace declaration (other than "jabber:client", "jabber: 4614 server", or "http://etherx.jabber.org/streams") that defines all data 4615 contained within the child element. Such a child element is said to 4616 be EXTENDED CONTENT and its namespace name is said to be an EXTENDED 4617 NAMESPACE. 4619 Support for any given extended namespace is OPTIONAL on the part of 4620 any implementation. If an entity does not understand such a 4621 namespace, the entity's expected behavior depends on whether the 4622 entity is (1) the recipient or (2) an entity that is routing the 4623 stanza to the recipient. 4625 Recipient: If a recipient receives a stanza that contains a child 4626 element it does not understand, it MUST silently ignore that 4627 particular XML data, i.e., it MUST NOT process it or present it to 4628 a user or associated application (if any). In particular: 4629 * If an entity receives a message or presence stanza that 4630 contains XML data qualified by a namespace it does not 4631 understand, the portion of the stanza that qualified by the 4632 unknown namespace MUST be ignored. 4634 * If an entity receives a message stanza whose only child element 4635 is qualified by a namespace it does not understand, it MUST 4636 ignore the entire stanza. 4637 * If an entity receives an IQ stanza of type "get" or "set" 4638 containing a child element qualified by a namespace it does not 4639 understand, the entity MUST return an IQ stanza of type "error" 4640 with an error condition of . 4641 Router: If a routing entity (typically a server) handles a stanza 4642 that contains a child element it does not understand, it MUST 4643 ignore the associated XML data by routing or delivering it 4644 untouched to the recipient. 4646 9.5. Stanza Size 4648 XMPP is optimized for the exchange of relatively large numbers of 4649 relatively small stanzas. A client or server MAY enforce a maximum 4650 stanza size. The maximum stanza size MUST NOT be smaller than 10000 4651 bytes, from the opening "<" character to the closing ">" character. 4652 If an entity receives a stanza that exceeds its maximum stanza size, 4653 it MUST return a stanza error or a stream error. 4656 10. Examples 4658 10.1. Client-to-Server 4660 The following examples show the XMPP data flow for a client 4661 negotiating an XML stream with a server, exchanging XML stanzas, and 4662 closing the negotiated stream. The server is "im.example.com", the 4663 server requires use of TLS, the client authenticates via the SASL 4664 PLAIN mechanism as "juliet@im.example.com", and the client binds a 4665 client-submitted resource to the stream. It is assumed that before 4666 sending the initial stream header, the client has already resolved an 4667 SRV record of _xmpp-client._tcp.im.example.com and has opened a TCP 4668 connection to the advertised port at the resolved IP address. 4670 Note: The alternate steps shown are provided only to illustrate 4671 the protocol for failure cases; they are not exhaustive and would 4672 not necessarily be triggered by the data sent in the examples. 4674 10.1.1. TLS 4676 Step 1: Client initiates stream to server: 4678 C: 4686 Step 2: Server responds by sending a response stream header to 4687 client: 4689 S: 4702 4703 4704 4705 4707 Step 4: Client sends STARTTLS command to server: 4709 C: 4711 Step 5: Server informs client that it is allowed to proceed: 4713 S: 4715 Step 5 (alt): Server informs client that STARTTLS negotiation has 4716 failed and closes both XML stream and TCP connection: 4718 S: 4720 S: 4721 Step 6: Client and server attempt to complete TLS negotiation over 4722 the existing TCP connection (see [TLS] for details). 4724 Step 7: If TLS negotiation is successful, client initiates a new 4725 stream to server: 4727 C: 4735 Step 7 (alt): If TLS negotiation is unsuccessful, server closes TCP 4736 connection. 4738 10.1.2. SASL 4740 Step 8: Server responds by sending a stream header to client along 4741 with any available stream features: 4743 S: 4753 4754 DIGEST-MD5 4755 PLAIN 4756 4757 4758 4760 Step 9: Client selects an authentication mechanism, in this case 4761 [PLAIN]: 4763 C: UjBtMzBSMGNrcw== 4766 Step 10: Server informs client of success: 4768 S: 4770 Step 10 (alt): Server returns error to client: 4772 S: 4773 4774 4776 Step 11: Client initiates a new stream to server: 4778 C: 4800 S: 4801 4802 4803 4804 4806 Upon being so informed that resource binding is mandatory, the client 4807 needs to bind a resource to the stream; here we assume that the 4808 client submits a human-readable text string. 4810 Step 13: Client binds a resource: 4812 C: 4813 4814 balcony 4815 4816 4818 Step 14: Server accepts submitted resource identifier and informs 4819 client of successful resource binding: 4821 S: 4822 4823 4824 juliet@im.example.com/balcony 4825 4826 4827 4829 10.1.4. Stanza Exchange 4831 Now the client is allowed to send XML stanzas over the negotiated 4832 stream. 4834 C: 4837 Art thou not Romeo, and a Montague? 4838 4840 If necessary, sender's server negotiates XML streams with intended 4841 recipient's server (see Section 10.2). 4843 The intended recipient replies and the message is delivered to the 4844 client. 4846 E: 4849 Neither, fair saint, if either thee dislike. 4850 4852 The client can subsequently send and receive an unbounded number of 4853 subsequent XML stanzas over the stream. 4855 10.1.5. Close 4857 Desiring to send no further messages, the client closes the stream. 4859 C: 4861 Consistent with the recommended stream closing handshake, the server 4862 closes the stream as well: 4864 S: 4866 Client now terminates the underlying TCP connection. 4868 10.2. Server-to-Server Examples 4870 The following examples show the data flow for a server negotiating an 4871 XML stream with another server, exchanging XML stanzas, and closing 4872 the negotiated stream. The initiating server ("Server1") is 4873 im.example.com; the receiving server ("Server2") is example.net and 4874 it requires use of TLS; im.example.com presents a certificate and 4875 authenticates via the SASL EXTERNAL mechanism. It is assumed that 4876 before sending the initial stream header, Server1 has already 4877 resolved an SRV record of _xmpp-server._tcp.example.net and has 4878 opened a TCP connection to the advertised port at the resolved IP 4879 address. 4881 Note: The alternate steps shown are provided only to illustrate 4882 the protocol for failure cases; they are not exhaustive and would 4883 not necessarily be triggered by the data sent in the examples. 4885 10.2.1. TLS 4887 Step 1: Server1 initiates stream to Server2: 4889 S1: 4896 Step 2: Server2 responds by sending a response stream header to 4897 Server1: 4899 S2: 4907 Step 3: Server2 sends stream features to Server1: 4909 S2: 4910 4911 4912 4913 4915 Step 4: Server1 sends the STARTTLS command to Server2: 4917 S1: 4919 Step 5: Server2 informs Server1 that it is allowed to proceed: 4921 S2: 4923 Step 5 (alt): Server2 informs Server1 that STARTTLS negotiation has 4924 failed and closes stream: 4926 S2: 4928 S2: 4930 Step 6: Server1 and Server2 attempt to complete TLS negotiation via 4931 TCP (see [TLS] for details). 4933 Step 7: If TLS negotiation is successful, Server1 initiates a new 4934 stream to Server2: 4936 S1: 4943 Step 7 (alt): If TLS negotiation is unsuccessful, Server2 closes TCP 4944 connection. 4946 10.2.2. SASL 4948 Step 8: Server2 sends a response stream header to Server1 along with 4949 available stream features (including a preference for the SASL 4950 EXTERNAL mechanism): 4952 S2: 4960 S2: 4961 4962 EXTERNAL 4963 4964 4965 4967 Step 9: Server1 selects the EXTERNAL mechanism, in this case with an 4968 authorization identity encoded according to [BASE64]: 4970 S1: eG1wcC5leGFtcGxlLmNvbQ 4973 The decoded authorization identity is "im.example.com". 4975 Step 10: Server2 determines that the authorization identity provided 4976 by Server1 matches the information in the presented certificate and 4977 therefore returns success: 4979 S2: 4981 Step 10 (alt): Server2 informs Server1 of failed authentication: 4983 S2: 4984 4985 4987 S2: 4988 Step 11: Server1 initiates a new stream to Server2: 4990 S1: 4997 Step 12: Server2 responds by sending a stream header to Server1 along 4998 with any additional features (or, in this case, an empty features 4999 element): 5001 S2: 5009 S2: 5011 10.2.3. Stanza Exchange 5013 Now Server1 is allowed to send XML stanzas to Server2 over the 5014 negotiated stream; here we assume that the transferred stanzas are 5015 those shown earlier for client-to-server communication, albeit over a 5016 server-to-server stream qualified by the 'jabber:server' namespace. 5018 Server1 sends XML stanza to Server2: 5020 S1: 5023 Art thou not Romeo, and a Montague? 5024 5026 The intended recipient replies and the message is delivered from 5027 Server2 to Server1. 5029 Server2 sends XML stanza to Server1: 5031 S2: 5034 Neither, fair saint, if either thee dislike. 5035 5037 10.2.4. Close 5039 Desiring to send no further messages, Server1 closes the stream. (In 5040 practice, the stream would most likely remain open for some time, 5041 since Server1 and Server2 do not immediately know if the stream will 5042 be needed for further communication.) 5044 S1: 5046 Consistent with the recommended stream closing handshake, Server2 5047 closes the stream as well: 5049 S2: 5051 Server1 now terminates the underlying TCP connection. 5053 11. Server Rules for Processing XML Stanzas 5055 An XMPP server MUST ensure in-order processing of XML stanzas between 5056 any two entities. This includes stanzas sent by a client to its 5057 server for direct processing by the server (e.g., in-order processing 5058 of a roster get and initial presence as described in [xmpp-im]). 5060 Beyond the requirement for in-order processing, each server 5061 implementation will contain its own logic for processing stanzas it 5062 receives. Such logic determines whether the server needs to ROUTE a 5063 given stanza to another domain, DELIVER it to a local entity 5064 (typically a connected client associated with a local account), or 5065 HANDLE it directly within the server itself. The following rules 5066 apply. 5068 Note: Particular XMPP applications MAY specify delivery rules that 5069 modify or supplement the following rules; for example, a set of 5070 delivery rules for instant messaging and presence applications is 5071 defined in [xmpp-im]. 5073 11.1. No 'to' Address 5075 11.1.1. Overview 5077 If the stanza possesses no 'to' attribute, the server MUST handle it 5078 directly on behalf of the entity that sent it, where the meaning of 5079 "handle it directly" depends on whether the stanza is message, 5080 presence, or IQ. Because all stanzas received from other servers 5081 MUST possess a 'to' attribute, this rule applies only to stanzas 5082 received from a local entity (such as a client) that is connected to 5083 the server. 5085 11.1.2. Message 5087 If the server receives a message stanza with no 'to' attribute, it 5088 MUST treat the message as if the 'to' address were the bare JID 5089 of the sending entity. 5091 11.1.3. Presence 5093 If the server receives a presence stanza with no 'to' attribute, it 5094 MUST broadcast it to the entities that are subscribed to the sending 5095 entity's presence, if applicable ([xmpp-im] defines the semantics of 5096 such broadcasting for presence applications). 5098 11.1.4. IQ 5100 If the server receives an IQ stanza with no 'to' attribute, it MUST 5101 process the stanza on behalf of the account from which received the 5102 stanza, as follows: 5104 1. If the IQ stanza is of type "get" or "set" and the server 5105 understands the namespace that qualifies the payload, the server 5106 MUST handle the stanza on behalf of the sending entity or return 5107 an appropriate error to the sending entity. While the meaning of 5108 "handle" is determined by the semantics of the qualifying 5109 namespace, in general the server shall respond to the IQ stanza 5110 of type "get" or "set" by returning an appropriate IQ stanza of 5111 type "result" or "error", responding as if the server were the 5112 bare JID of the sending entity. As an example, if the sending 5113 entity sends an IQ stanza of type "get" where the payload is 5114 qualified by the 'jabber:iq:roster' namespace (as described in 5115 [xmpp-im]), then the server shall return the roster associated 5116 with the sending entity's bare JID to the particular resource of 5117 the sending entity that requested the roster. 5118 2. If the IQ stanza is of type "get" or "set" and the server does 5119 not understand the namespace that qualifies the payload, the 5120 server MUST return an error to the sending entity, which MUST be 5121 . 5122 3. If the IQ stanza is of type "error" or "result", the server MUST 5123 handle the error or result as appropriate for the request- 5124 response interaction, responding as if the server were the bare 5125 JID of the sending entity. 5127 11.2. Local Domain 5129 If the hostname of the domain identifier portion of the JID contained 5130 in the 'to' attribute matches one of the configured hostnames of the 5131 server itself, the server MUST first determine if the hostname is 5132 serviced by the server or by a specialized local service. If the 5133 latter, the server MUST route the stanza to that service. If the 5134 former, the server MUST proceed as follows. 5136 11.2.1. Mere Domain 5138 If the JID contained in the 'to' attribute is of the form , 5139 then the server MUST either handle the stanza as appropriate for the 5140 stanza kind or return an error stanza to the sender. 5142 11.2.2. Domain with Resource 5144 If the JID contained in the 'to' attribute is of the form , then the server MUST either handle the stanza as 5146 appropriate for the stanza kind or return an error stanza to the 5147 sender. 5149 11.2.3. Node at Domain 5151 Note: For addresses of this type, more detailed rules in the 5152 context of instant messaging and presence applications are 5153 provided in [xmpp-im]. 5155 11.2.3.1. No Such User 5157 If there is no local account associated with the , how 5158 the stanza shall be processed depends on the stanza type. 5160 o For a message stanza, the server MUST return a stanza error to the sender. 5162 o For a presence stanza, the server SHOULD silently discard the 5163 stanza. 5164 o For an IQ stanza, the server MUST return a 5165 stanza error to the sender. 5167 11.2.3.2. Bare JID 5169 If the JID contained in the 'to' attribute is of the form 5170 , how the stanza shall be processed depends on the 5171 stanza type. 5173 o For a message stanza, if there exists at least one connected 5174 resource for the node the server SHOULD deliver it to at least one 5175 of the connected resources. If there exists no connected 5176 resource, the server MUST either return an error or store the 5177 message offline for delivery when the account next has a connected 5178 resource. 5180 o For a presence stanza, if there exists at least one connected 5181 resource for the node the server SHOULD deliver it to at least one 5182 of the connected resources. If there exists no connected 5183 resource, the server MUST silently discard the stanza. 5184 o For an IQ stanza, the server MUST handle it directly on behalf of 5185 the intended recipient. 5187 11.2.3.3. Full JID 5189 If the JID contained in the 'to' attribute is of the form 5190 and there is no connected resource that 5191 exactly matches the full JID, the stanza shall be processed as if the 5192 JID were of the form . 5194 If the JID contained in the 'to' attribute is of the form 5195 and there is a connected resource that exactly 5196 matches the full JID, the server SHOULD deliver the stanza to that 5197 connected resource. 5199 11.3. Foreign Domain 5201 If the hostname of the domain identifier portion of the JID contained 5202 in the 'to' attribute does not match one of the configured hostnames 5203 of the server itself, the server SHOULD attempt to route the stanza 5204 to the foreign domain (subject to local service provisioning and 5205 security policies regarding inter-domain communication, since such 5206 communication is optional for any given deployment). There are two 5207 possible cases. 5209 11.3.1. Existing Stream 5211 If a server-to-server stream already exists between the two domains, 5212 the sender's server shall attempt to route the stanza to the 5213 authoritative server for the foreign domain over the existing stream. 5215 11.3.2. No Existing Stream 5217 If there exists no server-to-server stream between the two domains, 5218 the sender's server shall proceed as follows: 5220 1. Resolve the hostname of the foreign domain (as defined under 5221 Section 15.4). 5222 2. Negotiate a server-to-server stream between the two domains (as 5223 defined under Section 6 and Section 7). 5224 3. Route the stanza to the authoritative server for the foreign 5225 domain over the newly-established stream. 5227 11.3.3. Error Handling 5229 If routing of a stanza to the intended recipient's server is 5230 unsuccessful, the sender's server MUST return an error to the sender. 5231 If resolution of the foreign domain is unsuccessful, the stanza error 5232 MUST be . If resolution succeeds but 5233 streams cannot be negotiated, the stanza error MUST be . 5236 If stream negotiation with the intended recipient's server is 5237 successful but the foreign server cannot deliver the stanza to the 5238 recipient, the foreign server shall return an appropriate error to 5239 the sender by way of the sender's server. 5241 12. XML Usage 5243 12.1. Restrictions 5245 The Extensible Messaging and Presence Protocol (XMPP) defines a class 5246 of data objects called XML streams as well as the behavior of 5247 computer programs that process XML streams. XMPP is an application 5248 profile or restricted form of the Extensible Markup Language [XML], 5249 and a complete XML stream (including start and end stream tags) is a 5250 conforming XML document. 5252 However, XMPP does not deal with XML documents but with XML streams. 5253 Because XMPP does not require the parsing of arbitrary and complete 5254 XML documents, there is no requirement that XMPP needs to support the 5255 full feature set of [XML]. In particular, the following features of 5256 XML are prohibited in XMPP: 5258 o comments (as defined in Section 2.5 of [XML]) 5259 o processing instructions (Section 2.6 therein) 5260 o internal or external DTD subsets (Section 2.8 therein) 5261 o internal or external entity references (Section 4.2 therein) with 5262 the exception of predefined entities (Section 4.6 therein) 5264 An XMPP implementation MUST behave as follows with regard to these 5265 features: 5267 1. An XMPP implementation MUST NOT inject characters matching such 5268 features into an XML stream. 5269 2. If an XMPP implementation receives characters matching such 5270 features over an XML stream, it MUST return a stream error, which 5271 SHOULD be but MAY be . 5273 12.2. XML Namespace Names and Prefixes 5275 XML namespaces (see [XML-NAMES]) are used within XMPP streams to 5276 create strict boundaries of data ownership. The basic function of 5277 namespaces is to separate different vocabularies of XML elements that 5278 are structurally mixed together. Ensuring that XMPP streams are 5279 namespace-aware enables any allowable XML to be structurally mixed 5280 with any data element within XMPP. XMPP-specific rules for XML 5281 namespace names and prefixes are defined in the following 5282 subsections. 5284 12.2.1. Streams Namespace 5286 A streams namespace declaration is REQUIRED in all XML stream headers 5287 and the name of the streams namespace MUST be 5288 'http://etherx.jabber.org/streams'. If this rule is violated, the 5289 entity that receives the offending stream header MUST return a stream 5290 error to the sending entity, which SHOULD be but 5291 MAY be . 5293 The element names of the element and its and 5294 children MUST be qualified by the streams namespace prefix 5295 in all instances. If this rule is violated, the entity that receives 5296 the offending element MUST return a stream error to the sending 5297 entity, which SHOULD be . 5299 An implementation SHOULD generate only the 'stream:' prefix for these 5300 elements, and for historical reasons MAY accept only the 'stream:' 5301 prefix. If an entity receives a stream header with a streams 5302 namespace prefix it does not accept, it MUST return a stream error to 5303 the sending entity, which SHOULD be but MAY 5304 be . 5306 12.2.2. Default Namespace 5308 A default namespace declaration is REQUIRED and defines the allowable 5309 first-level children of the root stream element. This namespace 5310 declaration MUST be the same for the initial stream and the response 5311 stream so that both streams are qualified consistently. The default 5312 namespace declaration applies to the stream and all first-level child 5313 element sent within a stream unless explicitly qualified by the 5314 streams namespace or another namespace. 5316 A server implementation MUST support the following two default 5317 namespaces: 5319 o jabber:client -- this default namespace is declared when the 5320 stream is used for communication between a client and a server 5321 o jabber:server -- this default namespace is declared when the 5322 stream is used for communication between two servers 5324 A client implementation MUST support the 'jabber:client' default 5325 namespace. 5327 If an implementation accepts a stream that is qualified by the 5328 'jabber:client' or 'jabber:server' namespace, it MUST support the 5329 common attributes (Section 9.1) and basic semantics (Section 9.2) of 5330 all three core stanza types (message, presence, and IQ). 5332 For historical reasons, an implementation MAY refuse to support any 5333 other default namespaces. If an entity receives a stream header with 5334 a default namespace it does not support, it MUST return an stream error. 5337 An implementation MUST NOT generate namespace prefixes for elements 5338 qualified by the default namespace if the default namespace is 5339 'jabber:client' or 'jabber:server'. 5341 Note: The 'jabber:client' and 'jabber:server' namespaces are 5342 nearly identical but are used in different contexts (client-to- 5343 server communication for 'jabber:client' and server-to-server 5344 communication for 'jabber:server'). The only difference between 5345 the two is that the 'to' and 'from' attributes are OPTIONAL on 5346 stanzas sent over XML streams qualified by the 'jabber:client' 5347 namespace, whereas they are REQUIRED on stanzas sent over XML 5348 streams qualified by the 'jabber:server' namespace. 5350 An implementation MAY support a default namespace other than "jabber: 5351 client" or "jabber:server". However, because such namespaces would 5352 define applications other than XMPP, they are to be defined in 5353 separate specifications. 5355 12.2.3. Extended Namespaces 5357 An EXTENDED NAMESPACE is an XML namespace that qualifies extended 5358 content as defined under Section 9.4. For example, in the following 5359 stanza, the extended namespace is 'jabber:iq:roster': 5361 5364 5365 5366 An XML stanza MAY contain XML data qualified by more than one 5367 extended namespace, either at the direct child level of the stanza 5368 (for presence and message stanzas) or in any mix of levels (for all 5369 stanzas). 5371 5372 5375 5376 sha1-hash-of-image 5377 5378 5380 5381 Hello? 5382 5383 5384

Hello? 5385 5386 5387 5389 5392 5393 5394

some-long-opaque-string
5395 5396 5397 5399 An implementation SHOULD NOT generate namespace prefixes for elements 5400 qualified by content (as opposed to stream) namespaces other than the 5401 default namespace. However, if included, the namespace declarations 5402 for those prefixes MUST be included on the stanza root or a child 5403 thereof, not at the level of the stream element (this helps to ensure 5404 that any such namespace declaration is routed and delivered with the 5405 stanza, instead of assumed from the stream). 5407 12.3. Well-Formedness 5409 There are two varieties of well-formedness: 5411 o "XML-well-formedness" in accordance with the definition of "well- 5412 formed" in Section 2.1 of [XML]. 5413 o "Namespace-well-formedness" in accordance with the definition of 5414 "namespace-well-formed" in Section 7 of [XML-NAMES]. 5416 The following rules apply. 5418 An XMPP entity MUST NOT generate data that is not XML-well-formed. 5419 An XMPP entity MUST NOT accept data that is not XML-well-formed; 5420 instead it MUST return an stream error and 5421 close the stream over which the data was received. 5423 An XMPP entity MUST NOT generate data that is not namespace-well- 5424 formed. An XMPP server SHOULD NOT route or deliver data that is not 5425 namespace-well-formed, and SHOULD return a stanza error of or a stream error of in response 5427 to the receipt of such data. 5429 Note: Because these restrictions were underspecified in an earlier 5430 revision of this specification, it is possible that 5431 implementations based on that revision will send data that does 5432 not comply with the restrictions; an entity SHOULD be liberal in 5433 accepting such data. 5435 12.4. Validation 5437 A server is not responsible for ensuring that XML data delivered to a 5438 client or routed to another server is valid, in accordance with the 5439 definition of "valid" provided in Section 2.8 of [XML]. An 5440 implementation MAY choose to accept or provide only validated data, 5441 but such behavior is OPTIONAL. A client SHOULD NOT rely on the 5442 ability to send data that does not conform to the schemas, and SHOULD 5443 ignore any non-conformant elements or attributes on the incoming XML 5444 stream. 5446 Note: The terms "valid" and "well-formed" are distinct in XML. 5448 12.5. Inclusion of Text Declaration 5450 Implementations SHOULD send a text declaration before sending a 5451 stream header. Applications MUST follow the rules provided in [XML] 5452 regarding the circumstances under which a text declaration is 5453 included. 5455 12.6. Character Encoding 5457 Implementations MUST support the UTF-8 transformation of Universal 5458 Character Set [UCS2] characters, as required by [CHARSET] and defined 5459 in [UTF-8]. Implementations MUST NOT attempt to use any other 5460 encoding. If one party to an XML stream detects that the other party 5461 has attempted to send XML data with an encoding other than UTF-8, it 5462 MUST return a stream error, which SHOULD be 5463 but MAY be . 5465 Note: Because it is mandatory for an XMPP implementation to support 5466 all and only the UTF-8 encoding and because UTF-8 always has the same 5467 byte order, an implementation MUST NOT send a byte order mark ("BOM") 5468 at the beginning of the data stream. If an entity receives the 5469 Unicode character U+FEFF anywhere in an XML stream (including as the 5470 first character of the stream), it MUST interpret that character as a 5471 zero width no-break space, not as a byte order mark. 5473 12.7. Whitespace 5475 Except where explicitly disallowed (e.g., during TLS negotiation 5476 (Section 6) and SASL negotiation (Section 7)), either entity MAY send 5477 whitespace within the root stream element as separators between XML 5478 stanzas or between any other first-level elements sent over the 5479 stream. One common use for sending such whitespace is explained 5480 under Section 5.7.3. 5482 12.8. XML Versions 5484 XMPP is an application profile of XML 1.0. A future version of XMPP 5485 might be defined in terms of higher versions of XML, but this 5486 specification addresses XML 1.0 only. 5488 13. Compliance Requirements 5490 This section summarizes the specific aspects of the Extensible 5491 Messaging and Presence Protocol that MUST be supported by servers and 5492 clients in order to be considered compliant implementations, as well 5493 as additional protocol aspects that SHOULD be supported. For 5494 compliance purposes, we draw a distinction between core protocols 5495 (which MUST be supported by any server or client, regardless of the 5496 specific application) and instant messaging and presence protocols 5497 (which MUST be supported only by instant messaging and presence 5498 applications built on top of the core protocols). Compliance 5499 requirements that apply to all servers and clients are specified in 5500 this section; compliance requirements for instant messaging and 5501 presence applications are specified in the corresponding section of 5502 [xmpp-im]. 5504 13.1. Servers 5506 A server MUST support the following core protocols in order to be 5507 considered compliant: 5509 o Conformance with [IDNA] for domain identifiers, the Nodeprep 5510 (Appendix A) profile of [STRINGPREP] for node identifiers, and the 5511 Resourceprep (Appendix B) profile of [STRINGPREP] for resource 5512 identifiers, as well as enforcement thereof for clients that 5513 authenticate with the server 5514 o XML streams (Section 5), including TLS negotiation (Section 6), 5515 SASL negotiation (Section 7), stream features (Section 5.5), and 5516 Resource Binding (Section 8) 5517 o The basic semantics of the three defined stanza types (i.e., 5518 , , and ) 5519 o Generation (and, where appropriate, handling) of error syntax and 5520 semantics related to streams, TLS, SASL, and XML stanzas 5522 For backward compatibility with the large deployed base of XMPP 5523 servers, server developers are advised to implement the server 5524 dialback protocol first specified in [RFC3920] and now documented in 5525 [XEP-0220], since that protocol is widely used for weak identity 5526 verification of peer servers in the absence of domain certificates. 5528 13.2. Clients 5530 A client MUST support the following core protocols in order to be 5531 considered compliant: 5533 o XML streams (Section 5), including TLS negotiation (Section 6), 5534 SASL negotiation (Section 7), stream features (Section 5.5), and 5535 Resource Binding (Section 8) 5536 o The basic semantics of the three defined stanza types (i.e., 5537 , , and ) 5538 o Handling (and, where appropriate, generation) of error syntax and 5539 semantics related to streams, TLS, SASL, and XML stanzas 5541 In addition, a client SHOULD support the following core protocols: 5543 o Conformance with [IDNA] for domain identifiers, the Nodeprep 5544 (Appendix A) profile of [STRINGPREP] for node identifiers, and the 5545 Resourceprep (Appendix B) profile of [STRINGPREP] for resource 5546 identifiers. 5548 14. Internationalization Considerations 5550 As specified under Section 12.6, XML streams MUST be encoded in 5551 UTF-8. 5553 As specified under Section 5.3, an XML stream SHOULD include an 'xml: 5554 lang' attribute specifying the default language for any XML character 5555 data that is intended to be presented to a human user. As specified 5556 under Section 9.1.5, an XML stanza SHOULD include an 'xml:lang' 5557 attribute if the stanza contains XML character data that is intended 5558 to be presented to a human user. A server SHOULD apply the default 5559 'xml:lang' attribute to stanzas it routes or delivers on behalf of 5560 connected entities, and MUST NOT modify or delete 'xml:lang' 5561 attributes on stanzas it receives from other entities. 5563 As specified under Section 3, a server MUST support and enforce 5564 [IDNA] for domain identifiers, the Nodeprep (Appendix A) profile of 5565 [STRINGPREP] for node identifiers, and the Resourceprep (Appendix B) 5566 profile of [STRINGPREP] for resource identifiers; this enables XMPP 5567 addresses to include a wide variety of Unicode characters outside the 5568 US-ASCII range. 5570 15. Security Considerations 5572 15.1. High Security 5574 For the purposes of XMPP communication (client-to-server and server- 5575 to-server), the term "high security" refers to the use of security 5576 technologies that provide both mutual authentication and integrity 5577 checking; in particular, when using certificate-based authentication 5578 to provide high security, a chain-of-trust SHOULD be established out- 5579 of-band, although a shared certification authority signing 5580 certificates could allow a previously unknown certificate to 5581 establish trust in-band. See Section 15.2 regarding certificate 5582 validation procedures. 5584 Implementations MUST support high security. Service provisioning 5585 SHOULD use high security, subject to local security policies. 5587 15.2. Certificates 5589 Channel encryption of an XML stream using Transport Layer Security as 5590 described under Section 6, and in some cases also authentication as 5591 described under Section 7, is commonly based on a digital certificate 5592 presented by the receiving entity (or, in the case of mutual 5593 authentication, both the receiving entity and the initiating entity). 5594 This section describes best practices regarding the generation of 5595 digital certificates to be presented by XMPP entities and the 5596 verification of digital certificates presented by XMPP entities. 5598 For both client and server certificates, a certificate MUST conform 5599 to the format defined in [X509]. Considerations specific to client 5600 certificates or server certificates are described in the following 5601 sections. 5603 15.2.1. Certificate Generation 5605 15.2.1.1. Server Certificates 5607 In a digital certificate to be presented by an XMPP server (i.e., a 5608 SERVER CERTIFICATE), it is RECOMMENDED for the certificate to include 5609 one or more JIDs (i.e., domain identifiers) associated with domains 5610 serviced at the server. The representations described in the 5611 following sections are RECOMMENDED. These representations are 5612 provided in preference order. 5614 15.2.1.1.1. SRVName 5616 A server's domain identifier SHOULD be represented as an SRVName, 5617 i.e., as an otherName field of type "id-on-dnsSRV" as specified in 5618 [X509-SRV]. 5620 15.2.1.1.2. dNSName 5622 A server's domain identifier SHOULD be represented as a dNSName, 5623 i.e., as a subjectAltName extension of type dNSName. 5625 The dNSName MAY contain the wildcard character '*'. The wildcard 5626 character applies only to the left-most domain name component or 5627 component fragment and matches any single component or component 5628 fragment. For instance, a dNSName of *.example.com matches 5629 foo.example.com but not bar.foo.example.com or example.com itself; 5630 similarly, a dNSName of im*.example.net matches im1.example.net and 5631 im2.example.net but not chat.example.net or example.net itself. 5633 15.2.1.1.3. XmppAddr 5635 A server's domain identifier MAY be represented as an XmppAddr, i.e., 5636 as a UTF8String within an otherName entity inside the subjectAltName, 5637 using the [ASN.1] Object Identifier "id-on-xmppAddr" specified under 5638 Section 15.2.1.3. In server certificates, this representation is 5639 included only for the sake of backward-compatibility. 5641 15.2.1.1.4. Common Name 5643 A server's domain identifier SHOULD NOT be represented as a Common 5644 Name; instead, the Common Name field SHOULD be reserved for 5645 representation of a human-friendly name. 5647 15.2.1.1.5. Examples 5649 For our first (relatively simple) example, consider a company called 5650 "Example Products, Inc." It hosts an XMPP service at 5651 "im.example.com" (i.e., user addresses at the service are of the form 5652 "user@im.example.com"), and SRV lookups for the xmpp-client and xmpp- 5653 server services at "im.example.com" yield one machine, called 5654 "x.example.com", as follows: 5656 _xmpp-client._tcp.im.example.com. 400 IN SRV 20 0 5222 x.example.com 5657 _xmpp-server._tcp.im.example.com. 400 IN SRV 20 0 5269 x.example.com 5659 The certificate presented by x.example.com contains the following 5660 representations: 5662 o An otherName type of SRVName (id-on-dnsSRV) containing an 5663 IA5String (ASCII) string of: "_xmpp-client.im.example.com" 5664 o An otherName type of SRVName (id-on-dnsSRV) containing an 5665 IA5String (ASCII) string of: "_xmpp-server.im.example.com" 5666 o A dNSName containing an ASCII string of "im.example.com" 5667 o An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 5668 string of: "im.example.com" 5669 o A CN containing an ASCII string of "Example Products, Inc." 5671 For our second (more complex) example, consider an ISP called 5672 "Example Internet Services". It hosts an XMPP service at 5673 "example.net" (i.e., user addresses at the service are of the form 5674 "user@example.net"), but SRV lookups for the xmpp-client and xmpp- 5675 server services at "example.net" yield two machines ("x1.example.net" 5676 and "x2.example.net"), as follows: 5678 _xmpp-client._tcp.example.net. 68400 IN SRV 20 0 5222 x1.example.net. 5679 _xmpp-client._tcp.example.net. 68400 IN SRV 20 0 5222 x2.example.net. 5680 _xmpp-server._tcp.example.net. 68400 IN SRV 20 0 5269 x1.example.net. 5681 _xmpp-server._tcp.example.net. 68400 IN SRV 20 0 5269 x2.example.net. 5683 Example Internet Services also hosts chatrooms at chat.example.net, 5684 and provides an xmpp-server SRV record for that service as well (thus 5685 enabling entity from foreign domains to access that service). It 5686 also might provide other such services in the future, so it wishes to 5687 represent a wildcard in its certificate to handle such growth. 5689 The certificate presented by either x1.example.net or x2.example.net 5690 contains the following representations: 5692 o An otherName type of SRVName (id-on-dnsSRV) containing an 5693 IA5String (ASCII) string of: "_xmpp-client.example.net" 5695 o An otherName type of SRVName (id-on-dnsSRV) containing an 5696 IA5String (ASCII) string of: "_xmpp-server.example.net" 5697 o An otherName type of SRVName (id-on-dnsSRV) containing an 5698 IA5String (ASCII) string of: "_xmpp-server.chat.example.net" 5699 o A dNSName containing an ASCII string of "example.net" 5700 o A dNSName containing an ASCII string of "*.example.net" 5701 o An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 5702 string of: "example.net" 5703 o An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 5704 string of: "chat.example.net" 5705 o A CN containing an ASCII string of "Example Internet Services" 5707 15.2.1.2. Client Certificates 5709 In a digital certificate to be presented by an XMPP client controlled 5710 by a human user (i.e., a CLIENT CERTIFICATE), it is RECOMMENDED for 5711 the certificate to include one or more JIDs associated with an XMPP 5712 user. If included, a JID MUST be represented as an XmppAddr, i.e., 5713 as a UTF8String within an otherName entity inside the subjectAltName, 5714 using the [ASN.1] Object Identifier "id-on-xmppAddr" specified under 5715 Section 15.2.1.3. 5717 15.2.1.3. ASN.1 Object Identifier 5719 The [ASN.1] Object Identifier "id-on-xmppAddr" (also called an 5720 XmppAddr) is defined as follows. 5722 id-pkix OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) 5723 dod(6) internet(1) security(5) mechanisms(5) pkix(7) } 5725 id-on OBJECT IDENTIFIER ::= { id-pkix 8 } -- other name forms 5727 id-on-xmppAddr OBJECT IDENTIFIER ::= { id-on 5 } 5729 XmppAddr ::= UTF8String 5731 As an alternative to the "id-on-xmppAddr" notation, this Object 5732 Identifier MAY be represented in dotted display format (i.e., 5733 "1.3.6.1.5.5.7.8.5") or in the Uniform Resource Name notation 5734 specified in [URN-OID] (i.e., "urn:oid:1.3.6.1.5.5.7.8.5"). 5736 Thus for example the JID "juliet@im.example.com" as included in a 5737 certificate could be formatted in any of the following three ways: 5739 id-on-xmppAddr: 5740 subjectAltName=otherName:id-on-xmppAddr;UTF8:juliet@im.example.com 5741 dotted display format: subjectAltName=otherName: 5742 1.3.6.1.5.5.7.8.5;UTF8:juliet@im.example.com 5743 URN notation: subjectAltName=otherName:urn:oid: 5744 1.3.6.1.5.5.7.8.5;UTF8:juliet@im.example.com 5746 Use of the "id-on-xmppAddr" format is RECOMMENDED in the generation 5747 of certificates, but all three formats MUST be supported for the 5748 purpose of certificate validation. 5750 The "id-on-xmppAddr" object identifier MAY be used on conjuction with 5751 the extended key usage extension specified in Section 4.2.1.12 of 5752 [X509] in order to explicitly define and limit the intended use of a 5753 certificate to the XMPP network. 5755 15.2.2. Certificate Validation 5757 When an XMPP entity is presented with a server certificate or client 5758 certificate by a peer for the purpose of encryption or authentication 5759 of XML streams as described under Section 6 and Section 7, the entity 5760 MUST validate the certificate to determine if the certificate shall 5761 be considered a TRUSTED CERTIFICATE, i.e., a certificate that is 5762 acceptable for encryption and/or authentication in accordance with 5763 the XMPP entity's local service policies or configured settings. 5765 For both server certificates and client certificates, the validating 5766 entity MUST verify the integrity of the certificate, MUST verify that 5767 the certificate has been properly signed by the issuing Certificate 5768 Authority, and MUST support certificate revocation messages. An 5769 implementation MUST enable a human user to view information about the 5770 full chain of certificates. 5772 The following sections describe certificate validation rules for 5773 server-to-server and client-to-server streams. 5775 15.2.2.1. Server-to-Server Streams 5777 When an XMPP entity (client or server) validates a certificate 5778 presented by an XMPP server, there are three possible cases, as 5779 discussed in the following sections. 5781 15.2.2.1.1. Case #1 5783 If the server certificate appears to be certified by a chain of 5784 certificates terminating in a trust anchor (as described in Section 5785 6.1 of [X509]), the entity MUST check the certificate for any 5786 instances of the SRVName, dNSName, and XmppAddr (in that order of 5787 preference) as described under Section 15.2.1.1.1, 5788 Section 15.2.1.1.2, and Section 15.2.1.1.3. There are three possible 5789 sub-cases: 5791 Sub-Case #1: The entity finds at least one SRVName, dNSName, or 5792 XmppAddr that matches the hostname to which it attempted to 5793 connect; the entity MUST use this represented domain identifier as 5794 the validated identity of the XMPP server. The server certificate 5795 MUST be checked against the hostname as provided by the entity 5796 (client or server), not the hostname as resolved via the Domain 5797 Name System; e.g., if a user specifies a hostname of "example.net" 5798 but a [DNS-SRV] lookup returns "x1.example.net", the certificate 5799 MUST be checked as "example.net". A user-oriented client MAY 5800 provide a configuration setting that enables a human user to 5801 explicitly specify a hostname to be checked for connection 5802 purposes. 5803 Sub-Case #2: The entity finds no SRVName, dNSName, or XmppAddr that 5804 matches the hostname to which it attempted to connect and a human 5805 user has not permanently accepted the certificate during a 5806 previous connection attempt; the entity MUST NOT use the 5807 represented domain identifier (if any) as the validated identity 5808 of the XMPP server. Instead, if the connecting entity is a user- 5809 oriented client then it MUST either (1) automatically terminate 5810 the connection with a bad certificate error or (2) show the 5811 certificate (including the entire certificate chain) to the user 5812 and give the user the choice of terminating the connecting or 5813 accepting the certificate temporarily (i.e., for this connection 5814 attempt only) or permanently (i.e., for all future connection 5815 attempts) and then continuing with the connection; if a user 5816 permanently accepts a certificate in this way, the client MUST 5817 cache the certificate (or some non-forgeable representation such 5818 as a hash) and in future connection attempts behave as in Sub-Case 5819 #3. (It is the resposibility of the human user to verify the hash 5820 or fingerprint of the certificate with the peer over a trusted 5821 communication layer.) If the connecting entity is an XMPP server 5822 or an automated client, the application SHOULD terminate the 5823 connection (with a bad certificate error) and log the error to an 5824 appropriate audit log; an XMPP server or automated client MAY 5825 provide a configuration setting that disables this check, but MUST 5826 provide a setting that enables the check. 5827 Sub-Case #3: The entity finds no SRVName, dNSName, or XmppAddr that 5828 matches the hostname to which it attempted to connect but a human 5829 user has permanently accepted the certificate during a previous 5830 connection attempt; the entity MUST verify that the cached 5831 certificate was presented and MUST notify the user if the 5832 certificate has changed. 5834 15.2.2.1.2. Case #2 5836 If the server certificate is certified by a Certificate Authority not 5837 known to the entity, the entity MUST proceed as under Case #1, Sub- 5838 Case #2 or Case #1, Sub-Case #3 as appropriate. 5840 15.2.2.1.3. Case #3 5842 If the server certificate is self-signed, the entity MUST proceed as 5843 under Case #1, Sub-Case #2 or Case #1, Sub-Case #3 as appropriate. 5845 15.2.2.2. Client-to-Server Streams 5847 When an XMPP server validates a certificate presented by a client, 5848 there are three possible cases, as discussed in the following 5849 sections. 5851 15.2.2.2.1. Case #1 5853 If the client certificate appears to be certified by a chain of 5854 certificates terminating in a trust anchor (as described in Section 5855 6.1 of [X509]), the server MUST check the certificate for any 5856 instances of the XmppAddr as described under Section 15.2.1.3. There 5857 are three possible sub-cases: 5859 Sub-Case #1: The server finds one XmppAddr for which the domain 5860 identifier portion of the represented JID matches one of the 5861 configured hostnames of the server itself; the server SHOULD use 5862 this represented JID as the validated identity of the client. 5863 Sub-Case #2: The server finds more than one XmppAddr for which the 5864 domain identifier portion of the represented JID matches one of 5865 the configured hostnames of the server itself; the server SHOULD 5866 use one of these represented JIDs as the validated identity of the 5867 client, choosing among them according to local service policies or 5868 based on the 'to' address of the initial stream header. 5869 Sub-Case #3: The server finds no XmppAddrs, or finds at least one 5870 XmppAddr but the domain identifier portion of the represented JID 5871 does not match one of the configured hostnames of the server 5872 itself; the server MUST NOT use the represented JID (if any) as 5873 the validated identity of the client but instead MUST either 5874 validate the identity of the client using other means. 5876 15.2.2.2.2. Case #2 5878 If the client certificate is certified by a Certificate Authority not 5879 known to the server, the server MUST proceed as under Case #1, Sub- 5880 Case #3. 5882 15.2.2.2.3. Case #3 5884 If the client certificate is self-signed, the server MUST proceed as 5885 under Case #1, Sub-Case #3. 5887 15.2.2.3. Use of Certificates in XMPP Extensions 5889 Certificates MAY be used in extensions to XMPP for the purpose of 5890 application-layer encryption or authentication above the level of XML 5891 streams (e.g., for end-to-end encryption). Such extensions shall 5892 define their own certificate handling rules, which at a minimum 5893 SHOULD be consistent with the rules specified herein but MAY specify 5894 additional rules. 5896 15.3. Client-to-Server Communication 5898 A compliant client implementation MUST support both TLS and SASL for 5899 connections to a server. 5901 The TLS protocol for encrypting XML streams (defined under Section 6) 5902 provides a reliable mechanism for helping to ensure the 5903 confidentiality and data integrity of data exchanged between two 5904 entities. 5906 The SASL protocol for authenticating XML streams (defined under 5907 Section 7) provides a reliable mechanism for validating that a client 5908 connecting to a server is who it claims to be. 5910 Client-to-server communication MUST NOT proceed until the DNS 5911 hostname asserted by the server has been resolved as specified under 5912 Section 4. If there is a mismatch between the hostname to which a 5913 client attempted to connect (e.g., "example.net") and the hostname to 5914 which the client actually connects (e.g., "x1.example.net"), the 5915 client MUST warn a human user about the mismatch and the human user 5916 MUST approve the connection before the client proceeds; however, the 5917 client MAY also allow the user to add the presented hostname to a 5918 configured set of accepted hostnames to expedite future connections. 5920 A client's IP address and method of access MUST NOT be made public by 5921 a server, nor are any connections other than the original server 5922 connection required. This helps to protect the client's server from 5923 direct attack or identification by third parties. 5925 15.4. Server-to-Server Communication 5927 A compliant server implementation MUST support both TLS and SASL for 5928 inter-domain communication. 5930 Because service provisioning is a matter of policy, it is optional 5931 for any given domain to communicate with other domains, and server- 5932 to-server communication can be disabled by the administrator of any 5933 given deployment. If a particular domain enables inter-domain 5934 communication, it SHOULD enable high security. 5936 Administrators might want to require use of SASL for server-to-server 5937 communication to ensure both authentication and confidentiality 5938 (e.g., on an organization's private network). Compliant 5939 implementations SHOULD support SASL for this purpose. 5941 Server-to-server communication MUST NOT proceed until the DNS 5942 hostnames asserted by both servers have been resolved as specified 5943 under Section 4. 5945 15.5. Order of Layers 5947 The order of layers in which protocols MUST be stacked is: 5949 1. TCP 5950 2. TLS 5951 3. SASL 5952 4. XMPP 5954 The rationale for this order is that [TCP] is the base connection 5955 layer used by all of the protocols stacked on top of TCP, [TLS] is 5956 often provided at the operating system layer, [SASL] is often 5957 provided at the application layer, and XMPP is the application 5958 itself. 5960 15.6. Mandatory-to-Implement Technologies 5962 At a minimum, all implementations MUST support the following 5963 mechanisms: 5965 for confidentiality only: TLS (using the 5966 TLS_RSA_WITH_AES_128_CBC_SHA cipher) 5967 for both confidentiality and authentication: TLS plus the SASL PLAIN 5968 mechanism (See [PLAIN]) for password-based authentication and TLS 5969 plus the SASL EXTERNAL mechanism (see Appendix A of [SASL]) for 5970 non-password-based authentication (using the 5971 TLS_RSA_WITH_AES_128_CBC_SHA cipher supporting peer certificates) 5973 Naturally, implementations MAY support other ciphers with TLS and MAY 5974 support other SASL mechanisms. 5976 Note: The use of TLS plus SASL PLAIN replaces the SASL DIGEST-MD5 5977 mechanism as XMPP's mandatory-to-implement password-based method 5978 for authentication. For backward-compatibility, implementations 5979 are encouraged to continue supporting the SASL DIGEST-MD5 5980 mechanism as specified in [DIGEST-MD5]. Refer to [PLAIN] for 5981 important security considerations related to the SASL PLAIN 5982 mechanism. 5984 15.7. SASL Downgrade Attacks 5986 Because the initiating entity chooses an acceptable SASL mechanism 5987 from the list presented by the receiving entity, the initiating 5988 entity depends on the receiving entity's list for authentication. 5989 This dependency introduces the possibility of a downgrade attack if 5990 an attacker can gain control of the channel and therefore present a 5991 weak list of mechanisms. To prevent this attack, the parties SHOULD 5992 protect the channel using TLS before attempting SASL negotiation. 5994 15.8. Lack of SASL Channel Binding to TLS 5996 The SASL framework itself does not provide a method for binding SASL 5997 authentication to a security layer providing confidentiality and 5998 integrity protection that was negotiated at a lower layer. Such a 5999 binding is known as a "channel binding" (see [CHANNEL]). Some SASL 6000 mechanisms provide channel bindings. However, if a SASL mechanism 6001 does not provide a channel binding, then the mechanism cannot provide 6002 a way to verify that the source and destination end points to which 6003 the lower layer's security is bound are equivalent to the end points 6004 that SASL is authenticating; furthermore, if the end points are not 6005 identical, then the lower layer's security cannot be trusted to 6006 protect data transmitted between the SASL-authenticated entities. In 6007 such a situation, a SASL security layer SHOULD be negotiated that 6008 effectively ignores the presence of the lower-layer security. 6010 15.9. Use of base64 in SASL 6012 Both the client and the server MUST verify any base64 data received 6013 during SASL negotiation (Section 7). An implementation MUST reject 6014 (not ignore) any characters that are not explicitly allowed by the 6015 base64 alphabet; this helps to guard against creation of a covert 6016 channel that could be used to "leak" information. 6018 An implementation MUST NOT break on invalid input and MUST reject any 6019 sequence of base64 characters containing the pad ('=') character if 6020 that character is included as something other than the last character 6021 of the data (e.g., "=AAA" or "BBBB=CCC"); this helps to guard against 6022 buffer overflow attacks and other attacks on the implementation. 6024 While base 64 encoding visually hides otherwise easily recognized 6025 information (such as passwords), it does not provide any 6026 computational confidentiality. 6028 All uses of base 64 encoding MUST follow the definition in Section 4 6029 of [BASE64] and padding bits MUST be set to zero. 6031 15.10. Stringprep Profiles 6033 XMPP makes use of the [NAMEPREP] profile of [STRINGPREP] for 6034 processing of domain identifiers; for security considerations related 6035 to Nameprep, refer to the appropriate section of [NAMEPREP]. 6037 In addition, XMPP defines two profiles of [STRINGPREP]: Nodeprep 6038 (Appendix A) for node identifiers and Resourceprep (Appendix B) for 6039 resource identifiers. 6041 The Unicode and ISO/IEC 10646 repertoires have many characters that 6042 look similar. In many cases, users of security protocols might 6043 perform visual matching, such as when comparing the names of trusted 6044 third parties. Because it is impossible to map similar-looking 6045 characters without a great deal of context (such as knowing the fonts 6046 used), stringprep does nothing to map similar-looking characters 6047 together, nor to prohibit some characters because they look like 6048 others. 6050 A node identifier can be employed as one part of an entity's address 6051 in XMPP. One common usage is as the username of an instant messaging 6052 user; another is as the name of a multi-user conference room; and 6053 many other kinds of entities could use node identifiers as part of 6054 their addresses. The security of such services could be compromised 6055 based on different interpretations of the internationalized node 6056 identifier; for example, a user entering a single internationalized 6057 node identifier could access another user's account information, or a 6058 user could gain access to a hidden or otherwise restricted chat room 6059 or service. 6061 A resource identifier can be employed as one part of an entity's 6062 address in XMPP. One common usage is as the name for an instant 6063 messaging user's connected resource; another is as the nickname of a 6064 user in a multi-user conference room; and many other kinds of 6065 entities could use resource identifiers as part of their addresses. 6066 The security of such services could be compromised based on different 6067 interpretations of the internationalized resource identifier; for 6068 example, a user could attempt to initiate multiple connections with 6069 the same name, or a user could send a message to someone other than 6070 the intended recipient in a multi-user conference room. 6072 15.11. Address Spoofing 6074 As discussed in [XEP-0165], there are two forms of address spoofing: 6075 forging and mimicking. 6077 15.11.1. Address Forging 6079 In the context of XMPP technologies, address forging occurs when an 6080 entity is able to generate an XML stanza whose 'from' address does 6081 not correspond to the account credentials with which the entity 6082 authenticated onto the network (or an authorization identity provided 6083 during SASL negotiation (Section 7)). For example, address forging 6084 occurs if an entity that authenticated as "juliet@im.example.com" is 6085 able to send XML stanzas from "nurse@im.example.com" or 6086 "romeo@example.net". 6088 Address forging is difficult in XMPP systems, given the requirement 6089 for sending servers to stamp 'from' addresses and for receiving 6090 servers to verify sending domains via server-to-server 6091 authentication. However, address forging is not impossible, since a 6092 rogue server could forge JIDs at the sending domain by ignoring the 6093 stamping requirement. A rogue server could even forge JIDs at other 6094 domains by means of a DNS poisoning attack if [DNSSEC] is not used. 6095 This specification does not define methods for discovering or 6096 counteracting such rogue servers. 6098 15.11.2. Address Mimicking 6100 Address mimicking occus when an entity provides legitimate 6101 authentication credentials for and sends XML stanzas from an account 6102 whose JID appears to a human user to be the same as another JID. For 6103 example, in some XMPP clients the address "paypa1@example.org" 6104 (spelled with the number one as the final character of the node 6105 identifier) might appear to be the same as "paypal@example.org 6106 (spelled with the lower-case version of the letter "L"), especially 6107 on casual visual inspection; this phenomenon is sometimes called 6108 "typejacking". A more sophisticated example of address mimicking 6109 might involve the use of characters from outside the US-ASCII range, 6110 such as the Cherokee characters U+13DA U+13A2 U+13B5 U+13AC U+13A2 6111 U+13AC U+13D2 instead of the US-ASCII characters "STPETER". 6113 In some examples of address mimicking, it is unlikely that the 6114 average user could tell the difference between the real JID and the 6115 fake JID. (Naturally, there is no way to distinguish with full 6116 certainty which is the fake JID and which is the real JID; in some 6117 communication contexts, the JID with Cherokee characters might be the 6118 real JID and the JID with US-ASCII characters might thus appear to be 6119 the fake JID.) Because JIDs can contain almost any Unicode 6120 character, it can be relatively easy to mimic some JIDs in XMPP 6121 systems. The possibility of address mimicking introduces security 6122 vulnerabilities of the kind that have also plagued the World Wide 6123 Web, specifically the phenomenon known as phishing. 6125 Mimicked addresses that involve characters from only one character 6126 set or from the character set typically employed by a particular user 6127 are not easy to combat (e.g., the simple typejacking attack 6128 previously described, which relies on a surface similarity between 6129 the characters "1" and "l" in some presentations). However, mimicked 6130 addresses that involve characters from more than one character set, 6131 or from a character set not typically employed by a particular user, 6132 can be mitigated somewhat through intelligent presentation. In 6133 particular, every human user of an XMPP technology presumably has a 6134 preferred language (or, in some cases, a small set of preferred 6135 languages), which an XMPP application SHOULD gather either explicitly 6136 from the user or implicitly via the operating system of the user's 6137 device. Furthermore, every language has a range (or a small set of 6138 ranges) of characters normally used to represent that language in 6139 textual form. Therefore, an XMPP application SHOULD warn the user 6140 when presenting a JID that uses characters outside the normal range 6141 of the user's preferred language(s). This recommendation is not 6142 intended to discourage communication across language communities; 6143 instead, it recognizes the existence of such language communities and 6144 encourages due caution when presenting unfamiliar character sets to 6145 human users. 6147 For more detailed recommendations regarding prevention of address 6148 mimicking in XMPP systems, refer to [XEP-0165]. 6150 15.12. Firewalls 6152 Communication using XMPP normally occurs over TCP connections on port 6153 5222 (client-to-server) or port 5269 (server-to-server), as 6154 registered with the IANA (see Section 16). Use of these well-known 6155 ports allows administrators to easily enable or disable XMPP activity 6156 through existing and commonly-deployed firewalls. 6158 15.13. Denial of Service 6160 [DOS] defines denial of service as follows: 6162 A Denial-of-Service (DoS) attack is an attack in which one or more 6163 machines target a victim and attempt to prevent the victim from 6164 doing useful work. The victim can be a network server, client or 6165 router, a network link or an entire network, an individual 6166 Internet user or a company doing business using the Internet, an 6167 Internet Service Provider (ISP), country, or any combination of or 6168 variant on these. 6170 [XEP-0205] provides a detailed discussion of potential denial of 6171 service attacks against XMPP systems and best practices for 6172 preventing such attacks. The recommendations include: 6174 1. A server implementation SHOULD enable a server administrator to 6175 limit the number of TCP connections that it will accept from a 6176 given IP address at any one time. If an entity attempts to 6177 connect but the maximum number of TCP connections has been 6178 reached, the receiving server MUST NOT allow the new connection 6179 to proceed. 6180 2. A server implementation SHOULD enable a server administrator to 6181 limit the number of TCP connection attempts that it will accept 6182 from a given IP address in a given time period. (While it is 6183 possible to limit the number of connections at the TCP layer 6184 rather than at the XMPP application layer, this is not advisable 6185 because limits at the TCP layer might result in an inability to 6186 access non-XMPP services.) If an entity attempts to connect but 6187 the maximum number of connections has been reached, the receiving 6188 server MUST NOT allow the new connection to proceed. 6189 3. A server MUST NOT process XML stanzas from clients that have not 6190 yet provided appropriate authentication credentials and MUST NOT 6191 process XML stanzas from peer servers whose identity it has not 6192 either authenticated via SASL or weakly verified via server 6193 dialback (see [XEP-0220]). 6194 4. A server implementation SHOULD enable a server administrator to 6195 limit the number of connected resources it will allow an account 6196 to bind at any one time. If a client attempts to bind a resource 6197 but it has already reached the configured number of allowable 6198 resources, the receiving server MUST return a stanza error. 6200 5. A server implementation SHOULD enable a server administrator to 6201 limit the size of stanzas it will accept from a connected client 6202 or peer server. If a connected resource or peer server sends a 6203 stanza that violates the upper limit, the receiving server SHOULD 6204 NOT process the stanza and instead SHOULD return a 6205 stanza error. Alternatively (e.g., if the sender has sent an 6206 egregiously large stanza), the server MAY instead return a 6207 stream error. 6208 6. A server implementation SHOULD enable a server administrator to 6209 limit the number of XML stanzas that a connected client is 6210 allowed to send to distinct recipients within a given time 6211 period. If a connected client sends too many stanzas to distinct 6212 recipients in a given time period, the receiving server SHOULD 6213 NOT process the stanza and instead SHOULD return an stanza error. 6216 7. A server implementation SHOULD enable a server administrator to 6217 limit the amount of bandwidth it will allow a connected client or 6218 peer server to use in a given time period. 6219 8. A server implementation MAY enable a server administrator to 6220 limit the types of stanzas (based on the extended content 6221 "payload") that it will allow a connected resource or peer server 6222 send over an active connection. Such limits and restrictions are 6223 a matter of deployment policy. 6224 9. A server implementation MAY refuse to route or deliver any stanza 6225 that it considers to be abusive, with or without returning an 6226 error to the sender. 6228 For more detailed recommendations regarding denial of service attacks 6229 in XMPP systems, refer to [XEP-0205]. 6231 15.14. Presence Leaks 6233 One of the core aspects of XMPP is presence: information about the 6234 network availability of an XMPP entity (i.e., whether the entity is 6235 currently online or offline). A PRESENCE LEAK occurs when an 6236 entity's network availability is inadvertently and involuntarily 6237 revealed to a second entity that is not authorized to know the first 6238 entity's network availability. 6240 Although presence is discussed more fully in [xmpp-im], it is 6241 important to note that an XMPP server MUST NOT leak presence. In 6242 particular at the core XMPP level, real-time addressing and network 6243 availability is associated with a specific connected resource; 6244 therefore, any disclosure of a connected resource's full JID 6245 comprises a presence leak. To help prevent such a presence leak, a 6246 server MUST NOT return different stanza errors if a potential 6247 attacker sends XML stanzas to the entity's bare JID () 6248 or full JID (). 6250 15.15. Directory Harvesting 6252 To help prevent directory harvesting attacks, a server MUST NOT 6253 return different stanza errors if a potential attacker sends XML 6254 stanzas to an existing entity or a nonexistent entity. 6256 16. IANA Considerations 6258 The following sections update the registrations provided in 6259 [RFC3920]. 6261 16.1. XML Namespace Name for TLS Data 6263 A URN sub-namespace for STARTTLS negotiation data in the Extensible 6264 Messaging and Presence Protocol (XMPP) is defined as follows. (This 6265 namespace name adheres to the format defined in [XML-REG].) 6267 URI: urn:ietf:params:xml:ns:xmpp-tls 6268 Specification: XXXX 6269 Description: This is the XML namespace name for STARTTLS negotiation 6270 data in the Extensible Messaging and Presence Protocol (XMPP) as 6271 defined by XXXX. 6272 Registrant Contact: IETF, XMPP Working Group, 6274 16.2. XML Namespace Name for SASL Data 6276 A URN sub-namespace for SASL negotiation data in the Extensible 6277 Messaging and Presence Protocol (XMPP) is defined as follows. (This 6278 namespace name adheres to the format defined in [XML-REG].) 6280 URI: urn:ietf:params:xml:ns:xmpp-sasl 6281 Specification: XXXX 6282 Description: This is the XML namespace name for SASL negotiation 6283 data in the Extensible Messaging and Presence Protocol (XMPP) as 6284 defined by XXXX. 6285 Registrant Contact: IETF, XMPP Working Group, 6287 16.3. XML Namespace Name for Stream Errors 6289 A URN sub-namespace for stream error data in the Extensible Messaging 6290 and Presence Protocol (XMPP) is defined as follows. (This namespace 6291 name adheres to the format defined in [XML-REG].) 6293 URI: urn:ietf:params:xml:ns:xmpp-streams 6294 Specification: XXXX 6295 Description: This is the XML namespace name for stream error data in 6296 the Extensible Messaging and Presence Protocol (XMPP) as defined 6297 by XXXX. 6298 Registrant Contact: IETF, XMPP Working Group, 6300 16.4. XML Namespace Name for Resource Binding 6302 A URN sub-namespace for resource binding in the Extensible Messaging 6303 and Presence Protocol (XMPP) is defined as follows. (This namespace 6304 name adheres to the format defined in [XML-REG].) 6305 URI: urn:ietf:params:xml:ns:xmpp-bind 6306 Specification: XXXX 6307 Description: This is the XML namespace name for resource binding in 6308 the Extensible Messaging and Presence Protocol (XMPP) as defined 6309 by XXXX. 6310 Registrant Contact: IETF, XMPP Working Group, 6312 16.5. XML Namespace Name for Stanza Errors 6314 A URN sub-namespace for stanza error data in the Extensible Messaging 6315 and Presence Protocol (XMPP) is defined as follows. (This namespace 6316 name adheres to the format defined in [XML-REG].) 6318 URI: urn:ietf:params:xml:ns:xmpp-stanzas 6319 Specification: XXXX 6320 Description: This is the XML namespace name for stanza error data in 6321 the Extensible Messaging and Presence Protocol (XMPP) as defined 6322 by XXXX. 6323 Registrant Contact: IETF, XMPP Working Group, 6325 16.6. Nodeprep Profile of Stringprep 6327 The Nodeprep profile of stringprep is defined under Nodeprep 6328 (Appendix A). The IANA has registered Nodeprep in the stringprep 6329 profile registry. 6331 Name of this profile: 6333 Nodeprep 6335 RFC in which the profile is defined: 6337 XXXX 6339 Indicator whether or not this is the newest version of the profile: 6341 This is the first version of Nodeprep 6343 16.7. Resourceprep Profile of Stringprep 6345 The Resourceprep profile of stringprep is defined under Resourceprep 6346 (Appendix B). The IANA has registered Resourceprep in the stringprep 6347 profile registry. 6349 Name of this profile: 6351 Resourceprep 6353 RFC in which the profile is defined: 6355 XXXX 6357 Indicator whether or not this is the newest version of the profile: 6359 This is the first version of Resourceprep 6361 16.8. GSSAPI Service Name 6363 The IANA has registered "xmpp" as a GSSAPI [GSS-API] service name, as 6364 defined under Section 7.5. 6366 16.9. Port Numbers 6368 The IANA has registered "xmpp-client" and "xmpp-server" as keywords 6369 for [TCP] ports 5222 and 5269 respectively. 6371 These ports SHOULD be used for client-to-server and server-to-server 6372 communications respectively, but other ports MAY be used. 6374 17. References 6376 17.1. Normative References 6378 [ABNF] Crocker, D. and P. Overell, "Augmented BNF for Syntax 6379 Specifications: ABNF", STD 68, RFC 5234, January 2008. 6381 [BASE64] Josefsson, S., "The Base16, Base32, and Base64 Data 6382 Encodings", RFC 4648, October 2006. 6384 [CHARSET] Alvestrand, H., "IETF Policy on Character Sets and 6385 Languages", BCP 18, RFC 2277, January 1998. 6387 [DNS] Mockapetris, P., "Domain names - implementation and 6388 specification", STD 13, RFC 1035, November 1987. 6390 [DNS-SRV] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for 6391 specifying the location of services (DNS SRV)", RFC 2782, 6392 February 2000. 6394 [IDNA] Faltstrom, P., Hoffman, P., and A. Costello, 6395 "Internationalizing Domain Names in Applications (IDNA)", 6396 RFC 3490, March 2003. 6398 [LANGTAGS] 6399 Phillips, A. and M. Davis, "Tags for Identifying 6400 Languages", BCP 47, RFC 4646, September 2006. 6402 [NAMEPREP] 6403 Hoffman, P. and M. Blanchet, "Nameprep: A Stringprep 6404 Profile for Internationalized Domain Names (IDN)", 6405 RFC 3491, March 2003. 6407 [PLAIN] Zeilenga, K., "The PLAIN Simple Authentication and 6408 Security Layer (SASL) Mechanism", RFC 4616, August 2006. 6410 [RANDOM] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 6411 Requirements for Security", BCP 106, RFC 4086, June 2005. 6413 [SASL] Melnikov, A. and K. Zeilenga, "Simple Authentication and 6414 Security Layer (SASL)", RFC 4422, June 2006. 6416 [STRINGPREP] 6417 Hoffman, P. and M. Blanchet, "Preparation of 6418 Internationalized Strings ("stringprep")", RFC 3454, 6419 December 2002. 6421 [TCP] Postel, J., "Transmission Control Protocol", STD 7, 6422 RFC 793, September 1981. 6424 [TERMS] Bradner, S., "Key words for use in RFCs to Indicate 6425 Requirement Levels", BCP 14, RFC 2119, March 1997. 6427 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 6428 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 6430 [UCS2] International Organization for Standardization, 6431 "Information Technology - Universal Multiple-octet coded 6432 Character Set (UCS) - Amendment 2: UCS Transformation 6433 Format 8 (UTF-8)", ISO Standard 10646-1 Addendum 2, 6434 October 1996. 6436 [UNICODE] The Unicode Consortium, "The Unicode Standard, Version 6437 3.2.0", 2000. 6439 The Unicode Standard, Version 3.2.0 is defined by The 6440 Unicode Standard, Version 3.0 (Reading, MA, Addison- 6441 Wesley, 2000. ISBN 0-201-61633-5), as amended by the 6442 Unicode Standard Annex #27: Unicode 3.1 6443 (http://www.unicode.org/reports/tr27/) and by the Unicode 6444 Standard Annex #28: Unicode 3.2 6445 (http://www.unicode.org/reports/tr28/). 6447 [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 6448 10646", STD 63, RFC 3629, November 2003. 6450 [UUID] Leach, P., Mealling, M., and R. Salz, "A Universally 6451 Unique IDentifier (UUID) URN Namespace", RFC 4122, 6452 July 2005. 6454 [URI] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 6455 Resource Identifier (URI): Generic Syntax", STD 66, 6456 RFC 3986, January 2005. 6458 [X509] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 6459 Housley, R., and W. Polk, "Internet X.509 Public Key 6460 Infrastructure Certificate and Certificate Revocation List 6461 (CRL) Profile", RFC 5280, May 2008. 6463 [X509-SRV] 6464 Santesson, S., "Internet X.509 Public Key Infrastructure 6465 Subject Alternative Name for Expression of Service Name", 6466 RFC 4985, August 2007. 6468 [XML] Paoli, J., Maler, E., Sperberg-McQueen, C., Yergeau, F., 6469 and T. Bray, "Extensible Markup Language (XML) 1.0 (Fourth 6470 Edition)", World Wide Web Consortium Recommendation REC- 6471 xml-20060816, August 2006, 6472 . 6474 [XML-NAMES] 6475 Layman, A., Hollander, D., Tobin, R., and T. Bray, 6476 "Namespaces in XML 1.1 (Second Edition)", World Wide Web 6477 Consortium Recommendation REC-xml-names11-20060816, 6478 August 2006, . 6480 17.2. Informative References 6482 [ACAP] Newman, C. and J. Myers, "ACAP -- Application 6483 Configuration Access Protocol", RFC 2244, November 1997. 6485 [ANONYMOUS] 6486 Zeilenga, K., "Anonymous Simple Authentication and 6487 Security Layer (SASL) Mechanism", RFC 4505, June 2006. 6489 [ASN.1] CCITT, "Recommendation X.208: Specification of Abstract 6490 Syntax Notation One (ASN.1)", 1988. 6492 [CHANNEL] Williams, N., "On the Use of Channel Bindings to Secure 6493 Channels", RFC 5056, November 2007. 6495 [DIGEST-MD5] 6496 Leach, P. and C. Newman, "Using Digest Authentication as a 6497 SASL Mechanism", RFC 2831, May 2000. 6499 [DNSSEC] Arends, R., Austein, R., Larson, M., Massey, D., and S. 6500 Rose, "DNS Security Introduction and Requirements", 6501 RFC 4033, March 2005. 6503 [DNS-TXT] Rosenbaum, R., "Using the Domain Name System To Store 6504 Arbitrary String Attributes", RFC 1464, May 1993. 6506 [DOS] Handley, M., Rescorla, E., and IAB, "Internet Denial-of- 6507 Service Considerations", RFC 4732, December 2006. 6509 [GSS-API] Linn, J., "Generic Security Service Application Program 6510 Interface Version 2, Update 1", RFC 2743, January 2000. 6512 [HTTP] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 6513 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 6514 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 6516 [IMAP] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 6517 4rev1", RFC 3501, March 2003. 6519 [IMP-REQS] 6520 Day, M., Aggarwal, S., and J. Vincent, "Instant Messaging 6521 / Presence Protocol Requirements", RFC 2779, 6522 February 2000. 6524 [IRI] Duerst, M. and M. Suignard, "Internationalized Resource 6525 Identifiers (IRIs)", RFC 3987, January 2005. 6527 [LINKLOCAL] 6528 Cheshire, S., Aboba, B., and E. Guttman, "Dynamic 6529 Configuration of IPv4 Link-Local Addresses", RFC 3927, 6530 May 2005. 6532 [MAILBOXES] 6533 Crocker, D., "MAILBOX NAMES FOR COMMON SERVICES, ROLES AND 6534 FUNCTIONS", RFC 2142, May 1997. 6536 [POP3] Myers, J. and M. Rose, "Post Office Protocol - Version 3", 6537 STD 53, RFC 1939, May 1996. 6539 [PUNYCODE] 6540 Costello, A., "Punycode: A Bootstring encoding of Unicode 6541 for Internationalized Domain Names in Applications 6542 (IDNA)", RFC 3492, March 2003. 6544 [RFC3920] Saint-Andre, P., Ed., "Extensible Messaging and Presence 6545 Protocol (XMPP): Core", RFC 3920, October 2004. 6547 [RFC3921] Saint-Andre, P., Ed., "Extensible Messaging and Presence 6548 Protocol (XMPP): Instant Messaging and Presence", 6549 RFC 3921, October 2004. 6551 [xmpp-im] Saint-Andre, P., "Extensible Messaging and Presence 6552 Protocol (XMPP): Instant Messaging and Presence", 6553 draft-ietf-xmpp-3921bis-00 (work in progress), June 2009. 6555 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 2821, 6556 April 2001. 6558 [URN-OID] Mealling, M., "A URN Namespace of Object Identifiers", 6559 RFC 3061, February 2001. 6561 [USINGTLS] 6562 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 6563 RFC 2595, June 1999. 6565 [XEP-0001] 6566 Saint-Andre, P., "XMPP Extension Protocols", XSF XEP 0001, 6567 January 2008. 6569 [XEP-0045] 6570 Saint-Andre, P., "Multi-User Chat", XSF XEP 0045, 6571 July 2007. 6573 [XEP-0060] 6574 Millard, P., Saint-Andre, P., and R. Meijer, "Publish- 6575 Subscribe", XSF XEP 0060, September 2008. 6577 [XEP-0071] 6578 Saint-Andre, P., "XHTML-IM", XSF XEP 0071, September 2008. 6580 [XEP-0077] 6581 Saint-Andre, P., "In-Band Registration", XSF XEP 0077, 6582 January 2006. 6584 [XEP-0124] 6585 Paterson, I., Smith, D., and P. Saint-Andre, 6586 "Bidirectional-streams Over Synchronous HTTP (BOSH)", XSF 6587 XEP 0124, April 2009. 6589 [XEP-0156] 6590 Hildebrand, J. and P. Saint-Andre, "Discovering 6591 Alternative XMPP Connection Methods", XSF XEP 0156, 6592 June 2007. 6594 [XEP-0165] 6595 Saint-Andre, P., "Best Practices to Prevent JID 6596 Mimicking", XSF XEP 0165, December 2007. 6598 [XEP-0174] 6599 Saint-Andre, P., "Link-Local Messaging", XSF XEP 0174, 6600 November 2008. 6602 [XEP-0175] 6603 Saint-Andre, P., "Best Practices for Use of SASL 6604 ANONYMOUS", XSF XEP 0175, November 2007. 6606 [XEP-0178] 6607 Saint-Andre, P. and P. Millard, "Best Practices for Use of 6608 SASL EXTERNAL with Certificates", XSF XEP 0178, 6609 February 2007. 6611 [XEP-0205] 6612 Saint-Andre, P., "Best Practices to Discourage Denial of 6613 Service Attacks", XSF XEP 0205, January 2009. 6615 [XEP-0206] 6616 Paterson, I., "XMPP Over BOSH", XSF XEP 0206, 6617 October 2008. 6619 [XEP-0220] 6620 Saint-Andre, P. and J. Miller, "Server Dialback", XSF 6621 XEP 0220, October 2008. 6623 [XML-FRAG] 6624 Grosso, P. and D. Veillard, "XML Fragment Interchange", 6625 World Wide Web Consortium CR CR-xml-fragment-20010212, 6626 February 2001, 6627 . 6629 [XML-REG] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, 6630 January 2004. 6632 [XML-SCHEMA] 6633 Thompson, H., Maloney, M., Mendelsohn, N., and D. Beech, 6634 "XML Schema Part 1: Structures Second Edition", World Wide 6635 Web Consortium Recommendation REC-xmlschema-1-20041028, 6636 October 2004, 6637 . 6639 [XMPP-URI] 6640 Saint-Andre, P., "Internationalized Resource Identifiers 6641 (IRIs) and Uniform Resource Identifiers (URIs) for the 6642 Extensible Messaging and Presence Protocol (XMPP)", 6643 RFC 5122, February 2008. 6645 Appendix A. Nodeprep 6647 A.1. Introduction 6649 This appendix defines the "Nodeprep" profile of stringprep. As such, 6650 it specifies processing rules that will enable users to enter 6651 internationalized node identifiers in the Extensible Messaging and 6652 Presence Protocol (XMPP) and have the highest chance of getting the 6653 content of the strings correct. (An XMPP node identifier is the 6654 optional portion of an XMPP address that precedes an XMPP domain 6655 identifier and the '@' separator; it is often but not exclusively 6656 associated with an instant messaging username.) These processing 6657 rules are intended only for XMPP node identifiers and are not 6658 intended for arbitrary text or any other aspect of an XMPP address. 6660 This profile defines the following, as required by [STRINGPREP]: 6662 o The intended applicability of the profile: internationalized node 6663 identifiers within XMPP 6664 o The character repertoire that is the input and output to 6665 stringprep: Unicode 3.2, specified in Section 2 of this Appendix 6666 o The mappings used: specified in Section 3 6667 o The Unicode normalization used: specified in Section 4 6668 o The characters that are prohibited as output: specified in Section 6669 5 6670 o Bidirectional character handling: specified in Section 6 6672 A.2. Character Repertoire 6674 This profile uses Unicode 3.2 with the list of unassigned code points 6675 being Table A.1, both defined in Appendix A of [STRINGPREP]. 6677 A.3. Mapping 6679 This profile specifies mapping using the following tables from 6680 [STRINGPREP]: 6682 Table B.1 6683 Table B.2 6685 A.4. Normalization 6687 This profile specifies the use of Unicode normalization form KC, as 6688 described in [STRINGPREP]. 6690 A.5. Prohibited Output 6692 This profile specifies the prohibition of using the following tables 6693 from [STRINGPREP]. 6695 Table C.1.1 6696 Table C.1.2 6697 Table C.2.1 6698 Table C.2.2 6699 Table C.3 6700 Table C.4 6701 Table C.5 6702 Table C.6 6703 Table C.7 6704 Table C.8 6705 Table C.9 6707 In addition, the following additional Unicode characters are also 6708 prohibited: 6710 U+0022 (QUOTATION MARK), i.e., " 6711 U+0026 (AMPERSAND), i.e., & 6712 U+0027 (APOSTROPHE), i.e., ' 6713 U+002F (SOLIDUS), i.e., / 6714 U+003A (COLON), i.e., : 6715 U+003C (LESS-THAN SIGN), i.e., < 6716 U+003E (GREATER-THAN SIGN), i.e., > 6717 U+0040 (COMMERCIAL AT), i.e., @ 6719 A.6. Bidirectional Characters 6721 This profile specifies checking bidirectional strings, as described 6722 in Section 6 of [STRINGPREP]. 6724 A.7. Notes 6726 Because the additional characters prohibited by Nodeprep are 6727 prohibited after normalization, an implementation MUST NOT enable a 6728 human user to input any Unicode code point whose decomposition 6729 includes those characters; such code points include but are not 6730 necessarily limited to the following (refer to [UNICODE] for complete 6731 information). 6733 o U+2100 (ACCOUNT OF) 6734 o U+2101 (ADDRESSED TO THE SUBJECT) 6735 o U+2105 (CARE OF) 6736 o U+2106 (CADA UNA) 6737 o U+226E (NOT LESS-THAN) 6738 o U+226F (NOT GREATER-THAN) 6739 o U+2A74 (DOUBLE COLON EQUAL) 6740 o U+FE13 (SMALL COLON) 6741 o U+FE60 (SMALL AMPERSAND) 6742 o U+FE64 (SMALL LESS-THAN SIGN) 6743 o U+FE65 (SMALL GREATER-THAN SIGN) 6744 o U+FE6B (SMALL COMMERCIAL AT) 6745 o U+FF02 (FULLWIDTH QUOTATION MARK) 6746 o U+FF06 (FULLWIDTH AMPERSAND) 6747 o U+FF07 (FULLWIDTH APOSTROPHE) 6748 o U+FF0F (FULLWIDTH SOLIDUS) 6749 o U+FF1A (FULLWIDTH COLON) 6750 o U+FF1C (FULLWIDTH LESS-THAN SIGN) 6751 o U+FF1E (FULLWIDTH GREATER-THAN SIGN) 6752 o U+FF20 (FULLWIDTH COMMERCIAL AT) 6754 Appendix B. Resourceprep 6756 B.1. Introduction 6758 This appendix defines the "Resourceprep" profile of stringprep. As 6759 such, it specifies processing rules that will enable users to enter 6760 internationalized resource identifiers in the Extensible Messaging 6761 and Presence Protocol (XMPP) and have the highest chance of getting 6762 the content of the strings correct. (An XMPP resource identifier is 6763 the optional portion of an XMPP address that follows an XMPP domain 6764 identifier and the '/' separator.) These processing rules are 6765 intended only for XMPP resource identifiers and are not intended for 6766 arbitrary text or any other aspect of an XMPP address. 6768 This profile defines the following, as required by [STRINGPREP]: 6770 o The intended applicability of the profile: internationalized 6771 resource identifiers within XMPP 6772 o The character repertoire that is the input and output to 6773 stringprep: Unicode 3.2, specified in Section 2 of this Appendix 6774 o The mappings used: specified in Section 3 6775 o The Unicode normalization used: specified in Section 4 6776 o The characters that are prohibited as output: specified in Section 6777 5 6778 o Bidirectional character handling: specified in Section 6 6780 B.2. Character Repertoire 6782 This profile uses Unicode 3.2 with the list of unassigned code points 6783 being Table A.1, both defined in Appendix A of [STRINGPREP]. 6785 B.3. Mapping 6787 This profile specifies mapping using the following tables from 6788 [STRINGPREP]: 6790 Table B.1 6792 B.4. Normalization 6794 This profile specifies the use of Unicode normalization form KC, as 6795 described in [STRINGPREP]. 6797 B.5. Prohibited Output 6799 This profile specifies the prohibition of using the following tables 6800 from [STRINGPREP]. 6802 Table C.1.2 6803 Table C.2.1 6804 Table C.2.2 6805 Table C.3 6806 Table C.4 6807 Table C.5 6808 Table C.6 6809 Table C.7 6810 Table C.8 6811 Table C.9 6813 B.6. Bidirectional Characters 6815 This profile specifies checking bidirectional strings, as described 6816 in Section 6 of [STRINGPREP]. 6818 Appendix C. XML Schemas 6820 Because validation of XML streams and stanzas is optional, the 6821 following XML schemas are provided for descriptive purposes only. 6822 These schemas are not normative. 6824 The following schemas formally define various XML namespaces used in 6825 the core XMPP protocols, in conformance with [XML-SCHEMA]. For 6826 schemas defining the 'jabber:client' and 'jabber:server' namespaces, 6827 refer to [xmpp-im]. 6829 C.1. Streams Namespace 6831 6833 6839 6840 6841 6842 6843 6845 6846 6847 6849 6850 6853 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6880 6881 6882 6883 6884 6886 6887 6888 6889 6890 6893 6896 6897 6898 6900 6902 C.2. Stream Error Namespace 6904 6906 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6966 6967 6968 6969 6970 6971 6972 6973 6974 6976 6977 6978 6979 6980 6982 6984 C.3. STARTTLS Namespace 6986 6988 6994 6995 6996 6997 6998 6999 7000 7001 7003 7005 7007 7008 7009 7010 7011 7013 7015 C.4. SASL Namespace 7016 7018 7024 7025 7026 7027 7031 7032 7033 7034 7035 7038 7039 7040 7042 7044 7045 7046 7047 7048 7051 7052 7053 7054 7056 7058 7060 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7084 7085 7086 7087 7088 7089 7090 7091 7092 7094 7095 7096 7097 7098 7100 7102 C.5. Resource Binding Namespace 7104 7106 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7127 7128 7129 7130 7131 7132 7134 7135 7136 7137 7138 7139 7141 7143 C.6. Stanza Error Namespace 7145 7147 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7207 7208 7209 7210 7211 7212 7213 7214 7215 7217 7218 7219 7220 7221 7223 7225 Appendix D. Contact Addresses 7227 Consistent with [MAILBOXES], an organization that offers an XMPP 7228 service SHOULD provide an Internet mailbox of "XMPP" for inquiries 7229 related to that service, where the host portion of the resulting 7230 mailto URI MUST be the organization's domain, not the domain of the 7231 XMPP service itself (e.g., the XMPP service might be offered at 7232 im.example.com but the Internet mailbox would be ). 7234 Appendix E. Account Provisioning 7236 Account provisioning is out of scope for this specification. 7237 Possible methods for account provisioning include account creation by 7238 a server administrator and in-band account registration using the 7239 'jabber:iq:register' namespace as documented in [XEP-0077]. 7241 Appendix F. Differences From RFC 3920 7243 Based on consensus derived from implementation and deployment 7244 experience as well as formal interoperability testing, the following 7245 substantive modifications were made from RFC 3920. 7247 o Corrected the ABNF syntax for JIDs to prevent zero-length node 7248 identifiers, domain identifiers, and resource identifiers. 7249 o Corrected the nameprep processing rules to require use of the 7250 UseSTD3ASCIIRules flag. 7251 o Recommended or mandated use of the 'from' and 'to' attributes on 7252 stream headers. 7253 o More fully specified stream closing handshake. 7254 o Specified recommended stream reconnection algorithm. 7255 o Specified return of stream error in response to 7256 receipt of prohibited XML features. 7257 o Specified that TLS plus SASL PLAIN is a mandatory-to-implement 7258 technology for client-to-server connections, since implementation 7259 of SASL EXTERNAL is uncommon in XMPP clients, in part because 7260 underlying security features such as end-user X.509 certificates 7261 are not yet widely deployed. 7262 o Added the , , 7263 , , and SASL error conditions to handle error flows mistakenly 7265 left out of RFC 3920 or discussed in RFC 4422 but not in RFC 2222. 7266 o More fully specified binding of multiple resources to the same 7267 stream. 7268 o Added the stanza error condition to enable 7269 potential ETags usage. 7270 o Removed unnecessary requirement for escaping of characters that 7271 map to certain predefined entities, which do not need to be 7272 escaped in XML. 7273 o Clarified process of DNS SRV lookups and fallbacks. 7274 o Clarified handling of SASL security layers. 7275 o Clarified handling of stream features, regularized use of the 7276 child element, and defined use of the 7277 child element. 7278 o Clarified handling of data that violates the well-formedness 7279 definitions for XML 1.0 and XML namespaces. 7280 o Specified security considerations in more detail, especially with 7281 regard to presence leaks and denial of service attacks. 7282 o Moved historical documentation of the server dialback protocol 7283 from this specification to a separate specification maintained by 7284 the XMPP Standards Foundation. 7286 In addition, numerous changes of an editorial nature were made in 7287 order to more fully specify and clearly explain XMPP. 7289 Appendix G. Copying Conditions 7291 Regarding this entire document or any portion of it, the author makes 7292 no guarantees and is not responsible for any damage resulting from 7293 its use. The author grants irrevocable permission to anyone to use, 7294 modify, and distribute it in any way that does not diminish the 7295 rights of anyone else to use, modify, and distribute it, provided 7296 that redistributed derivative works do not contain misleading author 7297 or version information. Derivative works need not be licensed under 7298 similar terms. 7300 Index 7302 B 7303 Bare JID 17 7305 C 7306 Connected Resource 74 7308 D 7309 Domain Identifier 15 7311 E 7312 Entity 14 7313 Error Stanza 86 7314 Extended Content 102 7316 F 7317 Full JID 17 7319 I 7320 Initial Stream 22 7321 IQ Stanza 85 7323 J 7324 Jabber Identifier 14 7326 M 7327 Message Stanza 84 7329 N 7330 Node Identifier 16 7332 P 7333 Presence Stanza 84 7335 R 7336 Resource Identifier 17 7337 Response Stream 22 7339 S 7340 Stream ID 27 7342 W 7343 Whitespace Ping 35 7345 X 7346 XML Stanza 22 7347 XML Stream 22 7349 Author's Address 7351 Peter Saint-Andre 7352 Cisco 7354 Email: psaintan@cisco.com