Network Working Group P. Saint-Andre
Internet-Draft Cisco
Obsoletes: 3920 (if approved) August 9, 2010
Intended status: Standards Track
Expires: February 10, 2011
Extensible Messaging and Presence Protocol (XMPP): Core
draft-ietf-xmpp-3920bis-12
Abstract
The Extensible Messaging and Presence Protocol (XMPP) is an
application profile of the Extensible Markup Language (XML) that
enables the near-real-time exchange of structured yet extensible data
between any two or more network entities. This document defines
XMPP's core protocol methods: setup and teardown of XML streams,
channel encryption, authentication, error handling, and communication
primitives for messaging, network availability ("presence"), and
request-response interactions.
Status of this Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on February 10, 2011.
Copyright Notice
Copyright (c) 2010 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
Saint-Andre Expires February 10, 2011 [Page 1]
Internet-Draft XMPP Core August 2010
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 9
1.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2. History . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3. Functional Summary . . . . . . . . . . . . . . . . . . . 9
1.4. Terminology . . . . . . . . . . . . . . . . . . . . . . 11
1.5. Acknowledgements . . . . . . . . . . . . . . . . . . . . 12
1.6. Discussion Venue . . . . . . . . . . . . . . . . . . . . 12
2. Architecture . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1. Global Addresses . . . . . . . . . . . . . . . . . . . . 13
2.2. Presence . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3. Persistent Streams . . . . . . . . . . . . . . . . . . . 13
2.4. Structured Data . . . . . . . . . . . . . . . . . . . . 14
2.5. Distributed Network of Clients and Servers . . . . . . . 14
3. TCP Binding . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.1. Scope . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2. Hostname Resolution . . . . . . . . . . . . . . . . . . 16
3.2.1. Preferred Process: SRV Lookup . . . . . . . . . . . 16
3.2.2. Fallback Processes . . . . . . . . . . . . . . . . . 17
3.2.3. When Not to Use SRV . . . . . . . . . . . . . . . . 17
3.2.4. Use of SRV Records with Add-On Services . . . . . . 17
3.3. Reconnection . . . . . . . . . . . . . . . . . . . . . . 18
3.4. Reliability . . . . . . . . . . . . . . . . . . . . . . 18
4. XML Streams . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.1. Streams Overview . . . . . . . . . . . . . . . . . . . . 19
4.2. Stream Negotiation . . . . . . . . . . . . . . . . . . . 21
4.2.1. Overview . . . . . . . . . . . . . . . . . . . . . . 21
4.2.2. Stream Features Format . . . . . . . . . . . . . . . 22
4.2.3. Restarts . . . . . . . . . . . . . . . . . . . . . . 24
4.2.4. Resending Features . . . . . . . . . . . . . . . . . 24
4.2.5. Completion of Stream Negotiation . . . . . . . . . . 24
4.2.6. Determination of Addresses . . . . . . . . . . . . . 25
4.2.7. Flow Chart . . . . . . . . . . . . . . . . . . . . . 26
4.3. Directionality . . . . . . . . . . . . . . . . . . . . . 28
4.4. Closing a Stream . . . . . . . . . . . . . . . . . . . . 29
4.5. Handling of Silent Peers . . . . . . . . . . . . . . . . 29
4.5.1. Dead Connection . . . . . . . . . . . . . . . . . . 30
4.5.2. Broken Stream . . . . . . . . . . . . . . . . . . . 30
4.5.3. Idle Peer . . . . . . . . . . . . . . . . . . . . . 31
4.5.4. Use of Checking Methods . . . . . . . . . . . . . . 31
4.6. Stream Attributes . . . . . . . . . . . . . . . . . . . 31
Saint-Andre Expires February 10, 2011 [Page 2]
Internet-Draft XMPP Core August 2010
4.6.1. from . . . . . . . . . . . . . . . . . . . . . . . . 32
4.6.2. to . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.6.3. id . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.6.4. xml:lang . . . . . . . . . . . . . . . . . . . . . . 35
4.6.5. version . . . . . . . . . . . . . . . . . . . . . . 37
4.6.6. Summary of Stream Attributes . . . . . . . . . . . . 38
4.7. Namespaces . . . . . . . . . . . . . . . . . . . . . . . 38
4.7.1. Streams Namespace . . . . . . . . . . . . . . . . . 39
4.7.2. Default Namespace . . . . . . . . . . . . . . . . . 39
4.7.3. Other Namespaces . . . . . . . . . . . . . . . . . . 40
4.7.4. Namespace Declarations and Prefixes . . . . . . . . 40
4.7.5. Mandatory-to-Implement Default Namespaces . . . . . 41
4.8. Stream Errors . . . . . . . . . . . . . . . . . . . . . 42
4.8.1. Rules . . . . . . . . . . . . . . . . . . . . . . . 42
4.8.1.1. Stream Errors Are Unrecoverable . . . . . . . . . 42
4.8.1.2. Stream Errors Can Occur During Setup . . . . . . 43
4.8.1.3. Stream Errors When the Host is Unspecified or
Unknown . . . . . . . . . . . . . . . . . . . . . 43
4.8.1.4. Where Stream Errors Are Sent . . . . . . . . . . 44
4.8.2. Syntax . . . . . . . . . . . . . . . . . . . . . . . 44
4.8.3. Defined Stream Error Conditions . . . . . . . . . . 45
4.8.3.1. bad-format . . . . . . . . . . . . . . . . . . . 45
4.8.3.2. bad-namespace-prefix . . . . . . . . . . . . . . 46
4.8.3.3. conflict . . . . . . . . . . . . . . . . . . . . 47
4.8.3.4. connection-timeout . . . . . . . . . . . . . . . 47
4.8.3.5. host-gone . . . . . . . . . . . . . . . . . . . . 48
4.8.3.6. host-unknown . . . . . . . . . . . . . . . . . . 48
4.8.3.7. improper-addressing . . . . . . . . . . . . . . . 49
4.8.3.8. internal-server-error . . . . . . . . . . . . . . 50
4.8.3.9. invalid-from . . . . . . . . . . . . . . . . . . 50
4.8.3.10. invalid-namespace . . . . . . . . . . . . . . . . 50
4.8.3.11. invalid-xml . . . . . . . . . . . . . . . . . . . 51
4.8.3.12. not-authorized . . . . . . . . . . . . . . . . . 52
4.8.3.13. policy-violation . . . . . . . . . . . . . . . . 52
4.8.3.14. remote-connection-failed . . . . . . . . . . . . 53
4.8.3.15. reset . . . . . . . . . . . . . . . . . . . . . . 53
4.8.3.16. resource-constraint . . . . . . . . . . . . . . . 54
4.8.3.17. restricted-xml . . . . . . . . . . . . . . . . . 54
4.8.3.18. see-other-host . . . . . . . . . . . . . . . . . 55
4.8.3.19. system-shutdown . . . . . . . . . . . . . . . . . 56
4.8.3.20. undefined-condition . . . . . . . . . . . . . . . 56
4.8.3.21. unsupported-encoding . . . . . . . . . . . . . . 57
4.8.3.22. unsupported-feature . . . . . . . . . . . . . . . 57
4.8.3.23. unsupported-stanza-type . . . . . . . . . . . . . 58
4.8.3.24. unsupported-version . . . . . . . . . . . . . . . 59
4.8.3.25. xml-not-well-formed . . . . . . . . . . . . . . . 60
4.8.4. Application-Specific Conditions . . . . . . . . . . 60
4.9. Simplified Stream Examples . . . . . . . . . . . . . . . 61
Saint-Andre Expires February 10, 2011 [Page 3]
Internet-Draft XMPP Core August 2010
5. STARTTLS Negotiation . . . . . . . . . . . . . . . . . . . . 63
5.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 64
5.2. Stream Negotiation Rules . . . . . . . . . . . . . . . . 64
5.2.1. Mandatory-to-Negotiate . . . . . . . . . . . . . . . 64
5.2.2. Restart . . . . . . . . . . . . . . . . . . . . . . 64
5.2.3. Data Formatting . . . . . . . . . . . . . . . . . . 64
5.2.4. Order of TLS and SASL Negotiations . . . . . . . . . 65
5.2.5. TLS Renegotiation . . . . . . . . . . . . . . . . . 65
5.2.6. TLS Extensions . . . . . . . . . . . . . . . . . . . 66
5.3. Process . . . . . . . . . . . . . . . . . . . . . . . . 66
5.3.1. Exchange of Stream Headers and Stream Features . . . 66
5.3.2. Initiation of STARTTLS Negotiation . . . . . . . . . 67
5.3.2.1. STARTTLS Command . . . . . . . . . . . . . . . . 67
5.3.2.2. Failure Case . . . . . . . . . . . . . . . . . . 67
5.3.2.3. Proceed Case . . . . . . . . . . . . . . . . . . 68
5.3.3. TLS Negotiation . . . . . . . . . . . . . . . . . . 68
5.3.3.1. Rules . . . . . . . . . . . . . . . . . . . . . . 68
5.3.3.2. TLS Failure . . . . . . . . . . . . . . . . . . . 69
5.3.3.3. TLS Success . . . . . . . . . . . . . . . . . . . 69
6. SASL Negotiation . . . . . . . . . . . . . . . . . . . . . . 71
6.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 71
6.2. Stream Negotiation Rules . . . . . . . . . . . . . . . . 71
6.2.1. Mandatory-to-Negotiate . . . . . . . . . . . . . . . 71
6.2.2. Restart . . . . . . . . . . . . . . . . . . . . . . 71
6.2.3. Mechanism Preferences . . . . . . . . . . . . . . . 71
6.2.4. Mechanism Offers . . . . . . . . . . . . . . . . . . 72
6.2.5. Data Formatting . . . . . . . . . . . . . . . . . . 72
6.2.6. Security Layers . . . . . . . . . . . . . . . . . . 73
6.2.7. Simple Username . . . . . . . . . . . . . . . . . . 73
6.2.8. Authorization Identity . . . . . . . . . . . . . . . 73
6.2.9. Realms . . . . . . . . . . . . . . . . . . . . . . . 74
6.2.10. Round Trips . . . . . . . . . . . . . . . . . . . . 74
6.3. Process . . . . . . . . . . . . . . . . . . . . . . . . 75
6.3.1. Exchange of Stream Headers and Stream Features . . . 75
6.3.2. Initiation . . . . . . . . . . . . . . . . . . . . . 76
6.3.3. Challenge-Response Sequence . . . . . . . . . . . . 76
6.3.4. Abort . . . . . . . . . . . . . . . . . . . . . . . 77
6.3.5. Failure . . . . . . . . . . . . . . . . . . . . . . 77
6.3.6. Success . . . . . . . . . . . . . . . . . . . . . . 78
6.4. SASL Errors . . . . . . . . . . . . . . . . . . . . . . 79
6.4.1. aborted . . . . . . . . . . . . . . . . . . . . . . 80
6.4.2. account-disabled . . . . . . . . . . . . . . . . . . 80
6.4.3. credentials-expired . . . . . . . . . . . . . . . . 80
6.4.4. encryption-required . . . . . . . . . . . . . . . . 80
6.4.5. incorrect-encoding . . . . . . . . . . . . . . . . . 81
6.4.6. invalid-authzid . . . . . . . . . . . . . . . . . . 81
6.4.7. invalid-mechanism . . . . . . . . . . . . . . . . . 81
6.4.8. malformed-request . . . . . . . . . . . . . . . . . 82
Saint-Andre Expires February 10, 2011 [Page 4]
Internet-Draft XMPP Core August 2010
6.4.9. mechanism-too-weak . . . . . . . . . . . . . . . . . 82
6.4.10. not-authorized . . . . . . . . . . . . . . . . . . . 82
6.4.11. temporary-auth-failure . . . . . . . . . . . . . . . 83
6.4.12. transition-needed . . . . . . . . . . . . . . . . . 83
6.5. SASL Definition . . . . . . . . . . . . . . . . . . . . 84
7. Resource Binding . . . . . . . . . . . . . . . . . . . . . . 84
7.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 84
7.2. Stream Negotiation Rules . . . . . . . . . . . . . . . . 85
7.2.1. Mandatory-to-Negotiate . . . . . . . . . . . . . . . 85
7.2.2. Restart . . . . . . . . . . . . . . . . . . . . . . 85
7.3. Advertising Support . . . . . . . . . . . . . . . . . . 85
7.4. Generation of Resource Identifiers . . . . . . . . . . . 86
7.5. Server-Generated Resource Identifier . . . . . . . . . . 86
7.5.1. Success Case . . . . . . . . . . . . . . . . . . . . 86
7.5.2. Error Cases . . . . . . . . . . . . . . . . . . . . 87
7.5.2.1. Resource Constraint . . . . . . . . . . . . . . . 87
7.5.2.2. Not Allowed . . . . . . . . . . . . . . . . . . . 87
7.6. Client-Submitted Resource Identifier . . . . . . . . . . 88
7.6.1. Success Case . . . . . . . . . . . . . . . . . . . . 88
7.6.2. Error Cases . . . . . . . . . . . . . . . . . . . . 89
7.6.2.1. Bad Request . . . . . . . . . . . . . . . . . . . 89
7.6.2.2. Conflict . . . . . . . . . . . . . . . . . . . . 89
7.6.3. Retries . . . . . . . . . . . . . . . . . . . . . . 90
8. XML Stanzas . . . . . . . . . . . . . . . . . . . . . . . . . 90
8.1. Common Attributes . . . . . . . . . . . . . . . . . . . 91
8.1.1. to . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.1.1.1. Client-to-Server Streams . . . . . . . . . . . . 91
8.1.1.2. Server-to-Server Streams . . . . . . . . . . . . 92
8.1.2. from . . . . . . . . . . . . . . . . . . . . . . . . 92
8.1.2.1. Client-to-Server Streams . . . . . . . . . . . . 92
8.1.2.2. Server-to-Server Streams . . . . . . . . . . . . 93
8.1.3. id . . . . . . . . . . . . . . . . . . . . . . . . . 93
8.1.4. type . . . . . . . . . . . . . . . . . . . . . . . . 94
8.1.5. xml:lang . . . . . . . . . . . . . . . . . . . . . . 94
8.2. Basic Semantics . . . . . . . . . . . . . . . . . . . . 95
8.2.1. Message Semantics . . . . . . . . . . . . . . . . . 95
8.2.2. Presence Semantics . . . . . . . . . . . . . . . . . 95
8.2.3. IQ Semantics . . . . . . . . . . . . . . . . . . . . 96
8.3. Stanza Errors . . . . . . . . . . . . . . . . . . . . . 97
8.3.1. Rules . . . . . . . . . . . . . . . . . . . . . . . 98
8.3.2. Syntax . . . . . . . . . . . . . . . . . . . . . . . 99
8.3.3. Defined Conditions . . . . . . . . . . . . . . . . . 100
8.3.3.1. bad-request . . . . . . . . . . . . . . . . . . . 100
8.3.3.2. conflict . . . . . . . . . . . . . . . . . . . . 101
8.3.3.3. feature-not-implemented . . . . . . . . . . . . . 101
8.3.3.4. forbidden . . . . . . . . . . . . . . . . . . . . 102
8.3.3.5. gone . . . . . . . . . . . . . . . . . . . . . . 103
8.3.3.6. internal-server-error . . . . . . . . . . . . . . 103
Saint-Andre Expires February 10, 2011 [Page 5]
Internet-Draft XMPP Core August 2010
8.3.3.7. item-not-found . . . . . . . . . . . . . . . . . 104
8.3.3.8. jid-malformed . . . . . . . . . . . . . . . . . . 104
8.3.3.9. not-acceptable . . . . . . . . . . . . . . . . . 105
8.3.3.10. not-allowed . . . . . . . . . . . . . . . . . . . 106
8.3.3.11. not-authorized . . . . . . . . . . . . . . . . . 106
8.3.3.12. payment-required . . . . . . . . . . . . . . . . 107
8.3.3.13. policy-violation . . . . . . . . . . . . . . . . 107
8.3.3.14. recipient-unavailable . . . . . . . . . . . . . . 108
8.3.3.15. redirect . . . . . . . . . . . . . . . . . . . . 109
8.3.3.16. registration-required . . . . . . . . . . . . . . 109
8.3.3.17. remote-server-not-found . . . . . . . . . . . . . 110
8.3.3.18. remote-server-timeout . . . . . . . . . . . . . . 111
8.3.3.19. resource-constraint . . . . . . . . . . . . . . . 111
8.3.3.20. service-unavailable . . . . . . . . . . . . . . . 112
8.3.3.21. subscription-required . . . . . . . . . . . . . . 112
8.3.3.22. undefined-condition . . . . . . . . . . . . . . . 113
8.3.3.23. unexpected-request . . . . . . . . . . . . . . . 114
8.3.4. Application-Specific Conditions . . . . . . . . . . 115
8.4. Extended Content . . . . . . . . . . . . . . . . . . . . 116
9. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 119
9.1. Client-to-Server Examples . . . . . . . . . . . . . . . 119
9.1.1. TLS . . . . . . . . . . . . . . . . . . . . . . . . 119
9.1.2. SASL . . . . . . . . . . . . . . . . . . . . . . . . 121
9.1.3. Resource Binding . . . . . . . . . . . . . . . . . . 123
9.1.4. Stanza Exchange . . . . . . . . . . . . . . . . . . 124
9.1.5. Close . . . . . . . . . . . . . . . . . . . . . . . 124
9.2. Server-to-Server Examples . . . . . . . . . . . . . . . 125
9.2.1. TLS . . . . . . . . . . . . . . . . . . . . . . . . 125
9.2.2. SASL . . . . . . . . . . . . . . . . . . . . . . . . 126
9.2.3. Stanza Exchange . . . . . . . . . . . . . . . . . . 127
9.2.4. Close . . . . . . . . . . . . . . . . . . . . . . . 128
10. Server Rules for Processing XML Stanzas . . . . . . . . . . . 128
10.1. In-Order Processing . . . . . . . . . . . . . . . . . . 128
10.2. General Considerations . . . . . . . . . . . . . . . . . 129
10.3. No 'to' Address . . . . . . . . . . . . . . . . . . . . 129
10.3.1. Message . . . . . . . . . . . . . . . . . . . . . . 130
10.3.2. Presence . . . . . . . . . . . . . . . . . . . . . . 130
10.3.3. IQ . . . . . . . . . . . . . . . . . . . . . . . . . 130
10.4. Remote Domain . . . . . . . . . . . . . . . . . . . . . 131
10.4.1. Existing Stream . . . . . . . . . . . . . . . . . . 131
10.4.2. No Existing Stream . . . . . . . . . . . . . . . . . 131
10.4.3. Error Handling . . . . . . . . . . . . . . . . . . . 131
10.5. Local Domain . . . . . . . . . . . . . . . . . . . . . . 132
10.5.1. Mere Domain . . . . . . . . . . . . . . . . . . . . 132
10.5.2. Domain with Resource . . . . . . . . . . . . . . . . 132
10.5.3. Localpart at Domain . . . . . . . . . . . . . . . . 132
10.5.3.1. No Such User . . . . . . . . . . . . . . . . . . 132
10.5.3.2. Bare JID . . . . . . . . . . . . . . . . . . . . 133
Saint-Andre Expires February 10, 2011 [Page 6]
Internet-Draft XMPP Core August 2010
10.5.3.3. Full JID . . . . . . . . . . . . . . . . . . . . 133
11. XML Usage . . . . . . . . . . . . . . . . . . . . . . . . . . 133
11.1. Restrictions . . . . . . . . . . . . . . . . . . . . . . 133
11.2. XML Namespace Names and Prefixes . . . . . . . . . . . . 134
11.3. Well-Formedness . . . . . . . . . . . . . . . . . . . . 134
11.4. Validation . . . . . . . . . . . . . . . . . . . . . . . 135
11.5. Inclusion of XML Declaration . . . . . . . . . . . . . . 135
11.6. Character Encoding . . . . . . . . . . . . . . . . . . . 135
11.7. Whitespace . . . . . . . . . . . . . . . . . . . . . . . 136
11.8. XML Versions . . . . . . . . . . . . . . . . . . . . . . 136
12. Internationalization Considerations . . . . . . . . . . . . . 136
13. Security Considerations . . . . . . . . . . . . . . . . . . . 136
13.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 136
13.2. Threat Model . . . . . . . . . . . . . . . . . . . . . . 137
13.3. Order of Layers . . . . . . . . . . . . . . . . . . . . 138
13.4. Confidentiality and Integrity . . . . . . . . . . . . . 138
13.5. Peer Entity Authentication . . . . . . . . . . . . . . . 138
13.6. Strong Security . . . . . . . . . . . . . . . . . . . . 139
13.7. Certificates . . . . . . . . . . . . . . . . . . . . . . 139
13.7.1. Certificate Generation . . . . . . . . . . . . . . . 139
13.7.1.1. General Considerations . . . . . . . . . . . . . 139
13.7.1.2. Server Certificates . . . . . . . . . . . . . . . 140
13.7.1.3. Client Certificates . . . . . . . . . . . . . . . 142
13.7.1.4. XmppAddr Identifier Type . . . . . . . . . . . . 142
13.7.2. Certificate Validation . . . . . . . . . . . . . . . 143
13.7.2.1. Server Certificates . . . . . . . . . . . . . . . 144
13.7.2.2. Client Certificates . . . . . . . . . . . . . . . 144
13.7.2.3. Checking of Certificates in Long-Lived Streams . 145
13.7.2.4. Use of Certificates in XMPP Extensions . . . . . 145
13.8. Mandatory-to-Implement Technologies . . . . . . . . . . 146
13.9. Technology Reuse . . . . . . . . . . . . . . . . . . . . 147
13.9.1. Use of base64 in SASL . . . . . . . . . . . . . . . 147
13.9.2. Use of DNS . . . . . . . . . . . . . . . . . . . . . 147
13.9.3. Use of Hash Functions . . . . . . . . . . . . . . . 147
13.9.4. Use of SASL . . . . . . . . . . . . . . . . . . . . 148
13.9.5. Use of TLS . . . . . . . . . . . . . . . . . . . . . 149
13.9.6. Use of UTF-8 . . . . . . . . . . . . . . . . . . . . 149
13.9.7. Use of XML . . . . . . . . . . . . . . . . . . . . . 149
13.10. Information Leaks . . . . . . . . . . . . . . . . . . . 149
13.10.1. IP Addresses . . . . . . . . . . . . . . . . . . . . 149
13.10.2. Presence Information . . . . . . . . . . . . . . . . 150
13.11. Directory Harvesting . . . . . . . . . . . . . . . . . . 150
13.12. Denial of Service . . . . . . . . . . . . . . . . . . . 150
13.13. Firewalls . . . . . . . . . . . . . . . . . . . . . . . 152
13.14. Interdomain Federation . . . . . . . . . . . . . . . . . 152
13.15. Non-Repudiation . . . . . . . . . . . . . . . . . . . . 153
14. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 153
14.1. XML Namespace Name for TLS Data . . . . . . . . . . . . 153
Saint-Andre Expires February 10, 2011 [Page 7]
Internet-Draft XMPP Core August 2010
14.2. XML Namespace Name for SASL Data . . . . . . . . . . . . 153
14.3. XML Namespace Name for Stream Errors . . . . . . . . . . 154
14.4. XML Namespace Name for Resource Binding . . . . . . . . 154
14.5. XML Namespace Name for Stanza Errors . . . . . . . . . . 154
14.6. GSSAPI Service Name . . . . . . . . . . . . . . . . . . 155
14.7. Port Numbers . . . . . . . . . . . . . . . . . . . . . . 155
15. Conformance Requirements . . . . . . . . . . . . . . . . . . 155
16. References . . . . . . . . . . . . . . . . . . . . . . . . . 164
16.1. Normative References . . . . . . . . . . . . . . . . . . 164
16.2. Informative References . . . . . . . . . . . . . . . . . 167
Appendix A. XML Schemas . . . . . . . . . . . . . . . . . . . . 172
A.1. Streams Namespace . . . . . . . . . . . . . . . . . . . 172
A.2. Stream Error Namespace . . . . . . . . . . . . . . . . . 173
A.3. STARTTLS Namespace . . . . . . . . . . . . . . . . . . . 176
A.4. SASL Namespace . . . . . . . . . . . . . . . . . . . . . 176
A.5. Resource Binding Namespace . . . . . . . . . . . . . . . 179
A.6. Stanza Error Namespace . . . . . . . . . . . . . . . . . 179
Appendix B. Contact Addresses . . . . . . . . . . . . . . . . . 181
Appendix C. Account Provisioning . . . . . . . . . . . . . . . . 181
Appendix D. Differences from RFC 3920 . . . . . . . . . . . . . 181
Appendix E. Copying Conditions . . . . . . . . . . . . . . . . . 183
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 183
Saint-Andre Expires February 10, 2011 [Page 8]
Internet-Draft XMPP Core August 2010
1. Introduction
1.1. Overview
The Extensible Messaging and Presence Protocol (XMPP) is an
application profile of the Extensible Markup Language [XML] that
enables the near-real-time exchange of structured yet extensible data
between any two or more network entities. This document defines
XMPP's core protocol methods: setup and teardown of XML streams,
channel encryption, authentication, error handling, and communication
primitives for messaging, network availability ("presence"), and
request-response interactions.
1.2. History
The basic syntax and semantics of XMPP were developed originally
within the Jabber open-source community, mainly in 1999. In late
2002, the XMPP Working Group was chartered with developing an
adaptation of the core Jabber protocol that would be suitable as an
IETF instant messaging (IM) and presence technology in accordance
with [IMP-REQS]. In October 2004, [RFC3920] and [RFC3921] were
published, representing the most complete definition of XMPP at that
time.
Since 2004 the Internet community has gained extensive implementation
and deployment experience with XMPP, including formal
interoperability testing carried out under the auspices of the XMPP
Standards Foundation (XSF). This document incorporates comprehensive
feedback from software developers and service providers, including a
number of backward-compatible modifications summarized under
Appendix D. As a result, this document reflects the rough consensus
of the Internet community regarding the core features of XMPP 1.0,
thus obsoleting RFC 3920.
1.3. Functional Summary
This non-normative section provides a developer-friendly, functional
summary of XMPP; refer to the sections that follow for a normative
definition of XMPP.
The purpose of XMPP is to enable the exchange of relatively small
pieces of structured data (called "XML stanzas") over a network
between any two (or more) entities. XMPP is typically implemented
using a distributed client-server architecture, wherein a client
needs to connect to a server in order to gain access to the network
and thus be allowed to exchange XML stanzas with other entities
(which can be associated with other servers). The process whereby a
client connects to a server, exchanges XML stanzas, and ends the
Saint-Andre Expires February 10, 2011 [Page 9]
Internet-Draft XMPP Core August 2010
connection is:
1. Determine the hostname and port at which to connect
2. Open a Transmission Control Protocol [TCP] connection
3. Open an XML stream over TCP
4. Negotiate Transport Layer Security [TLS] for channel encryption
(recommended)
5. Authenticate using a Simple Authentication and Security Layer
[SASL] mechanism
6. Bind a resource to the stream
7. Exchange an unbounded number of XML stanzas with other entities
on the network
8. Close the XML stream
9. Close the TCP connection
Within XMPP, one server can optionally connect to another server to
enable inter-domain or inter-server communication. For this to
happen, the two servers need to negotiate a connection between
themselves and then exchange XML stanzas; the process for doing so
is:
1. Determine the hostname and port at which to connect
2. Open a TCP connection
3. Open an XML stream
4. Negotiate TLS for channel encryption (recommended)
5. Authenticate using a Simple Authentication and Security Layer
[SASL] mechanism *
6. Exchange an unbounded number of XML stanzas both directly for the
servers and indirectly on behalf of entities associated with each
server (e.g., connected clients)
7. Close the XML stream
8. Close the TCP connection
* Implementation Note: At the time of writing, most deployed
server will use the older server dialback protocol to provide weak
identity verification instead of using SASL to provide strong
authentication, especially in cases where SASL negotiation would
not result in strong authentication anyway (e.g., because TLS
negotiation was not mandated by the peer server, or because the
certificate presented by the peer server during TLS negotiation is
self-signed and has not been previously accepted); for details,
see [XEP-0220].
This document specifies how clients connect to servers and specifies
the basic semantics of XML stanzas. However, this document does not
define the "payloads" of the XML stanzas that might be exchanged once
a connection is successfully established; instead, those payloads are
defined by various XMPP extensions. For example, [XMPP-IM] defines
Saint-Andre Expires February 10, 2011 [Page 10]
Internet-Draft XMPP Core August 2010
extensions for basic instant messaging and presence functionality.
In addition, various specifications produced in the XSF's XEP series
[XEP-0001] define extensions for a wide range of applications.
1.4. Terminology
The following capitalized keywords are to be interpreted as described
in [KEYWORDS]: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT";
"SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY",
"OPTIONAL".
Certain security-related terms are to be understood in the sense
defined in [SEC-TERMS]; such terms include, but are not limited to,
"assurance", "attack", "authentication", "authorization",
"certificate", "certification authority", "certification path",
"confidentiality", "credential", "downgrade", "encryption",
"fingerprint", "hash value", "identity", "integrity", "signature",
"security perimeter", "self-signed certificate", "sign", "spoof",
"tamper", "trust", "trust anchor", "trust chain", "validate",
"verify". Other security-related terms (for example, "denial of
service") are to be understood in the sense defined in the referenced
specifications.
The term "whitespace" is used to refer to any character that matches
production [3] content of [XML], i.e., any instance of SP, HT, CR, or
LF.
We define the following terms with regard to XML stanzas or parts
thereof:
deliver: for a server, to pass the data to a connected client
ignore: for a client or server, to discard the data without
acting upon it, presenting it a human user, or returning an
error to the sender
route: for a server, to pass the data to a remote server for
subsequent delivery
In examples, lines have been wrapped for improved readability,
"[...]" means elision, and the following prepended strings are used
(these prepended strings are not to be sent over the wire):
o C: = a client
Saint-Andre Expires February 10, 2011 [Page 11]
Internet-Draft XMPP Core August 2010
o E: = any XMPP entity
o I: = an initiating entity
o P: = a peer server
o R: = a receiving entity
o S: = a server
o S1: = server1
o S2: = server2
Following the "XML Notation" used in [IRI] to represent characters
that cannot be rendered in ASCII-only documents, some examples in
this document use the form "...." as a notational device to
represent [UNICODE] characters (e.g., the string "ř" stands
for the Unicode character LATIN SMALL LETTER R WITH CARON); this form
is definitely not to be sent over the wire in XMPP systems.
In adherence to the convention used in [URI] to represent Uniform
Resource Indentifiers, XMPP addresses in running text are enclosed
between '' (despite the fact that natively they are not
URIs).
1.5. Acknowledgements
The editor of this document finds it impossible to appropriately
acknowledge the many individuals who have provided comments regarding
the protocols defined in this specification. However, thanks are due
to those who have provided implementation feedback, bug reports,
requests for clarification, and suggestions for improvement since the
publication of the RFC this document supersedes. The editor has
endeavored to address all such feedback, but is solely responsible
for any remaining errors and ambiguities.
1.6. Discussion Venue
The document editor and the broader XMPP developer community welcome
discussion and comments related to the topics presented in this
document. The primary and preferred venue is the
mailing list, for which archives and subscription information are
available at . Related
discussions often occur on the mailing list, for
which archives and subscription information are available at
.
2. Architecture
XMPP provides a technology for the asynchronous, end-to-end exchange
of structured data by means of direct, persistent XML streams among a
distributed network of globally-addressable, presence-aware clients
Saint-Andre Expires February 10, 2011 [Page 12]
Internet-Draft XMPP Core August 2010
and servers. Because this architectural style involves ubiquitous
knowledge of network availability and a conceptually unlimited number
of concurrent information transactions in the context of a given
client-to-server or server-to-server session, we label it
"Availability for Concurrent Transactions" (ACT) to distinguish it
from the "Representational State Transfer" [REST] architectural style
familiar from the World Wide Web. Although the architecture of XMPP
is similar in important ways to that of email (see [EMAIL-ARCH]), it
introduces several modifications to facilitate communication in close
to real time. The salient features of this ACTive architectural
style are as follows.
2.1. Global Addresses
As with email, XMPP uses globally-unique addresses (based on the
Domain Name System) in order to route and deliver messages over the
network. All XMPP entities are addressable on the network, most
particularly clients and servers but also various additional services
that can be accessed by clients and servers. In general, server
addresses are of the form (e.g., ),
accounts hosted at a server are of the form
(e.g., ), and a particular connected device or
resource that is currently authorized for interaction on behalf of an
account is of the form (e.g.,
). For historical reasons, XMPP
addresses are often called Jabber IDs or JIDs. Because the formal
specification of the XMPP address format depends on
internationalization technologies that are in flux at the time of
writing, the format is defined in [XMPP-ADDR] instead of this
document.
2.2. Presence
XMPP includes the ability for an entity to advertise its network
availability or "presence" to other entities. Such availability for
communication is signalled end-to-end via dedicated communication
primitives in XMPP (the stanza). Although knowledge of
network availability is not strictly necessary for the exchange of
XMPP messages, it facilitates real-time interaction because the
originator of a message can know before initiating communication that
the intended recipient is online and available. End-to-end presence
is defined in [XMPP-IM].
2.3. Persistent Streams
Availability for communication is also built into a point-to-point
"hop" through the use of persistent XML streams over long-lived TCP
connections. These "always-on" client-to-server or server-to-server
Saint-Andre Expires February 10, 2011 [Page 13]
Internet-Draft XMPP Core August 2010
streams enable each party to push data to the other party at any time
for immediate routing or delivery. XML streams are defined under
Section 4.
2.4. Structured Data
The basic protocol data unit in XMPP is not an XML stream (which
simply provides the transport for point-to-point communication) but
an XML "stanza", which is essentially a fragment of XML that is sent
over a stream. The root element of a stanza includes routing
attributes (such as "from" and "to" addresses) and the child elements
of the stanza contain a payload for delivery to the intended
recipient. XML stanzas are defined under Section 8.
2.5. Distributed Network of Clients and Servers
In practice, XMPP consists of a network of clients and servers that
inter-communicate (however, communication between any two given
deployed servers is strictly OPTIONAL). Thus, for example, the user
associated with the server
might be able to exchange messages, presence, and other structured
data with the user associated with the server
. This pattern is familiar from messaging protocols
that make use of global addresses, such as the email network (see
[SMTP] and [EMAIL-ARCH]). As a result, end-to-end communication in
XMPP is logically peer-to-peer but physically client-to-server-to-
server-to-client, as illustrated in the following diagram.
example.net ---------------- im.example.com
| |
| |
romeo@example.net juliet@im.example.com
Informational Note: Architectures that employ XML streams
(Section 4) and XML stanzas (Section 8) but that establish peer-
to-peer connections directly between clients using technologies
based on [LINKLOCAL] have been deployed, but such architectures
are not defined in this specification and are best described as
"XMPP-like"; for details, see [XEP-0174]. In addition, XML
streams can be established end-to-end over any reliable transport,
including extensions to XMPP itself; however, such methods are out
of scope for this specification.
The following paragraphs describe the responsibilities of clients and
servers on the network.
A CLIENT is an entity that establishes an XML stream with a server by
Saint-Andre Expires February 10, 2011 [Page 14]
Internet-Draft XMPP Core August 2010
authenticating using the credentials of a local account and that then
completes resource binding (Section 7) in order to enable delivery of
XML stanzas between the server and the client over the negotiated
stream. The client then uses XMPP to communicate with its server,
other clients, and any other entities on the network, where the
server is responsible for delivering stanzas to local entities or
routing them to remote entities. Multiple clients can connect
simultaneously to a server on behalf of the same local account, where
each client is differentiated by the resourcepart of an XMPP address
(e.g., vs.
), as defined under [XMPP-ADDR] and
Section 7.
A SERVER is an entity whose primary responsibilities are to:
o Manage XML streams (Section 4) with local clients and deliver XML
stanzas (Section 8) to those clients over the negotiated streams;
this includes responsibility for ensuring that a client
authenticates with the server before being granted access to the
XMPP network.
o Subject to local service policies on server-to-server
communication, manage XML streams (Section 4) with remote servers
and route XML stanzas (Section 8) to those servers over the
negotiated streams.
Depending on the application, the secondary responsibilities of an
XMPP server can include:
o Storing data that is used by clients (e.g., contact lists for
users of XMPP-based instant messaging and presence applications as
defined in [XMPP-IM]); in this case, the relevant XML stanza is
handled directly by the server itself on behalf of the client and
is not routed to a remote server or delivered to a local entity.
o Hosting local services that also use XMPP as the basis for
communication but that provide additional functionality beyond
that defined in this document or in [XMPP-IM]; examples include
multi-user conferencing services as specified in [XEP-0045] and
publish-subscribe services as specified in [XEP-0060].
3. TCP Binding
3.1. Scope
As XMPP is defined in this specification, an initiating entity
(client or server) MUST open a Transmission Control Protocol [TCP]
Saint-Andre Expires February 10, 2011 [Page 15]
Internet-Draft XMPP Core August 2010
connection to the receiving entity (server) before it negotiates XML
streams with the receiving entity. The parties then maintain that
TCP connection for as long as the XML streams are in use. The rules
specified in the following sections apply to the TCP binding.
Informational Note: There is no necessary coupling of XML streams
to TCP, and other transports are possible. For example, two
entities could connect to each other by means of [HTTP] as
specified in [XEP-0124] and [XEP-0206]. However, this
specification defines only a binding of XMPP to TCP.
3.2. Hostname Resolution
Because XML streams are sent over TCP, the initiating entity needs to
determine the IPv4 or IPv6 address (and port) of the receiving
entity's "origin domain" before it can attempt to connect to the XMPP
network.
3.2.1. Preferred Process: SRV Lookup
The preferred process for hostname resolution is to use [DNS-SRV]
records as follows:
1. The initiating entity constructs a DNS SRV query whose inputs
are:
* a Service of "xmpp-client" (for client-to-server connections)
or "xmpp-server" (for server-to-server connections)
* a Proto of "tcp"
* a Name corresponding to the "origin domain" of the XMPP
service to which the initiating entity wishes to connect
(e.g., "example.net" or "im.example.com")
2. The resulting is a query such as "_xmpp-client._tcp.example.net."
or "_xmpp-server._tcp.im.example.com.".
3. If a response is received, it will contain one or more
combinations of a port and hostname, each of which is weighted
and prioritized as described in [DNS-SRV]. However, if the
result of the SRV lookup is a single resource record with a
Target of ".", i.e. the root domain, then the initiating entity
MUST abort SRV processing at this point (but SHOULD attempt the
fallback process described in the next section).
4. The initiating entity chooses at least one of the returned
hostnames to resolve (following the rules in [DNS-SRV]), which it
does by using a DNS "A" or "AAAA" lookup on the hostname; this
will result in an IPv4 or IPv6 address.
Saint-Andre Expires February 10, 2011 [Page 16]
Internet-Draft XMPP Core August 2010
5. The initiating entity uses the IP address(es) from the first
successfully resolved hostname (with the corresponding port
number returned by the SRV lookup) as the connection address for
the receiving entity.
6. If the initiating entity fails to connect using that IP address
but the "A" or "AAAA" lookup returned more than one IP address,
then the initiating entity uses the next resolved IP address for
that hostname as the connection address.
7. If the initiating entity fails to connect using all resolved IP
addresses for a given hostname, then it repeats the process of
resolution and connection for the next hostname returned by the
SRV lookup.
8. If the initiating entity fails to connect using any hostname
returned by the SRV lookup, then it can either abort the
connection attempt or use the fallback process described in the
next section.
3.2.2. Fallback Processes
The fallback process SHOULD be a normal "A" or "AAAA" address record
resolution to determine the IPv4 or IPv6 address of the origin
domain, where the port used is the "xmpp-client" port of 5222 for
client-to-server connections or the "xmpp-server" port 5269 for
server-to-server connections.
For client-to-server connections, the fallback MAY be a [DNS-TXT]
lookup for alternative connection methods, for example as described
in [XEP-0156].
3.2.3. When Not to Use SRV
If the initiating entity has been explicitly configured to associate
a particular hostname (and potentially port) with the origin domain
of the receiving entity (say, to "hardcode" an association from an
origin domain of example.net to a configured hostname of
webcm.example.com:80), the initiating entity SHOULD use the
configured name instead of performing the preferred SRV resolution
process on the origin name.
3.2.4. Use of SRV Records with Add-On Services
Many XMPP servers are implemented in such a way that they can host
add-on services (beyond those defined in this specification and
[XMPP-IM]) at hostnames that typically are subdomains of the hostname
of the main XMPP service (e.g., conference.example.net for a
Saint-Andre Expires February 10, 2011 [Page 17]
Internet-Draft XMPP Core August 2010
[XEP-0045] service associated with the example.net XMPP service) or
subdomains of the first-level domain of the underlying host (e.g.,
muc.example.com for a [XEP-0045] service associated with the
im.example.com XMPP service). If an entity from a remote domain
wishes to use such add-on services, it would generate an appropriate
XML stanza and the remote domain itself would attempt to resolve the
service's hostname via an SRV lookup on resource records such as
"_xmpp-server._tcp.conference.example.net." or "_xmpp-
server._tcp.muc.example.com.". Therefore if a service wishes to
enable entities from remote domains to access these add-on services,
it needs to advertise the appropriate "_xmpp-server" SRV records in
addition to the "_xmpp-server" record for its main XMPP service. The
same fallback methods apply in case SRV records are not available.
3.3. Reconnection
It can happen that an XMPP server goes offline while servicing TCP
connections from local clients and from other servers. Because the
number of such connections can be quite large, the reconnection
algorithm employed by entities that seek to reconnect can have a
significant impact on software and network performance. If an entity
chooses to reconnect, the following guidelines are RECOMMENDED:
o The number of seconds that expire before an entity first seeks to
reconnect SHOULD be an unpredictable number between 0 and 60
(e.g., so that all clients do not attempt to reconnect exactly 30
seconds after being disconnected).
o If the first reconnection attempt does not succeed, an entity
SHOULD back off increasingly on the time between subsequent
reconnection attempts (e.g., in accordance with "truncated binary
exponential backoff" as described in [ETHERNET]).
3.4. Reliability
The use of long-lived TCP connections in XMPP implies that the
sending of XML stanzas over XML streams can be unreliable, since the
parties to a long-lived TCP connection might not discover a
connectivity disruption in a timely manner. At the XMPP application
layer, long connectivity disruptions can result in undelivered
stanzas. Although the core XMPP technology defined in this
specification does not contain features to overcome this lack of
reliability, there exist XMPP extensions for doing so (e.g.,
[XEP-0198]).
Saint-Andre Expires February 10, 2011 [Page 18]
Internet-Draft XMPP Core August 2010
4. XML Streams
4.1. Streams Overview
Two fundamental concepts make possible the rapid, asynchronous
exchange of relatively small payloads of structured information
between XMPP entities: XML streams and XML stanzas. These terms are
defined as follows.
Definition of XML Stream: An XML STREAM is a container for the
exchange of XML elements between any two entities over a network.
The start of an XML stream is denoted unambiguously by an opening
STREAM HEADER (i.e., an XML tag with appropriate
attributes and namespace declarations), while the end of the XML
stream is denoted unambiguously by a closing XML tag.
During the life of the stream, the entity that initiated it can
send an unbounded number of XML elements over the stream, either
elements used to negotiate the stream (e.g., to complete TLS
negotiation (Section 5) or SASL negotiation (Section 6)) or XML
stanzas. The INITIAL STREAM is negotiated from the initiating
entity (typically a client or server) to the receiving entity
(typically a server), and can be seen as corresponding to the
initiating entity's "connection to" or "session with" the
receiving entity. The initial stream enables unidirectional
communication from the initiating entity to the receiving entity;
in order to enable exchange of stanzas from the receiving entity
to the initiating entity, the receiving entity MUST negotiate a
stream in the opposite direction (the RESPONSE STREAM).
Definition of XML Stanza: An XML STANZA is the basic unit of meaning
in XMPP. Only a first-level , , or
element qualified by the default namespace is an XML stanza. By
contrast, a first-level XML element sent for any other purpose is
not an XML stanza (stream errors, stream features, TLS-related
elements, SASL-related elements, etc.). An XML stanza typically
contains one or more child elements (with accompanying attributes,
elements, and XML character data) as necessary in order to convey
the desired information, which MAY be qualified by any XML
namespace (see [XML-NAMES] as well as Section 8.4 in this
specification).
Consider the example of a client's connection to a server. The
client initiates an XML stream by sending a stream header to the
server, optionally preceded by a text declaration specifying the XML
version and the character encoding supported (see Section 11.5 and
Section 11.6). Subject to local policies and service provisioning,
the server then replies with a second XML stream back to the client,
again optionally preceded by a text declaration. Once the client has
Saint-Andre Expires February 10, 2011 [Page 19]
Internet-Draft XMPP Core August 2010
completed SASL negotiation (Section 6) and resource binding
(Section 7), the client can send an unbounded number of XML stanzas
over the stream. When the client desires to close the stream, it
simply sends a closing tag to the server as further
described under Section 4.4.
In essence, then, an XML stream acts as an envelope for all the XML
stanzas sent during a connection. We can represent this in a
simplistic fashion as follows.
+--------------------+
| |
|--------------------|
| |
| |
| |
|--------------------|
| |
| |
| |
|--------------------|
| |
| |
| |
|--------------------|
| |
| |
| |
|--------------------|
| [ ... ] |
|--------------------|
| |
+--------------------+
Those who are accustomed to thinking of XML in a document-centric
manner might find the following analogies useful:
o The two XML streams are like two "documents" (matching production
[1] content of [XML]) that are built up through the accumulation
of XML stanzas.
o The root element is like the "document entity" for each
"document" (as described in Section 4.8 of [XML]).
o The XML stanzas sent over the streams are like "fragments" of the
"documents" (as described in [XML-FRAG]).
However, these analogies are merely that, because XMPP does not deal
in documents and fragments but in streams and stanzas.
Saint-Andre Expires February 10, 2011 [Page 20]
Internet-Draft XMPP Core August 2010
The remainder of this section defines the following aspects of XML
streams:
o The stream negotation process
o How to close a stream
o How to handle peers that are silent
o The XML attributes of a stream
o The XML namespaces of a stream
4.2. Stream Negotiation
4.2.1. Overview
Because the receiving entity for a stream acts as a gatekeeper to the
domains it services, it imposes certain conditions for connecting as
a client or as a peer server. At a minimum, the initiating entity
needs to authenticate with the receiving entity before it is allowed
to send stanzas to the receiving entity, typically using SASL as
described under Section 6. However, the receiving entity can
consider conditions other than authentication to be mandatory, such
as encryption using TLS as described under Section 5. The receiving
entity informs the initiating entity about such conditions by
communicating STREAM FEATURES: the set of particular protocol
interactions that are mandatory for the initiating entity to complete
before the receiving entity will accept XML stanzas from the
initiating entity (e.g., authentication), as well as any protocol
interactions that are voluntary but that might improve the handling
of an XML stream (e.g., establishment of application-layer
compression as described in [XEP-0138]).
The existence of conditions for connecting implies that streams need
to be negotiated. The order of layers (TCP, then TLS, then SASL,
then XMPP; see Section 13.3) implies that stream negotiation is a
multi-stage process. Further structure is imposed by two factors:
(1) a given stream feature might be offered only to certain entities
or only after certain other features have been negotiated (e.g.,
resource binding is offered only after SASL authentication), and (2)
stream features can be either mandatory-to-negotiate or voluntary-to-
negotiate. Finally, for security reasons the parties to a stream
need to discard knowledge that they gained during the negotiation
process after successfully completing the protocol interactions
defined for certain features (e.g., TLS in all cases and SASL in the
case when a security layer might be established, as defined in the
specification for the relevant SASL mechanism); this is done by
flushing the old stream context and exchanging new stream headers
over the existing TCP connection.
Saint-Andre Expires February 10, 2011 [Page 21]
Internet-Draft XMPP Core August 2010
4.2.2. Stream Features Format
If the initiating entity includes the 'version' attribute set to a
value of at least "1.0" in the initial stream header, after sending
the response stream header the receiving entity MUST send a
child element (prefixed by the streams namespace prefix)
to the initiating entity in order to announce any conditions for
continuation of the stream negotiation process. Each condition takes
the form of a child element of the element, qualified by
a namespace that is different from the streams namespace and the
default namespace. The element can contain one child,
contain multiple children, or be empty.
Implementation Note: The order of child elements contained in any
given element is not significant.
If a particular stream feature is or can be mandatory-to-negotiate,
the definition of that feature needs to do one of the following:
1. Declare that the feature is always mandatory-to-negotiate (e.g.,
this is true of resource binding for XMPP clients); or
2. Specify a way for the receiving entity to flag the feature as
mandatory-to-negotiate for this interaction (e.g., this is done
for TLS by including an empty element in the
advertisement for that stream feature); it is RECOMMENDED that
stream feature definitions for mandatory-to-negotiate features do
so by including an empty element as is done for TLS.
Informational Note: Because there is no generic format for
indicating that a feature is mandatory-to-negotiate, it is
possible that a feature which is not understood by the initiating
entity might be considered mandatory-to-negotiate by the receiving
entity, resulting in failure of the stream negotiation process.
Although such an outcome would be undesirable, the working group
deemed it rare enough that a generic format was not needed.
For security reasons, certain stream features necessitate the
initiating entity to send a new initial stream header upon successful
negotiation of the feature (e.g., TLS in all cases and SASL in the
case when a security layer might be established). If this is true of
a given stream feature, the definition of that feature needs to
declare that a stream restart is expected after negotiation of the
feature.
A element that contains at least one mandatory-to-
negotiate feature indicates that the stream negotiation is not
complete and that the initiating entity MUST negotiate further
Saint-Andre Expires February 10, 2011 [Page 22]
Internet-Draft XMPP Core August 2010
features.
R:
A element MAY contain more than one mandatory feature.
This means that the initiating entity can choose among the mandatory
features. For example, perhaps a future technology will perform
roughly the same function as TLS, so the receiving entity might
advertise support for both TLS and the future technology.
A element that contains both mandatory and voluntary
features indicates that the negotiation is not complete but that the
initiating entity MAY complete the voluntary feature(s) before it
attempts to negotiate the mandatory feature(s).
R: zliblzw
A element that contains only voluntary features indicates
that the stream negotiation is complete and that the initiating
entity is cleared to send XML stanzas, but that the initiating entity
MAY negotiate further features if desired.
R: zliblzw
An empty element indicates that the stream negotiation is
complete and that the initiating entity is cleared to send XML
stanzas.
R:
Saint-Andre Expires February 10, 2011 [Page 23]
Internet-Draft XMPP Core August 2010
4.2.3. Restarts
On successful negotiation of a feature that necessitates a stream
restart, both parties MUST consider the previous stream to be
replaced but MUST NOT terminate the underlying TCP connection;
instead, the parties MUST reuse the existing connection, which might
be in a new state (e.g., encrypted as a result of TLS negotiation).
The initiating entity then MUST send a new initial stream header,
which SHOULD be preceded by an XML declaration as described under
Section 11.5. When the receiving entity receives the new initial
stream header, it MUST generate a new stream ID (instead of re-using
the old stream ID) before sending a new response stream header (which
SHOULD be preceded by an XML declaration as described under
Section 11.5).
4.2.4. Resending Features
The receiving entity MUST send an updated list of stream features to
the initiating entity after a stream restart, and MAY do so after
completing negotiation of a stream feature that does not require a
stream restart. The list of updated features MAY be empty if there
are no further features to be advertised or MAY include any
combination of features.
4.2.5. Completion of Stream Negotiation
The receiving entity indicates completion of the stream negotiation
process by sending to the initiating entity either an empty
element or a element that contains only
voluntary features. After doing so, the receiving entity MAY send an
empty element (e.g., after negotiation of such voluntary
features) but MUST NOT send additional stream features to the
initiating entity (if the receiving entity has new features to offer,
preferably limited to mandatory-to-negotiate or security-critical
features, it can simply close the stream using a stream
error and then advertise the new features when the initiating entity
reconnects, preferably closing existing streams in a staggered way so
that not all of the initiating entities reconnect at once). Once
stream negotiation is complete, the initiating entity is cleared to
send XML stanzas over the stream for as long as the stream is
maintained by both parties.
Informational Note: Resource binding as specified under Section 7
is an historical exception to the foregoing rule, since it is
mandatory-to-negotiate for clients but uses XML stanzas for
negotiation purposes.
The initiating entity MUST NOT attempt to send XML stanzas
Saint-Andre Expires February 10, 2011 [Page 24]
Internet-Draft XMPP Core August 2010
(Section 8) to entities other than itself (i.e., the client's
connected resource or any other authenticated resource of the
client's account) or the server to which it is connected until stream
negotiation has been completed. However, if it does attempt to do
so, the receiving entity MUST NOT accept such stanzas and MUST return
a stream error. This rule applies to XML stanzas
only (i.e., , , and elements qualified by
the default namespace) and not to XML elements used for stream
negotiation (e.g., elements used to complete TLS negotiation
(Section 5) or SASL negotiation (Section 6)).
4.2.6. Determination of Addresses
After the parties to an XML stream have completed the appropriate
aspects of stream negotiation (typically SASL negotiation (Section 6)
and, for client-to-server streams, resource binding (Section 7)) the
receiving entity for a stream MUST determine the initiating entity's
JID.
For client-to-server communication, the client's bare JID
() MUST be the authorization identity (as
defined by [SASL]), either (1) as directly communicated by the client
during SASL negotiation (Section 6) or (2) as derived by the server
from the authentication identity if no authorization identity was
specified during SASL negotiation (Section 6). The resourcepart of
the full JID () MUST be the resource
negotiated by the client and server during resource binding
(Section 7). A client MUST NOT attempt to guess at its JID but
instead MUST consider its JID to be whatever the server returns to it
during resource binding.
For server-to-server communication, the initiating server's JID MUST
be the authentication identity communicated by the initiating entity
during SASL negotiation (Section 6); in the absence of SASL
negotiation (e.g., when the older server dialback protocol is used as
specified in [XEP-0220]), the receiving server MAY consider the
authentication identity to be the 'from' address on the initial
stream header sent after TLS negotiation (information contained in
stream headers sent before successful TLS negotation can be modified
in transit by a third party). Note that authorization identities are
not allowed during SASL negotiation for server-to-server streams; for
details, see under Section 6.2.8.
The receiving entity MUST ensure that the resulting JID (including
localpart, domainpart, resourcepart, and separator characters)
conforms to the canonical format for XMPP addresses defined in
[XMPP-ADDR]; to meet this restriction, the receiving entity MAY
replace the JID sent by the initiating entity with the canonicalized
Saint-Andre Expires February 10, 2011 [Page 25]
Internet-Draft XMPP Core August 2010
JID as determined by the receiving entity.
4.2.7. Flow Chart
We summarize the foregoing rules in the following non-normative flow
chart for the stream negotiation process, presented from the
perspective of the initiating entity.
Saint-Andre Expires February 10, 2011 [Page 26]
Internet-Draft XMPP Core August 2010
+------------+
| open TCP |
| connection |
+------------+
|
v
+---------------+
| send initial || features | |
^ +----------------+ |
| | |
| v |
| + {all voluntary?} ----> {some mandatory?} |
| | no | no | |
| | yes | yes | yes |
| | v v |
| | +---------------+ +----------------+ |
| | | MAY negotiate | | MUST negotiate | |
| | | any or none | | one feature | |
| | +---------------+ +----------------+ |
| | | | |
| v v | |
| +----------+ +-----------+ | |
| | process |++
no yes
Saint-Andre Expires February 10, 2011 [Page 27]
Internet-Draft XMPP Core August 2010
4.3. Directionality
An XML stream is always unidirectional, by which is meant that XML
stanzas can be sent in only one direction over the stream (either
from the initiating entity to the receiving entity or from the
receiving entity to the initiating entity).
Depending on the type of session that has been negotiated and the
nature of the entities involved, the entities might use:
o Two streams over a single TCP connection; this is typical for
client-to-server sessions, and a server MUST allow a client to use
the same TCP connection for both streams.
o Two streams over two TCP connections, where one TCP connection is
used for the stream in which stanzas are sent from the initiating
entity to the receiving entity and the other TCP connection is
used for the stream in which stanzas are sent from the receiving
entity to the initiating entity; this is typical for server-to-
server sessions.
o Multiple streams over two or more TCP connections; this approach
is sometimes used for server-to-server sessions between two large
XMPP service providers, but is not otherwise described in this
document.
This concept of directionality applies only to stanzas and explicitly
does not apply to other first-level children of the stream root, such
as elements used for TLS negotiation, SASL negotiation, server
dialback [XEP-0220], and the stream management protocol [XEP-0198].
In particular, during establishment of a server-to-server session,
while completing STARTTLS negotiation (Section 5) and SASL
negotiation (Section 6) two servers would use one TCP connection, but
after the stream negotiation process is done that original TCP
connection would be used only for the initiating server to send XML
stanzas to the receiving server. In order for the receiving server
to send XML stanzas to the initiating server, the receiving server
would need to reverse the roles and negotiate an XML stream from the
receiving server to the initiating server over a separate TCP
connection.
Implementation Note: For historical reasons, a server-to-server
session always uses two TCP connections. Although a future
extension might allow servers to use a single TCP connection after
negotiation of a suitable feature, definition of such a feature is
out of scope for this document.
Saint-Andre Expires February 10, 2011 [Page 28]
Internet-Draft XMPP Core August 2010
Informational Note: Although XMPP developers sometimes apply the
terms "unidirectional" and "bidirectional" to the underlying TCP
connection (e.g., calling the TCP connection for a client-to-
server session "bidirectional" and the TCP connection for a
server-to-server session "unidirectional"), strictly speaking a
stream is always unidirectional (because the initiating entity and
receiving entity always have a minimum of two streams, one in each
direction) and a TCP connection is always bidirectional (because
TCP traffic can be sent in both directions). Directionality
applies to the application-layer traffic sent over the TCP
connection, not to the transport-layer traffic sent over the TCP
connection itself.
4.4. Closing a Stream
An XML stream between two entities can be closed at any time, either
because a specific stream error has occurred or in the absence of an
error (e.g., when a client simply ends its session).
A stream is closed by sending a closing tag.
S:
The entity that sends the closing stream tag SHOULD behave as
follows:
1. Wait for the other party to also close its stream before
terminating the underlying TCP connection (this gives the other
party an opportunity to finish transmitting any data in the
opposite direction before the TCP connection is terminated).
2. Refrain from initiating the sending of further data over that
stream but continue to process data sent by the other entity
(and, if necessary, react to such data).
3. Consider both streams to be void if the other party does not send
its closing stream tag within a reasonable amount of time (where
the definition of "reasonable" is a matter of implementation or
deployment).
4. After receiving a reciprocal closing stream tag from the other
party or waiting a reasonable amount of time with no response,
MUST terminate the underlying TCP connection.
4.5. Handling of Silent Peers
When an entity that is a party to a stream has not received any XMPP
traffic from its stream peer for some period of time, the peer might
Saint-Andre Expires February 10, 2011 [Page 29]
Internet-Draft XMPP Core August 2010
appear to be silent. There are several reasons why this might
happen:
1. The underlying TCP connection is dead.
2. The XML stream is broken despite the fact that the underlying TCP
connection is alive.
3. The peer is idle and simply has not sent any XMPP traffic over
its XML stream to the entity.
These three conditions are best handled separately, as described in
the following sections.
Implementation Note: For the purpose of handling silent peers, we
treat a two unidirectional TCP connections as conceptually
equivalent to a single bidirectional TCP connection (see
Section 4.3); however, implementers need to be aware that, in the
case of two unidirectional TCP connections, responses to traffic
at the XMPP application layer will come back from the peer on the
second TCP connection. In addition, the use of multiple streams
in each direction (which is a common deployment choice for server-
to-server connectivity among large XMPP service providers) further
complicates application-level checking of XMPP streams and their
underlying TCP connections, because there is no necessary
correlation between any given initial stream and any given
response stream.
4.5.1. Dead Connection
If the underlying TCP connection is dead, stream-level checks (e.g.,
[XEP-0199] and [XEP-0198]) are ineffective. Therefore it is
unnecessary to close the stream with or without an error, and it is
appropriate instead to simply terminate the TCP connection.
One common method for checking the TCP connection is to send a space
character (U+0020) between XML stanzas, which is allowed for XML
streams as described under Section 11.7; the sending of such a space
character is properly called a WHITESPACE KEEPALIVE (the term
"whitespace ping" is often used, despite the fact that it is not a
ping since no "pong" is possible).
4.5.2. Broken Stream
Even if the underlying TCP connection is alive, the peer might never
respond to XMPP traffic that the entity sends, whether normal stanzas
or specialized stream-checking traffic such as the application-level
pings defined in [XEP-0199] or the more comprehensive stream
Saint-Andre Expires February 10, 2011 [Page 30]
Internet-Draft XMPP Core August 2010
management protocol defined in [XEP-0198]. In this case, it is
appropriate for the entity to close a broken stream using the
stream error described under Section 4.8.3.4.
4.5.3. Idle Peer
Even if the underlying TCP connection is alive and the stream is not
broken, the peer might have sent no stanzas for a certain period of
time. In this case, the peer SHOULD close the stream using the
handshake described under Section 4.4. If the idle peer does not
close the stream, the other party MAY either close the stream using
the handshake described under Section 4.4 or return a stream error
(e.g., if the entity has reached a limit on
the number of open TCP connections or if the
connection has exceeded a local timeout policy). However, consistent
with the order of layers (specified under Section 13.3), the other
party is advised to verify that the underlying TCP connection is
alive and the stream is unbroken (as described above) before
concluding that the peer is idle. Furthermore, it is preferable to
be liberal in accepting idle peers, since experience has shown that
doing so improves the reliability of communication over XMPP networks
and that it is typically more efficient to maintain a stream between
two servers than to aggressively timeout such a stream.
4.5.4. Use of Checking Methods
Implementers are advised to support whichever stream-checking and
connection-checking methods they deem appropriate, but to carefully
weigh the network impact of such methods against the benefits of
discovering broken streams and dead TCP connections in a timely
manner. The length of time between the use of any particular check
is very much a matter of local service policy and depends strongly on
the network environment and usage scenarios of a given deployment and
connection type; at the time of writing, it is RECOMMENDED that any
such check be performed not more than once every 5 minutes and that,
ideally, such checks will be initiated by clients rather than
servers. Those who implement XMPP software and deploy XMPP services
are encouraged to seek additional advice regarding appropriate timing
of stream-checking and connection-checking methods, particularly when
power-constrained devices are being used (e.g., in mobile
environments).
4.6. Stream Attributes
The attributes of the root element are defined in the
following sections.
Saint-Andre Expires February 10, 2011 [Page 31]
Internet-Draft XMPP Core August 2010
Security Note: Until and unless the confidentiality and integrity
of a stream header is ensured via Transport Layer Security as
described under Section 5, the attributes provided in a stream
header could be tampered with by an attacker.
Implementation Note: The attributes of the root element
are not prepended by a namespace prefix because, as explained in
[XML-NAMES], "[d]efault namespace declarations do not apply
directly to attribute names; the interpretation of unprefixed
attributes is determined by the element on which they appear."
4.6.1. from
The 'from' attribute communicates an XMPP identity of the entity
sending the stream element.
For initial stream headers in client-to-server communication, if the
client knows the XMPP identity of the principal controlling the
client (typically an account name of the form
), then it SHOULD include the 'from' attribute
and set its value to that identity once the stream is in a state in
which it is willing to perform authentication, e.g. once TLS has been
negotiated. However, because the client might not know the XMPP
identity of the principal controlling the entity (e.g., because the
XMPP identity is assigned at a level other than the XMPP application
layer, as in the General Security Service Application Program
Interface [GSS-API]), inclusion of the 'from' address is OPTIONAL.
Security Note: Including the XMPP identity before the stream is
protected via TLS can expose that identity to eavesdroppers.
I:
For initial stream headers in server-to-server communication, a
server MUST include the 'from' attribute and MUST set the value to
one of its own hostnames (because the initiating entity might have
more than one XMPP identity, e.g., in the case of a server that
provides virtual hosting, it will need to choose an identity that is
associated with this stream).
Saint-Andre Expires February 10, 2011 [Page 32]
Internet-Draft XMPP Core August 2010
I:
For response stream headers in both client-to-server and server-to-
server communication, the receiving entity MUST include the 'from'
attribute and MUST set the value to one of the receiving entity's
hostnames (which MAY be a hostname other than that specified in the
'to' attribute of the initial stream header; see Section 4.8.1.3 and
Section 4.8.3.6).
R:
Whether or not the 'from' attribute is included, each entity MUST
verify the identity of the other entity before exchanging XML stanzas
with it, as described under Section 13.5.
Interoperability Note: It is possible that implementations based
on [RFC3920] will not include the 'from' address on stream
headers; an entity SHOULD be liberal in accepting such stream
headers.
4.6.2. to
For initial stream headers in both client-to-server and server-to-
server communication, the initiating entity MUST include the 'to'
attribute and MUST set its value to a hostname that the initiating
entity knows or expects the receiving entity to service. (The same
information can be provided in other ways, such as a server name
indication during TLS negotiation as described in [TLS-EXT].)
Saint-Andre Expires February 10, 2011 [Page 33]
Internet-Draft XMPP Core August 2010
I:
For response stream headers in client-to-server communication, if the
client included a 'from' attribute in the initial stream header then
the server MUST include a 'to' attribute in the response stream
header and MUST set its value to the bare JID specified in the 'from'
attribute of the initial stream header. If the client did not
include a 'from' attribute in the initial stream header then the
server MUST NOT include a 'to' attribute in the response stream
header.
R:
For response stream headers in server-to-server communication, the
receiving entity MUST include a 'to' attribute in the response stream
header and MUST set its value to the hostname specified in the 'from'
attribute of the initial stream header.
R:
Whether or not the 'to' attribute is included, each entity MUST
verify the identity of the other entity before exchanging XML stanzas
with it, as described under Section 13.5.
Saint-Andre Expires February 10, 2011 [Page 34]
Internet-Draft XMPP Core August 2010
Interoperability Note: It is possible that implementations based
on [RFC3920] will not include the 'to' address on stream headers;
an entity SHOULD be liberal in accepting such stream headers.
4.6.3. id
The 'id' attribute communicates a unique identifier for the stream,
called a STREAM ID. The stream ID MUST be generated by the receiving
entity when it sends a response stream header and MUST BE unique
within the receiving application (normally a server).
Security Note: The stream ID MUST be both unpredictable and non-
repeating because it can be security-critical (see [RANDOM] for
recommendations regarding randomness for security purposes).
For initial stream headers, the initiating entity MUST NOT include
the 'id' attribute; however, if the 'id' attribute is included, the
receiving entity MUST ignore it.
For response stream headers, the receiving entity MUST include the
'id' attribute.
R:
4.6.4. xml:lang
The 'xml:lang' attribute communicates an entity's preferred or
default language for any human-readable XML character data to be sent
over the stream (an XML stanza can also possess an 'xml:lang'
attribute, as discussed under Section 8.1.5). The syntax of this
attribute is defined in Section 2.12 of [XML]; in particular, the
value of the 'xml:lang' attribute MUST conform to the NMTOKEN
datatype (as defined in Section 2.3 of [XML]) and MUST conform to the
language identifier format defined in [LANGTAGS].
For initial stream headers, the initiating entity SHOULD include the
'xml:lang' attribute.
Saint-Andre Expires February 10, 2011 [Page 35]
Internet-Draft XMPP Core August 2010
I:
For response stream headers, the receiving entity MUST include the
'xml:lang' attribute. The following rules apply:
o If the initiating entity included an 'xml:lang' attribute in its
initial stream header and the receiving entity supports that
language in the human-readable XML character data that it
generates and sends to the initiating entity (e.g., in the
element for stream and stanza errors), the value of the 'xml:lang'
attribute MUST be the identifier for the initiating entity's
preferred language (e.g., "de-CH").
o If the receiving entity supports a language that closely matches
the initiating entity's preferred language (e.g., "de" instead of
"de-CH"), then the value of the 'xml:lang' attribute SHOULD be the
identifier for the matching language (e.g., "de") but MAY be the
identifier for the default language of the receiving entity (e.g.,
"en").
o If the receiving entity does not support the initiating entity's
preferred language or a closely matching language (or if the
initiating entity did not include the 'xml:lang' attribute in its
initial stream header), then the value of the 'xml:lang' attribute
MUST be the identifier for the default language of the receiving
entity (e.g., "en").
R:
If the initiating entity included the 'xml:lang' attribute in its
initial stream header, the receiving entity SHOULD remember that
value as the default xml:lang for all stanzas sent by the initiating
entity over the current stream. As described under Section 8.1.5,
the initiating entity MAY include the 'xml:lang' attribute in any XML
stanzas it sends over the stream. If the initiating entity does not
Saint-Andre Expires February 10, 2011 [Page 36]
Internet-Draft XMPP Core August 2010
include the 'xml:lang' attribute in any such stanza, the receiving
entity SHOULD add the 'xml:lang' attribute to the stanza, where the
value of the attribute MUST be the identifier for the language
preferred by the initiating entity (even if the receiving entity does
not support that language for human-readable XML character data it
generates and sends to the initiating entity, such as in stream or
stanza errors). If the initiating entity includes the 'xml:lang'
attribute in any such stanza, the receiving entity MUST NOT modify or
delete it.
4.6.5. version
The inclusion of the version attribute set to a value of at least
"1.0" signals support for the stream-related protocols defined in
this specification, including TLS negotiation (Section 5), SASL
negotiation (Section 6), stream features (Section 4.2.2), and stream
errors (Section 4.8).
The version of XMPP specified in this specification is "1.0"; in
particular, XMPP 1.0 encapsulates the stream-related protocols as
well as the basic semantics of the three defined XML stanza types
(, , and ).
The numbering scheme for XMPP versions is ".". The
major and minor numbers MUST be treated as separate integers and each
number MAY be incremented higher than a single digit. Thus, "XMPP
2.4" would be a lower version than "XMPP 2.13", which in turn would
be lower than "XMPP 12.3". Leading zeros (e.g., "XMPP 6.01") MUST be
ignored by recipients and MUST NOT be sent.
The major version number will be incremented only if the stream and
stanza formats or obligatory actions have changed so dramatically
that an older version entity would not be able to interoperate with a
newer version entity if it simply ignored the elements and attributes
it did not understand and took the actions defined in the older
specification.
The minor version number will be incremented only if significant new
capabilities have been added to the core protocol (e.g., a newly
defined value of the 'type' attribute for message, presence, or IQ
stanzas). The minor version number MUST be ignored by an entity with
a smaller minor version number, but MAY be used for informational
purposes by the entity with the larger minor version number (e.g.,
the entity with the larger minor version number would simply note
that its correspondent would not be able to understand that value of
the 'type' attribute and therefore would not send it).
The following rules apply to the generation and handling of the
Saint-Andre Expires February 10, 2011 [Page 37]
Internet-Draft XMPP Core August 2010
'version' attribute within stream headers:
1. The initiating entity MUST set the value of the 'version'
attribute in the initial stream header to the highest version
number it supports (e.g., if the highest version number it
supports is that defined in this specification, it MUST set the
value to "1.0").
2. The receiving entity MUST set the value of the 'version'
attribute in the response stream header to either the value
supplied by the initiating entity or the highest version number
supported by the receiving entity, whichever is lower. The
receiving entity MUST perform a numeric comparison on the major
and minor version numbers, not a string match on
".".
3. If the version number included in the response stream header is
at least one major version lower than the version number included
in the initial stream header and newer version entities cannot
interoperate with older version entities as described, the
initiating entity SHOULD generate an
stream error.
4. If either entity receives a stream header with no 'version'
attribute, the entity MUST consider the version supported by the
other entity to be "0.9" and SHOULD NOT include a 'version'
attribute in the response stream header.
4.6.6. Summary of Stream Attributes
The following table summarizes the attributes of the root
element.
+----------+--------------------------+-------------------------+
| | initiating to receiving | receiving to initiating |
+----------+--------------------------+-------------------------+
| to | JID of receiver | JID of initiator |
| from | JID of initiator | JID of receiver |
| id | ignored | stream identifier |
| xml:lang | default language | default language |
| version | XMPP 1.0+ supported | XMPP 1.0+ supported |
+----------+--------------------------+-------------------------+
4.7. Namespaces
Readers are referred to the specification of XML namespaces
[XML-NAMES] for a full understanding of the concepts used in this
section.
Saint-Andre Expires February 10, 2011 [Page 38]
Internet-Draft XMPP Core August 2010
4.7.1. Streams Namespace
The root element ("stream header") MUST be qualified by the
namespace 'http://etherx.jabber.org/streams' (the "streams
namespace"). If this rule is violated, the entity that receives the
offending stream header MUST return a stream error to the sending
entity, which SHOULD be (although some existing
implementations send instead).
4.7.2. Default Namespace
An entity MAY declare a default namespace for data sent over the
stream. If so, (1) the default namespace MUST be other than the
streams namespace, and (2) the default namespace MUST be the same for
the initial stream and the response stream so that both streams are
qualified consistently. The default namespace applies to all first-
level child elements sent over the stream unless explicitly qualified
by another namespace.
Alternatively (i.e., instead of declaring a default namespace), an
entity MAY explicitly qualify the namespace for each first-level
child element of the stream, using so-called "prefix-free
canonicalization".
When a default namespace is declared, in rough outline a stream will
look something like the following.
foo
When a default namespace is not declared and so-called "prefix-free
canonicalization" is used instead, in rough outline a stream will
look something like the following.
Saint-Andre Expires February 10, 2011 [Page 39]
Internet-Draft XMPP Core August 2010
foo
Historically, most XMPP implementations have used the default
namespace style rather than the prefix-free canonicalization style
for stream headers; however, both styles are acceptable since they
are semantically equivalent.
4.7.3. Other Namespaces
Either party to a stream MAY send data qualified by namespaces other
than the default namespace (if declared) and the streams namespace.
For example, this is how data related to TLS negotiation and SASL
negotiation are exchanged, as well as XMPP extensions such as server
dialback [XEP-0220] and stream management [XEP-0198].
4.7.4. Namespace Declarations and Prefixes
Because the default namespace is other than the streams namespace, if
a default namespace is declared then the following statements are
true:
1. The stream header needs to contain a namespace declaration for
both the default namespace and the streams namespace.
2. The streams namespace declaration needs to include a namespace
prefix for the streams namespace.
Interoperability Note: For historical reasons, an implementation
MAY accept only the prefix 'stream' for the streams namespace
(resulting in prefixed names such as and ). If an entity receives a stream header with a streams
namespace prefix it does not accept, it MUST return a stream error
to the sending entity, which SHOULD be
(although some existing implementations send
instead).
By definition, the namespace declaration for the default namespace
will not include a namespace prefix (e.g., "xmlns='jabber:client'").
Furthermore, an implementation MUST NOT generate namespace prefixes
Saint-Andre Expires February 10, 2011 [Page 40]
Internet-Draft XMPP Core August 2010
for elements qualified by the default namespace if the default
namespace is 'jabber:client' or 'jabber:server'.
Namespaces declared in a stream header MUST apply only to that stream
(e.g., the 'jabber:server:dialback' namespace used in server dialback
[XEP-0220]). In particular, because XML stanzas intended for routing
or delivery over streams with other entities will lose the namespace
context declared in the header of the stream in which those stanzas
originated, namespaces for extended content within such stanzas MUST
NOT be declared in that stream header (see also Section 8.4). If
either party to a stream declares such namespaces, the other party to
the stream SHOULD close the stream with a stream error of . In any case, an entity MUST ensure that such namespaces
are properly declared (according to this section) when routing or
delivering stanzas originating from such a stream over streams with
other entities.
4.7.5. Mandatory-to-Implement Default Namespaces
XMPP as defined in this specification uses two default namespaces:
'jabber:client' and 'jabber:server'. These namespaces are nearly
identical but are used in different contexts (client-to-server
communication for 'jabber:client' and server-to-server communication
for 'jabber:server'). The only difference between the two is that
the 'to' and 'from' attributes are OPTIONAL on stanzas sent over XML
streams qualified by the 'jabber:client' namespace, whereas they are
REQUIRED on stanzas sent over XML streams qualified by the 'jabber:
server' namespace. Support for these default namespaces implies
support for the common attributes (Section 8.1) and basic semantics
(Section 8.2) of all three core stanza types (message, presence, and
IQ).
An implementation MAY support default namespaces other than 'jabber:
client' or 'jabber:server'. However, because such namespaces would
define applications other than XMPP, they are to be defined in
separate specifications.
An implementation MAY refuse to support any other default namespaces.
If an entity receives a first-level child element qualified by a
default namespace it does not support, it MUST return an stream error.
Client implementations MUST support the 'jabber:client' default
namespace.
Server implementations MUST support both the 'jabber:client' default
namespace (when the stream is used for communication between a client
and a server) and the 'jabber:server' default namespace (when the
Saint-Andre Expires February 10, 2011 [Page 41]
Internet-Draft XMPP Core August 2010
stream is used for communication between two servers).
Implementation Note: Because a client sends stanzas over a stream
whose default namespace is 'jabber:client', if the server to which
the client is connected needs to route a client-generated stanza
to another server then it MUST "re-scope" the stanza so that its
default namespace is 'jabber:server' (i.e., it MUST NOT send a
stanza qualified by the 'jabber:client' namespace over a stream
whose default namespace is 'jabber:server'). Similarly, a routing
server MUST "re-scope" a stanza received over a server-to-server
stream (whose default namespace is 'jabber:server') so that the
stanza is qualified by the 'jabber:client' namespace before
sending it over a client-to-server stream (whose default namespace
is 'jabber:client').
4.8. Stream Errors
The root stream element MAY contain an child element that is
prefixed by the streams namespace prefix. The error child SHALL be
sent by a compliant entity if it perceives that a stream-level error
has occurred.
4.8.1. Rules
The following rules apply to stream-level errors.
4.8.1.1. Stream Errors Are Unrecoverable
Stream-level errors are unrecoverable. Therefore, if an error occurs
at the level of the stream, the entity that detects the error MUST
send an element with an appropriate child element that
specifies the error condition and immediately close the stream as
described under Section 4.4.
C: No closing tag!
S:
The entity that generates the stream error then shall close the
stream as explained under Section 4.4.
C:
Saint-Andre Expires February 10, 2011 [Page 42]
Internet-Draft XMPP Core August 2010
4.8.1.2. Stream Errors Can Occur During Setup
If the error is triggered by the initial stream header, the receiving
entity MUST still send the opening tag, include the
element as a child of the stream element, and send the closing
tag (preferably all at the same time).
C:
S:
4.8.1.3. Stream Errors When the Host is Unspecified or Unknown
If the initiating entity provides no 'to' attribute or provides an
unknown host in the 'to' attribute and the error occurs during stream
setup, the value of the 'from' attribute returned by the receiving
entity in the stream header sent before closing the stream MUST be
either an authoritative hostname for the receiving entity or the
empty string.
Saint-Andre Expires February 10, 2011 [Page 43]
Internet-Draft XMPP Core August 2010
C:
S:
4.8.1.4. Where Stream Errors Are Sent
When two TCP connections are used between the initiating entity and
the receiving entity (one in each direction) rather than using a
single bidirectional connection, the following rules apply:
o Stanza errors triggered by outbound stanzas sent from the
initiating entity over the initial stream via the first TCP
connection are returned by the receiving entity on the response
stream via the second TCP connection (since they are inbound
stanzas from the perspective of the initiating entity).
o By contrast, stream-level errors related to the initial stream are
returned by the receiving entity on the response stream via the
first TCP connection.
4.8.2. Syntax
The syntax for stream errors is as follows, where "defined-condition"
is a placeholder for one of the conditions defined under
Section 4.8.3 and XML data shown within the square brackets '[' and
']' is OPTIONAL.
Saint-Andre Expires February 10, 2011 [Page 44]
Internet-Draft XMPP Core August 2010
[
[ ... descriptive text ... ]
]
[application-specific condition element]
The element:
o MUST contain a child element corresponding to one of the defined
stream error conditions (Section 4.8.3); this element MUST be
qualified by the 'urn:ietf:params:xml:ns:xmpp-streams' namespace.
o MAY contain a child element containing XML character data
that describes the error in more detail; this element MUST be
qualified by the 'urn:ietf:params:xml:ns:xmpp-streams' namespace
and SHOULD possess an 'xml:lang' attribute specifying the natural
language of the XML character data.
o MAY contain a child element for an application-specific error
condition; this element MUST be qualified by an application-
defined namespace, and its structure is defined by that namespace
(see Section 4.8.4).
The element is OPTIONAL. If included, it MUST be used only
to provide descriptive or diagnostic information that supplements the
meaning of a defined condition or application-specific condition. It
MUST NOT be interpreted programmatically by an application. It MUST
NOT be used as the error message presented to a human user, but MAY
be shown in addition to the error message associated with the defined
condition element (and, optionally, the application-specific
condition element).
4.8.3. Defined Stream Error Conditions
The following stream-level error conditions are defined.
4.8.3.1. bad-format
The entity has sent XML that cannot be processed.
(In the following example, the client sends an XMPP message that is
not well-formed XML, which alternatively might trigger an stream error.)
Saint-Andre Expires February 10, 2011 [Page 45]
Internet-Draft XMPP Core August 2010
C:
No closing tag!
S:
This error MAY be used instead of the more specific XML-related
errors, such as , , , , and . However,
the more specific errors are RECOMMENDED.
4.8.3.2. bad-namespace-prefix
The entity has sent a namespace prefix that is unsupported, or has
sent no namespace prefix on an element that needs such a prefix (see
Section 11.2).
(In the following example, the client specifies a namespace prefix of
"foobar" for the XML streams namespace.)
C:
S:
Saint-Andre Expires February 10, 2011 [Page 46]
Internet-Draft XMPP Core August 2010
4.8.3.3. conflict
The server either (1) is closing the existing stream for this entity
because a new stream has been initiated that conflicts with the
existing stream, or (2) is refusing a new stream for this entity
because allowing the new stream would conflict with an existing
stream (e.g., because the server allows only a certain number of
connections from the same IP address).
C:
S:
4.8.3.4. connection-timeout
One party is closing the stream because it has reason to believe that
the other party has permanently lost the ability to communicate over
the stream. The lack of ability to communicate can be discovered
using various methods, such as whitespace keepalives as specified
under Section 4.4, XMPP-level pings as defined in [XEP-0199], and
XMPP stream management as defined in [XEP-0198].
P:
Saint-Andre Expires February 10, 2011 [Page 47]
Internet-Draft XMPP Core August 2010
Interoperability Note: RFC 3920 specified that the stream error is to be used if the peer has not generated
any traffic over the stream for some period of time. That
behavior is no longer recommended; instead, the error SHOULD be
used only if the connected client or peer server has not responded
to data sent over the stream.
4.8.3.5. host-gone
The value of the 'to' attribute provided in the initial stream header
corresponds to a hostname that is no longer serviced by the receiving
entity.
(In the following example, the peer specifies a 'to' address of
"foo.im.example.com" when connecting to the "im.example.com" server,
but the server no longer hosts a service at that address.)
P:
S:
4.8.3.6. host-unknown
The value of the 'to' attribute provided in the initial stream header
does not correspond to a hostname that is serviced by the receiving
entity.
(In the following example, the peer specifies a 'to' address of
"example.org" when connecting to the "im.example.com" server, but the
Saint-Andre Expires February 10, 2011 [Page 48]
Internet-Draft XMPP Core August 2010
server knows nothing of that address.)
P:
S:
4.8.3.7. improper-addressing
A stanza sent between two servers lacks a 'to' or 'from' attribute,
the 'from' or 'to' attribute has no value, or the value is not a
valid XMPP address.
(In the following example, the peer sends a stanza without a 'to'
address over a server-to-server stream.)
P:
Wherefore art thou?
S:
Saint-Andre Expires February 10, 2011 [Page 49]
Internet-Draft XMPP Core August 2010
4.8.3.8. internal-server-error
The server has experienced a misconfiguration or an otherwise-
undefined internal error that prevents it from servicing the stream.
S:
4.8.3.9. invalid-from
The JID or hostname provided in a 'from' address is not a valid JID
or does not match an authorized JID or validated domain as negotiated
between servers via SASL or server dialback, or as negotiated between
a client and a server via authentication and resource binding.
(In the following example, a peer that has authenticated only as
"example.net" attempts to send a stanza from an address at
"example.org".)
P:
Neither, fair saint, if either thee dislike.
S:
4.8.3.10. invalid-namespace
The streams namespace name is something other than
"http://etherx.jabber.org/streams" (see Section 11.2) or the default
namespace is not supported (e.g., something other than "jabber:
client" or "jabber:server").
(In the following example, the client specifies a namespace of
'http://wrong.namespace.example.org/' for the stream.)
Saint-Andre Expires February 10, 2011 [Page 50]
Internet-Draft XMPP Core August 2010
C:
S:
4.8.3.11. invalid-xml
The entity has sent invalid XML over the stream to a server that
performs validation (see Section 11.4).
(In the following example, the peer attempts to send an IQ stanza of
type "subscribe" but the XML schema defines no such value for the
'type' attribute.)
P:
S:
Saint-Andre Expires February 10, 2011 [Page 51]
Internet-Draft XMPP Core August 2010
4.8.3.12. not-authorized
The entity has attempted to send XML stanzas before the stream has
been authenticated, or otherwise is not authorized to perform an
action related to stream negotiation; the receiving entity MUST NOT
process the offending stanza before sending the stream error.
(In the following example, the client attempts to send XML stanzas
before authenticating with the server.)
C:
S:
Wherefore art thou?
S:
4.8.3.13. policy-violation
The entity has violated some local service policy (e.g., the stanza
exceeds a configured size limit); the server MAY choose to specify
the policy in the element or in an application-specific
condition element.
(In the following example, the client sends an XMPP message that is
too large according to the server's local service policy.)
Saint-Andre Expires February 10, 2011 [Page 52]
Internet-Draft XMPP Core August 2010
C:
[ ... the-emacs-manual ... ]
S:
S:
4.8.3.14. remote-connection-failed
The server is unable to properly connect to a remote entity that is
needed for authentication or authorization, such as a remote
authentication database or (in server dialback) the authoritative
server.
C:
S:
4.8.3.15. reset
The server is closing the stream because it has new (typically
security-critical) features to offer or because it needs to reset the
stream for some other reason (e.g., because the certificates used to
establish a secure context for the stream have expired or have been
Saint-Andre Expires February 10, 2011 [Page 53]
Internet-Draft XMPP Core August 2010
revoked during the life of the stream).
S:
4.8.3.16. resource-constraint
The server lacks the system resources necessary to service the
stream.
C:
S:
4.8.3.17. restricted-xml
The entity has attempted to send restricted XML features such as a
comment, processing instruction, DTD subset, or XML entity reference
(see Section 11.1).
(In the following example, the client sends an XMPP message
containing an XML comment.)
Saint-Andre Expires February 10, 2011 [Page 54]
Internet-Draft XMPP Core August 2010
C:
This message has no subject.
S:
4.8.3.18. see-other-host
The server will not provide service to the initiating entity but is
redirecting traffic to another host; the XML character data of the
element returned by the server SHOULD specify the
alternate hostname or IP address at which to connect, which SHOULD be
a valid domainpart but MAY also include a port number. When it
receives a see-other-host stream error, the initiating entity SHOULD
cleanly handle the disconnection and then reconnect to the host
specified in the element; if no port is specified,
the initiating entity SHOULD perform a [DNS-SRV] lookup on the
provided domainpart but MAY assume that it can connect to that
domainpart at the standard XMPP ports (i.e., 5222 for client-to-
server connections and 5269 for server-to-server connections).
Saint-Andre Expires February 10, 2011 [Page 55]
Internet-Draft XMPP Core August 2010
C:
S:
[2001:41D0:1:A49b::1]:9222
4.8.3.19. system-shutdown
The server is being shut down and all active streams are being
closed.
S:
4.8.3.20. undefined-condition
The error condition is not one of those defined by the other
conditions in this list; this error condition SHOULD be used only in
conjunction with an application-specific condition.
S:
Saint-Andre Expires February 10, 2011 [Page 56]
Internet-Draft XMPP Core August 2010
4.8.3.21. unsupported-encoding
The initiating entity has encoded the stream in an encoding that is
not supported by the server (see Section 11.6) or has otherwise
improperly encoded the stream (e.g., by violating the rules of the
[UTF-8] encoding).
(In the following example, the client attempts to encode data using
UTF-16 instead of UTF-8.)
C:
S:
4.8.3.22. unsupported-feature
The receiving entity has advertised a mandatory stream feature that
the initiating entity does not support, and has offered no other
mandatory feature alongside the unsupported feature.
(In the following example, the receiving entity requires negotiation
of an example feature but the initiating entity does not support the
feature.)
Saint-Andre Expires February 10, 2011 [Page 57]
Internet-Draft XMPP Core August 2010
R:
I:
4.8.3.23. unsupported-stanza-type
The initiating entity has sent a first-level child of the stream that
is not supported by the server, either because the receiving entity
does not understand the namespace or because receiving entity does
not understand the element name for the applicable namespace (which
might be the default namespace).
(In the following example, the client attempts to send a first-level
child element of qualified by the 'jabber:client'
namespace, but the schema for that namespace defines no such
element.)
Saint-Andre Expires February 10, 2011 [Page 58]
Internet-Draft XMPP Core August 2010
C: Soliloquy
To be, or not to be: that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing end them?
tag:denmark.example,2003:entry-323972003-12-13T18:30:02Z2003-12-13T18:30:02Z
S:
4.8.3.24. unsupported-version
The value of the 'version' attribute provided by the initiating
entity in the stream header specifies a version of XMPP that is not
supported by the server.
Saint-Andre Expires February 10, 2011 [Page 59]
Internet-Draft XMPP Core August 2010
C:
S:
4.8.3.25. xml-not-well-formed
The initiating entity has sent XML that violates the well-formedness
rules of [XML] or [XML-NAMES].
(In the following example, the client sends an XMPP message that is
not namespace-well-formed.)
C:

What is this foo?

S:
4.8.4. Application-Specific Conditions
As noted, an application MAY provide application-specific stream
error information by including a properly-namespaced child in the
error element. The application-specific element SHOULD supplement or
further qualify a defined element. Thus the element will
contain two or three child elements.
Saint-Andre Expires February 10, 2011 [Page 60]
Internet-Draft XMPP Core August 2010
C:
My keyboard layout is:
QWERTYUIOP{}|
ASDFGHJKL:"
ZXCVBNM<>?
S:
Some special application diagnostic information!
4.9. Simplified Stream Examples
This section contains two simplified examples of a stream-based
connection between a client and a server; these examples are included
for the purpose of illustrating the concepts introduced thus far.
Saint-Andre Expires February 10, 2011 [Page 61]
Internet-Draft XMPP Core August 2010
A basic connection:
C:
S:
[ ... channel encryption ... ]
[ ... authentication ... ]
[ ... resource binding ... ]
C:
Art thou not Romeo, and a Montague?
S:
Neither, fair saint, if either thee dislike.
C:
S:
Saint-Andre Expires February 10, 2011 [Page 62]
Internet-Draft XMPP Core August 2010
A connection gone bad:
C:
S:
[ ... channel encryption ... ]
[ ... authentication ... ]
[ ... resource binding ... ]
C:
No closing tag!
S:
More detailed examples are provided under Section 9.
5. STARTTLS Negotiation
Saint-Andre Expires February 10, 2011 [Page 63]
Internet-Draft XMPP Core August 2010
5.1. Overview
XMPP includes a method for securing the stream from tampering and
eavesdropping. This channel encryption method makes use of the
Transport Layer Security [TLS] protocol, specifically a "STARTTLS"
extension that is modelled after similar extensions for the [IMAP],
[POP3], and [ACAP] protocols as described in [USINGTLS]. The XML
namespace name for the STARTTLS extension is
'urn:ietf:params:xml:ns:xmpp-tls'.
Support for STARTTLS is REQUIRED in XMPP client and server
implementations. An administrator of a given deployment MAY specify
that TLS is obligatory for client-to-server communication, server-to-
server communication, or both. An initiating entity SHOULD use TLS
to secure its stream with the receiving entity before proceeding with
SASL authentication.
5.2. Stream Negotiation Rules
5.2.1. Mandatory-to-Negotiate
If the receiving entity advertises only the STARTTLS feature or if
the receiving entity includes the child element as
explained under Section 5.3.1, the parties MUST consider TLS as
mandatory-to-negotiate. If TLS is mandatory-to-negotiate, the
receiving entity SHOULD NOT advertise support for any stream feature
except STARTTLS during the initial stage of the stream negotiation
process, because further stream features might depend on prior
negotiation of TLS given the order of layers in XMPP (e.g., the
particular SASL mechanisms offered by the receiving entity will
likely depend on whether TLS has been negotiated).
5.2.2. Restart
After TLS negotiation, the parties MUST restart the stream.
5.2.3. Data Formatting
During STARTTLS negotiation, the entities MUST NOT send any
whitespace as separators between XML elements (i.e., from the last
character of the element qualified by the
'urn:ietf:params:xml:ns:xmpp-tls' namespace at depth=1 of the stream
as sent by the initiating entity, until the last character of the
element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls'
namespace at depth=1 of the stream as sent by the receiving entity).
This prohibition helps to ensure proper security layer byte
precision. Any such whitespace shown in the STARTTLS examples
provided in this document is included only for the sake of
Saint-Andre Expires February 10, 2011 [Page 64]
Internet-Draft XMPP Core August 2010
readability.
5.2.4. Order of TLS and SASL Negotiations
If the initiating entity chooses to use TLS, STARTTLS negotiation
MUST be completed before proceeding to SASL negotiation (Section 6);
this order of negotiation is necessary to help safeguard
authentication information sent during SASL negotiation, as well as
to make it possible to base the use of the SASL EXTERNAL mechanism on
a certificate (or other credentials) provided during prior TLS
negotiation.
5.2.5. TLS Renegotiation
The TLS protocol allows either party in a TLS-protected channel to
initiate a new handshake that establishes new cryptographic
parameters (see [TLS-NEG]). The cases most commonly mentioned are:
1. Refreshing encryption keys.
2. Wrapping the TLS sequence number as explained in Section 6.1 of
[TLS].
3. Protecting client credentials by completing server authentication
first and then completing client authentication over the
protected channel.
Because it is relatively inexpensive to establish streams in XMPP,
for the first two cases it is preferable to use an XMPP stream reset
(as described under Section 4.8.3.15) instead of performing TLS
renegotiation.
The third case has improved security characteristics when the TLS
client (which might be an XMPP server) presents credentials to the
TLS server. If communicating such credentials to an unauthenticated
server might leak private information, it can be appropriate to
complete TLS negotiation for the purpose of server authentication and
then attempt TLS renegotiation for the purpose of client
authentication with the TLS server.
However, the third case is sufficiently rare that XMPP entities
SHOULD NOT blindly attempt TLS renegotiation.
If an entity that does not support TLS renegotiation detects a
renegotiation attempt, then it MUST immediately close the underlying
TCP connection without returning a stream error (since the violation
has occurred at the TLS layer, not the XMPP layer; see Section 13.3).
Saint-Andre Expires February 10, 2011 [Page 65]
Internet-Draft XMPP Core August 2010
If an entity that supports TLS renegotiation detects a TLS
renegotiation attempt that does not use the TLS Renegotiation
Extension [TLS-NEG], then it MUST immediately close the underlying
TCP connection without returning a stream error (since the violation
has occurred at the TLS layer, not the XMPP layer; see Section 13.3).
Support for TLS renegotiation is strictly OPTIONAL. However,
implementations that support TLS renegotiation MUST implement and use
the TLS Renegotiation Extension [TLS-NEG].
5.2.6. TLS Extensions
Either party to a stream MAY include any TLS extension during the TLS
negotiation itself. This is a matter for the TLS layer, not the XMPP
layer.
5.3. Process
5.3.1. Exchange of Stream Headers and Stream Features
The initiating entity resolves the hostname of the receiving entity
as specified under Section 3, opens a TCP connection to the
advertised port at the resolved IP address, and sends an initial
stream header to the receiving entity; if the initiating entity is
capable of STARTTLS negotiation, it MUST include the 'version'
attribute set to a value of at least "1.0" in the initial stream
header.
I:
The receiving entity MUST send a response stream header to the
initiating entity over the TCP connection opened by the initiating
entity; if the receiving entity is capable of STARTTLS negotiation,
it MUST include the 'version' attribute set to a value of at least
"1.0" in the response stream header.
Saint-Andre Expires February 10, 2011 [Page 66]
Internet-Draft XMPP Core August 2010
R: element qualified by the
'urn:ietf:params:xml:ns:xmpp-tls' namespace.
If the receiving entity considers STARTTLS negotiation to be
mandatory, the element SHOULD contain an empty
child element.
R:
5.3.2. Initiation of STARTTLS Negotiation
5.3.2.1. STARTTLS Command
In order to begin the STARTTLS negotiation, the initiating entity
issues the STARTTLS command (i.e., a element qualified by
the 'urn:ietf:params:xml:ns:xmpp-tls' namespace) to instruct the
receiving entity that it wishes to begin a STARTTLS negotiation to
secure the stream.
I:
The receiving entity MUST reply with either a element
(proceed case) or a element (failure case) qualified by
the 'urn:ietf:params:xml:ns:xmpp-tls' namespace.
5.3.2.2. Failure Case
If the failure case occurs, the receiving entity MUST return a
element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls'
namespace and close the XML stream.
Saint-Andre Expires February 10, 2011 [Page 67]
Internet-Draft XMPP Core August 2010
R:
R:
Causes for the failure case include but are not limited to:
1. The initiating entity has sent a malformed STARTTLS command.
2. The receiving entity did not offer the STARTTLS feature in its
stream features.
3. The receiving entity cannot complete STARTTLS negotiation because
of an internal error.
Informational Note: STARTTLS failure is not triggered by TLS
errors such as bad_certificate or handshake_failure, which are
generated and handled during the TLS negotiation itself as
described in [TLS].
If the failure case occurs, the initiating entity MAY attempt to
reconnect as explained under Section 3.3.
5.3.2.3. Proceed Case
If the proceed case occurs, the receiving entity MUST return a
element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls'
namespace.
R:
The receiving entity MUST consider the TLS negotiation to have begun
immediately after sending the closing '>' character of the
element to the initiating entity. The initiating entity MUST
consider the TLS negotiation to have begun immediately after
receiving the closing '>' character of the element from
the receiving entity.
The entities now proceed to TLS negotiation as explained in the next
section.
5.3.3. TLS Negotiation
5.3.3.1. Rules
In order to complete TLS negotiation over the TCP connection, the
entities MUST follow the process defined in [TLS].
The following rules apply:
Saint-Andre Expires February 10, 2011 [Page 68]
Internet-Draft XMPP Core August 2010
1. The entities MUST NOT send any further XML data until the TLS
negotiation is complete.
2. When using any of the mandatory-to-implement cipher suites
specified under Section 13.8, the receiving entity MUST present a
certificate.
3. So that mutual authentication will be possible, the receiving
entity SHOULD send a certificate request to the initiating entity
and the initiating entity SHOULD send a certificate (if
available) to the receiving entity.
4. The initiating entity MUST validate the certificate to determine
if the TLS negotiation will succeed; see Section 13.7.2 regarding
certificate validation procedures.
5. The receiving entity SHOULD choose which certificate to present
based on the 'to' attribute of the initial stream header.
6. Following successful TLS negotiation, all further data
transmitted by either party MUST be encrypted.
Security Note: See Section 13.8 regarding ciphers that MUST be
supported for TLS; naturally, other ciphers MAY be supported as
well.
5.3.3.2. TLS Failure
If the TLS negotiation results in failure, the receiving entity MUST
terminate the TCP connection.
The receiving entity MUST NOT send a closing tag before
terminating the TCP connection, since the receiving entity and
initiating entity MUST consider the original stream to be replaced
upon failure of the TLS negotiation.
The initiating entity MAY attempt to reconnect as explained under
Section 3.3, with or without attempting TLS negotiation (in
accordance with local service policy, user-configured prefernces,
etc.).
5.3.3.3. TLS Success
If the TLS negotiation is successful, then the entities MUST proceed
as follows.
Saint-Andre Expires February 10, 2011 [Page 69]
Internet-Draft XMPP Core August 2010
1. The initiating entity MUST discard any information transmitted in
layers above TCP that it obtained from the receiving entity in an
insecure manner before TLS took effect (e.g., the receiving
entity's 'from' address or the stream ID and stream features
received from the receiving entity).
2. The receiving entity MUST discard any information transmitted in
layers above TCP that it obtained from the initiating entity in
an insecure manner before TLS took effect (e.g., the initiating
entity's from address).
3. The initiating entity MUST send a new initial stream header to
the receiving entity over the encrypted connection.
I:
Implementation Note: The initiating entity MUST NOT send a
closing tag before sending the new initial stream
header, since the receiving entity and initiating entity MUST
consider the original stream to be replaced upon success of the
TLS negotiation.
4. The receiving entity MUST respond with a new response stream
header over the encrypted connection (for which it MUST generate
a new stream ID instead of re-using the old stream ID).
R: