summaryrefslogtreecommitdiff
path: root/dht/doc/rfc6120.html
blob: fa7ef0813d773798d3e31f31bf94de8ed7694846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en"><head><title>Extensible Messaging and Presence Protocol (XMPP): Core</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Extensible Messaging and Presence Protocol (XMPP): Core">
<meta name="keywords" content="XMPP, Extensible Messaging and Presence Protocol, Jabber, Messaging, Instant Messaging, Presence, Extensible Markup Language, XML">
<meta name="generator" content="xml2rfc v1.36 (http://xml.resource.org/)">
<style type='text/css'><!--
        body {
                font-family: verdana, charcoal, helvetica, arial, sans-serif;
                font-size: small; color: #000; background-color: #FFF;
                margin: 2em;
        }
        h1, h2, h3, h4, h5, h6 {
                font-family: helvetica, monaco, "MS Sans Serif", arial, sans-serif;
                font-weight: bold; font-style: normal;
        }
        h1 { color: #900; background-color: transparent; text-align: right; }
        h3 { color: #333; background-color: transparent; }

        td.RFCbug {
                font-size: x-small; text-decoration: none;
                width: 30px; height: 30px; padding-top: 2px;
                text-align: justify; vertical-align: middle;
                background-color: #000;
        }
        td.RFCbug span.RFC {
                font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
                font-weight: bold; color: #666;
        }
        td.RFCbug span.hotText {
                font-family: charcoal, monaco, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
                font-weight: normal; text-align: center; color: #FFF;
        }

        table.TOCbug { width: 30px; height: 15px; }
        td.TOCbug {
                text-align: center; width: 30px; height: 15px;
                color: #FFF; background-color: #900;
        }
        td.TOCbug a {
                font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, sans-serif;
                font-weight: bold; font-size: x-small; text-decoration: none;
                color: #FFF; background-color: transparent;
        }

        td.header {
                font-family: arial, helvetica, sans-serif; font-size: x-small;
                vertical-align: top; width: 33%;
                color: #FFF; background-color: #666;
        }
        td.author { font-weight: bold; font-size: x-small; margin-left: 4em; }
        td.author-text { font-size: x-small; }

        /* info code from SantaKlauss at http://www.madaboutstyle.com/tooltip2.html */
        a.info {
                /* This is the key. */
                position: relative;
                z-index: 24;
                text-decoration: none;
        }
        a.info:hover {
                z-index: 25;
                color: #FFF; background-color: #900;
        }
        a.info span { display: none; }
        a.info:hover span.info {
                /* The span will display just on :hover state. */
                display: block;
                position: absolute;
                font-size: smaller;
                top: 2em; left: -5em; width: 15em;
                padding: 2px; border: 1px solid #333;
                color: #900; background-color: #EEE;
                text-align: left;
        }

        a { font-weight: bold; }
        a:link    { color: #900; background-color: transparent; }
        a:visited { color: #633; background-color: transparent; }
        a:active  { color: #633; background-color: transparent; }

        p { margin-left: 2em; margin-right: 2em; }
        p.copyright { font-size: x-small; }
        p.toc { font-size: small; font-weight: bold; margin-left: 3em; }
        table.toc { margin: 0 0 0 3em; padding: 0; border: 0; vertical-align: text-top; }
        td.toc { font-size: small; font-weight: bold; vertical-align: text-top; }

        ol.text { margin-left: 2em; margin-right: 2em; }
        ul.text { margin-left: 2em; margin-right: 2em; }
        li      { margin-left: 3em; }

        /* RFC-2629 <spanx>s and <artwork>s. */
        em     { font-style: italic; }
        strong { font-weight: bold; }
        dfn    { font-weight: bold; font-style: normal; }
        cite   { font-weight: normal; font-style: normal; }
        tt     { color: #036; }
        tt, pre, pre dfn, pre em, pre cite, pre span {
                font-family: "Courier New", Courier, monospace; font-size: small;
        }
        pre {
                text-align: left; padding: 4px;
                color: #000; background-color: #CCC;
        }
        pre dfn  { color: #900; }
        pre em   { color: #66F; background-color: #FFC; font-weight: normal; }
        pre .key { color: #33C; font-weight: bold; }
        pre .id  { color: #900; }
        pre .str { color: #000; background-color: #CFF; }
        pre .val { color: #066; }
        pre .rep { color: #909; }
        pre .oth { color: #000; background-color: #FCF; }
        pre .err { background-color: #FCC; }

        /* RFC-2629 <texttable>s. */
        table.all, table.full, table.headers, table.none {
                font-size: small; text-align: center; border-width: 2px;
                vertical-align: top; border-collapse: collapse;
        }
        table.all, table.full { border-style: solid; border-color: black; }
        table.headers, table.none { border-style: none; }
        th {
                font-weight: bold; border-color: black;
                border-width: 2px 2px 3px 2px;
        }
        table.all th, table.full th { border-style: solid; }
        table.headers th { border-style: none none solid none; }
        table.none th { border-style: none; }
        table.all td {
                border-style: solid; border-color: #333;
                border-width: 1px 2px;
        }
        table.full td, table.headers td, table.none td { border-style: none; }

        hr { height: 1px; }
        hr.insert {
                width: 80%; border-style: none; border-width: 0;
                color: #CCC; background-color: #CCC;
        }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="2" width="30" align="right">
    <tr>
        <td class="RFCbug">
                <span class="RFC">&nbsp;RFC&nbsp;</span><br /><span class="hotText">&nbsp;6120&nbsp;</span>
        </td>
    </tr>
    <tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a><br /></td></tr>
</table>
<table summary="layout" width="66%" border="0" cellpadding="0" cellspacing="0"><tr><td><table summary="layout" width="100%" border="0" cellpadding="2" cellspacing="1">
<tr><td class="header">Internet Engineering Task Force (IETF)</td><td class="header">P. Saint-Andre</td></tr>
<tr><td class="header">Request for Comments: 6120</td><td class="header">Cisco</td></tr>
<tr><td class="header">Obsoletes: <a href='http://tools.ietf.org/html/rfc3920'>3920</a></td><td class="header">March 2011</td></tr>
<tr><td class="header">Category: Standards Track</td><td class="header">&nbsp;</td></tr>
<tr><td class="header">ISSN: 2070-1721</td><td class="header">&nbsp;</td></tr>
</table></td></tr></table>
<h1><br />Extensible Messaging and Presence Protocol (XMPP): Core</h1>

<h3>Abstract</h3>

<p>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.  This document obsoletes RFC 3920.
</p>
<h3>Status of This Memo</h3>
<p>
This is an Internet Standards Track document.</p>
<p>
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 5741.</p>
<p>
Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at http://www.rfc-editor.org/info/rfc6120.</p>

<h3>Copyright Notice</h3>
<p>
Copyright (c) 2011 IETF Trust and the persons identified as the
document authors.  All rights reserved.</p>
<p>
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
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.</p>
<a name="toc"></a><hr />

<table border="0" cellpadding="0" cellspacing="2" width="30" align="right">
    <tr>
        <td class="RFCbug">
                <span class="RFC">&nbsp;RFC&nbsp;</span><br /><span class="hotText">&nbsp;6120&nbsp;</span>
        </td>
    </tr>
    <tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a><br /></td></tr>
</table>
<h3>Table of Contents</h3>
<p class="toc">
<a href="#intro">1.</a>&nbsp;
Introduction<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#intro-overview">1.1.</a>&nbsp;
Overview<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#intro-history">1.2.</a>&nbsp;
History<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#intro-summary">1.3.</a>&nbsp;
Functional Summary<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#intro-terms">1.4.</a>&nbsp;
Terminology<br />
<a href="#arch">2.</a>&nbsp;
Architecture<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#arch-addresses">2.1.</a>&nbsp;
Global Addresses<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#arch-presence">2.2.</a>&nbsp;
Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#arch-streams">2.3.</a>&nbsp;
Persistent Streams<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#arch-data">2.4.</a>&nbsp;
Structured Data<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#arch-network">2.5.</a>&nbsp;
Distributed Network of Clients and Servers<br />
<a href="#tcp">3.</a>&nbsp;
TCP Binding<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tcp-scope">3.1.</a>&nbsp;
Scope<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tcp-resolution">3.2.</a>&nbsp;
Resolution of Fully Qualified Domain Names<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tcp-resolution-prefer">3.2.1.</a>&nbsp;
Preferred Process: SRV Lookup<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tcp-resolution-fallback">3.2.2.</a>&nbsp;
Fallback Processes<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tcp-resolution-srvnot">3.2.3.</a>&nbsp;
When Not to Use SRV<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tcp-resolution-srvadd">3.2.4.</a>&nbsp;
Use of SRV Records with Add-On Services<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tcp-reconnect">3.3.</a>&nbsp;
Reconnection<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-reliability">3.4.</a>&nbsp;
Reliability<br />
<a href="#streams">4.</a>&nbsp;
XML Streams<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-fundamentals">4.1.</a>&nbsp;
Stream Fundamentals<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-open">4.2.</a>&nbsp;
Opening a Stream<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-negotiation">4.3.</a>&nbsp;
Stream Negotiation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-negotiation-basics">4.3.1.</a>&nbsp;
Basic Concepts<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-negotiation-features">4.3.2.</a>&nbsp;
Stream Features Format<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-negotiation-restart">4.3.3.</a>&nbsp;
Restarts<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-negotiation-resend">4.3.4.</a>&nbsp;
Resending Features<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-negotiation-complete">4.3.5.</a>&nbsp;
Completion of Stream Negotiation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-negotiation-address">4.3.6.</a>&nbsp;
Determination of Addresses<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-negotiation-flowchart">4.3.7.</a>&nbsp;
Flow Chart<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-close">4.4.</a>&nbsp;
Closing a Stream<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-direction">4.5.</a>&nbsp;
Directionality<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-silence">4.6.</a>&nbsp;
Handling of Silent Peers<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-silence-dead">4.6.1.</a>&nbsp;
Dead Connection<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-silence-broken">4.6.2.</a>&nbsp;
Broken Stream<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-silence-idle">4.6.3.</a>&nbsp;
Idle Peer<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-silence-check">4.6.4.</a>&nbsp;
Use of Checking Methods<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-attr">4.7.</a>&nbsp;
Stream Attributes<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-attr-from">4.7.1.</a>&nbsp;
from<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-attr-to">4.7.2.</a>&nbsp;
to<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-attr-id">4.7.3.</a>&nbsp;
id<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-attr-xmllang">4.7.4.</a>&nbsp;
xml:lang<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-attr-version">4.7.5.</a>&nbsp;
version<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-attr-summary">4.7.6.</a>&nbsp;
Summary of Stream Attributes<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-ns">4.8.</a>&nbsp;
XML Namespaces<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-ns-stream">4.8.1.</a>&nbsp;
Stream Namespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-ns-content">4.8.2.</a>&nbsp;
Content Namespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-ns-xmpp">4.8.3.</a>&nbsp;
XMPP Content Namespaces<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-ns-other">4.8.4.</a>&nbsp;
Other Namespaces<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-ns-declarations">4.8.5.</a>&nbsp;
Namespace Declarations and Prefixes<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error">4.9.</a>&nbsp;
Stream Errors<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-rules">4.9.1.</a>&nbsp;
Rules<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-rules-unrecoverable">4.9.1.1.</a>&nbsp;
Stream Errors Are Unrecoverable<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-rules-setup">4.9.1.2.</a>&nbsp;
Stream Errors Can Occur During Setup<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-rules-host">4.9.1.3.</a>&nbsp;
Stream Errors When the Host Is Unspecified or Unknown<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-rules-where">4.9.1.4.</a>&nbsp;
Where Stream Errors Are Sent<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-syntax">4.9.2.</a>&nbsp;
Syntax<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions">4.9.3.</a>&nbsp;
Defined Stream Error Conditions<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-bad-format">4.9.3.1.</a>&nbsp;
bad-format<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-bad-namespace-prefix">4.9.3.2.</a>&nbsp;
bad-namespace-prefix<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-conflict">4.9.3.3.</a>&nbsp;
conflict<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-connection-timeout">4.9.3.4.</a>&nbsp;
connection-timeout<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-host-gone">4.9.3.5.</a>&nbsp;
host-gone<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-host-unknown">4.9.3.6.</a>&nbsp;
host-unknown<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-improper-addressing">4.9.3.7.</a>&nbsp;
improper-addressing<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-internal-server-error">4.9.3.8.</a>&nbsp;
internal-server-error<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-invalid-from">4.9.3.9.</a>&nbsp;
invalid-from<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-invalid-namespace">4.9.3.10.</a>&nbsp;
invalid-namespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-invalid-xml">4.9.3.11.</a>&nbsp;
invalid-xml<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-not-authorized">4.9.3.12.</a>&nbsp;
not-authorized<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-not-well-formed">4.9.3.13.</a>&nbsp;
not-well-formed<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-policy-violation">4.9.3.14.</a>&nbsp;
policy-violation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-remote-connection-failed">4.9.3.15.</a>&nbsp;
remote-connection-failed<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-reset">4.9.3.16.</a>&nbsp;
reset<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-resource-constraint">4.9.3.17.</a>&nbsp;
resource-constraint<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-restricted-xml">4.9.3.18.</a>&nbsp;
restricted-xml<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-see-other-host">4.9.3.19.</a>&nbsp;
see-other-host<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-system-shutdown">4.9.3.20.</a>&nbsp;
system-shutdown<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-undefined-condition">4.9.3.21.</a>&nbsp;
undefined-condition<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-unsupported-encoding">4.9.3.22.</a>&nbsp;
unsupported-encoding<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-unsupported-feature">4.9.3.23.</a>&nbsp;
unsupported-feature<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-unsupported-stanza-type">4.9.3.24.</a>&nbsp;
unsupported-stanza-type<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-conditions-unsupported-version">4.9.3.25.</a>&nbsp;
unsupported-version<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-error-app">4.9.4.</a>&nbsp;
Application-Specific Conditions<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#streams-example">4.10.</a>&nbsp;
Simplified Stream Examples<br />
<a href="#tls">5.</a>&nbsp;
STARTTLS Negotiation<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-fundamentals">5.1.</a>&nbsp;
Fundamentals<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-support">5.2.</a>&nbsp;
Support<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-rules">5.3.</a>&nbsp;
Stream Negotiation Rules<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-rules-mtn">5.3.1.</a>&nbsp;
Mandatory-to-Negotiate<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-rules-restart">5.3.2.</a>&nbsp;
Restart<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-rules-data">5.3.3.</a>&nbsp;
Data Formatting<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-rules-order">5.3.4.</a>&nbsp;
Order of TLS and SASL Negotiations<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-rules-renegotiation">5.3.5.</a>&nbsp;
TLS Renegotiation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-rules-extensions">5.3.6.</a>&nbsp;
TLS Extensions<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-process">5.4.</a>&nbsp;
Process<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-process-stream">5.4.1.</a>&nbsp;
Exchange of Stream Headers and Stream Features<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-process-initiate">5.4.2.</a>&nbsp;
Initiation of STARTTLS Negotiation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-process-initiate-command">5.4.2.1.</a>&nbsp;
STARTTLS Command<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-process-initiate-failure">5.4.2.2.</a>&nbsp;
Failure Case<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-process-initiate-proceed">5.4.2.3.</a>&nbsp;
Proceed Case<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-process-neg">5.4.3.</a>&nbsp;
TLS Negotiation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-process-neg-rules">5.4.3.1.</a>&nbsp;
Rules<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-process-neg-failure">5.4.3.2.</a>&nbsp;
TLS Failure<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#tls-process-neg-success">5.4.3.3.</a>&nbsp;
TLS Success<br />
<a href="#sasl">6.</a>&nbsp;
SASL Negotiation<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-fundamentals">6.1.</a>&nbsp;
Fundamentals<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-support">6.2.</a>&nbsp;
Support<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules">6.3.</a>&nbsp;
Stream Negotiation Rules<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules-mtn">6.3.1.</a>&nbsp;
Mandatory-to-Negotiate<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules-restart">6.3.2.</a>&nbsp;
Restart<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules-preferences">6.3.3.</a>&nbsp;
Mechanism Preferences<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules-offers">6.3.4.</a>&nbsp;
Mechanism Offers<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules-data">6.3.5.</a>&nbsp;
Data Formatting<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules-layers">6.3.6.</a>&nbsp;
Security Layers<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules-username">6.3.7.</a>&nbsp;
Simple User Name<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules-authzid">6.3.8.</a>&nbsp;
Authorization Identity<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules-realms">6.3.9.</a>&nbsp;
Realms<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-rules-roundtrips">6.3.10.</a>&nbsp;
Round Trips<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-process">6.4.</a>&nbsp;
Process<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-process-stream">6.4.1.</a>&nbsp;
Exchange of Stream Headers and Stream Features<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-process-neg-initiate">6.4.2.</a>&nbsp;
Initiation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-process-neg-challengeresponse">6.4.3.</a>&nbsp;
Challenge-Response Sequence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-process-neg-abort">6.4.4.</a>&nbsp;
Abort<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-process-neg-failure">6.4.5.</a>&nbsp;
SASL Failure<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-process-neg-success">6.4.6.</a>&nbsp;
SASL Success<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors">6.5.</a>&nbsp;
SASL Errors<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-aborted">6.5.1.</a>&nbsp;
aborted<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-account-disabled">6.5.2.</a>&nbsp;
account-disabled<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-credentials-expired">6.5.3.</a>&nbsp;
credentials-expired<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-encryption-required">6.5.4.</a>&nbsp;
encryption-required<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-incorrect-encoding">6.5.5.</a>&nbsp;
incorrect-encoding<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-invalid-authzid">6.5.6.</a>&nbsp;
invalid-authzid<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-invalid-mechanism">6.5.7.</a>&nbsp;
invalid-mechanism<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-malformed-request">6.5.8.</a>&nbsp;
malformed-request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-mechanism-too-weak">6.5.9.</a>&nbsp;
mechanism-too-weak<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-not-authorized">6.5.10.</a>&nbsp;
not-authorized<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-errors-temporary-auth-failure">6.5.11.</a>&nbsp;
temporary-auth-failure<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#sasl-def">6.6.</a>&nbsp;
SASL Definition<br />
<a href="#bind">7.</a>&nbsp;
Resource Binding<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-fundamentals">7.1.</a>&nbsp;
Fundamentals<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-support">7.2.</a>&nbsp;
Support<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-rules">7.3.</a>&nbsp;
Stream Negotiation Rules<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-rules-mtn">7.3.1.</a>&nbsp;
Mandatory-to-Negotiate<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-rules-restart">7.3.2.</a>&nbsp;
Restart<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-feature">7.4.</a>&nbsp;
Advertising Support<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-generation">7.5.</a>&nbsp;
Generation of Resource Identifiers<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-servergen">7.6.</a>&nbsp;
Server-Generated Resource Identifier<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-servergen-success">7.6.1.</a>&nbsp;
Success Case<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-servergen-error">7.6.2.</a>&nbsp;
Error Cases<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-servergen-error-resourceconstraint">7.6.2.1.</a>&nbsp;
Resource Constraint<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-servergen-error-notallowed">7.6.2.2.</a>&nbsp;
Not Allowed<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-clientsubmit">7.7.</a>&nbsp;
Client-Submitted Resource Identifier<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-clientsubmit-success">7.7.1.</a>&nbsp;
Success Case<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-clientsubmit-error">7.7.2.</a>&nbsp;
Error Cases<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-clientsubmit-error-badrequest">7.7.2.1.</a>&nbsp;
Bad Request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-clientsubmit-error-conflict">7.7.2.2.</a>&nbsp;
Conflict<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#bind-clientsubmit-retries">7.7.3.</a>&nbsp;
Retries<br />
<a href="#stanzas">8.</a>&nbsp;
XML Stanzas<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-attributes">8.1.</a>&nbsp;
Common Attributes<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-attributes-to">8.1.1.</a>&nbsp;
to<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-attributes-to-c2s">8.1.1.1.</a>&nbsp;
Client-to-Server Streams<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-attributes-to-s2s">8.1.1.2.</a>&nbsp;
Server-to-Server Streams<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-attributes-from">8.1.2.</a>&nbsp;
from<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-attributes-from-c2s">8.1.2.1.</a>&nbsp;
Client-to-Server Streams<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-attributes-from-s2s">8.1.2.2.</a>&nbsp;
Server-to-Server Streams<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-attributes-id">8.1.3.</a>&nbsp;
id<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-attributes-type">8.1.4.</a>&nbsp;
type<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-attributes-lang">8.1.5.</a>&nbsp;
xml:lang<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-semantics">8.2.</a>&nbsp;
Basic Semantics<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-semantics-message">8.2.1.</a>&nbsp;
Message Semantics<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-semantics-presence">8.2.2.</a>&nbsp;
Presence Semantics<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-semantics-iq">8.2.3.</a>&nbsp;
IQ Semantics<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error">8.3.</a>&nbsp;
Stanza Errors<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-rules">8.3.1.</a>&nbsp;
Rules<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-syntax">8.3.2.</a>&nbsp;
Syntax<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions">8.3.3.</a>&nbsp;
Defined Conditions<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-bad-request">8.3.3.1.</a>&nbsp;
bad-request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-conflict">8.3.3.2.</a>&nbsp;
conflict<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-feature-not-implemented">8.3.3.3.</a>&nbsp;
feature-not-implemented<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-forbidden">8.3.3.4.</a>&nbsp;
forbidden<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-gone">8.3.3.5.</a>&nbsp;
gone<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-internal-server-error">8.3.3.6.</a>&nbsp;
internal-server-error<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-item-not-found">8.3.3.7.</a>&nbsp;
item-not-found<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-jid-malformed">8.3.3.8.</a>&nbsp;
jid-malformed<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-not-acceptable">8.3.3.9.</a>&nbsp;
not-acceptable<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-not-allowed">8.3.3.10.</a>&nbsp;
not-allowed<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-not-authorized">8.3.3.11.</a>&nbsp;
not-authorized<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-policy-violation">8.3.3.12.</a>&nbsp;
policy-violation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-recipient-unavailable">8.3.3.13.</a>&nbsp;
recipient-unavailable<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-redirect">8.3.3.14.</a>&nbsp;
redirect<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-registration-required">8.3.3.15.</a>&nbsp;
registration-required<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-remote-server-not-found">8.3.3.16.</a>&nbsp;
remote-server-not-found<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-remote-server-timeout">8.3.3.17.</a>&nbsp;
remote-server-timeout<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-resource-constraint">8.3.3.18.</a>&nbsp;
resource-constraint<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-service-unavailable">8.3.3.19.</a>&nbsp;
service-unavailable<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-subscription-required">8.3.3.20.</a>&nbsp;
subscription-required<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-undefined-condition">8.3.3.21.</a>&nbsp;
undefined-condition<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-conditions-unexpected-request">8.3.3.22.</a>&nbsp;
unexpected-request<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-error-app">8.3.4.</a>&nbsp;
Application-Specific Conditions<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#stanzas-extended">8.4.</a>&nbsp;
Extended Content<br />
<a href="#examples">9.</a>&nbsp;
Detailed Examples<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-c2s">9.1.</a>&nbsp;
Client-to-Server Examples<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-c2s-tls">9.1.1.</a>&nbsp;
TLS<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-c2s-sasl">9.1.2.</a>&nbsp;
SASL<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-c2s-bind">9.1.3.</a>&nbsp;
Resource Binding<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-c2s-stanzas">9.1.4.</a>&nbsp;
Stanza Exchange<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-c2s-close">9.1.5.</a>&nbsp;
Close<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-s2s">9.2.</a>&nbsp;
Server-to-Server Examples<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-s2s-tls">9.2.1.</a>&nbsp;
TLS<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-s2s-sasl">9.2.2.</a>&nbsp;
SASL<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-s2s-stanzas">9.2.3.</a>&nbsp;
Stanza Exchange<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#examples-s2s-close">9.2.4.</a>&nbsp;
Close<br />
<a href="#rules">10.</a>&nbsp;
Server Rules for Processing XML Stanzas<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-order">10.1.</a>&nbsp;
In-Order Processing<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-gen">10.2.</a>&nbsp;
General Considerations<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-noto">10.3.</a>&nbsp;
No 'to' Address<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-noto-message">10.3.1.</a>&nbsp;
Message<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-noto-presence">10.3.2.</a>&nbsp;
Presence<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-noto-IQ">10.3.3.</a>&nbsp;
IQ<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-remote">10.4.</a>&nbsp;
Remote Domain<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-remote-existing">10.4.1.</a>&nbsp;
Existing Stream<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-remote-nostream">10.4.2.</a>&nbsp;
No Existing Stream<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-remote-error">10.4.3.</a>&nbsp;
Error Handling<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-local">10.5.</a>&nbsp;
Local Domain<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-local-domain">10.5.1.</a>&nbsp;
domainpart<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-local-domainresource">10.5.2.</a>&nbsp;
domainpart/resourcepart<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-local-barejid">10.5.3.</a>&nbsp;
localpart@domainpart<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-local-barejid-nosuchuser">10.5.3.1.</a>&nbsp;
No Such User<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-local-barejid-userexists">10.5.3.2.</a>&nbsp;
User Exists<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rules-local-fulljid">10.5.4.</a>&nbsp;
localpart@domainpart/resourcepart<br />
<a href="#xml">11.</a>&nbsp;
XML Usage<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#xml-restrictions">11.1.</a>&nbsp;
XML Restrictions<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#xml-ns">11.2.</a>&nbsp;
XML Namespace Names and Prefixes<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#xml-wellformed">11.3.</a>&nbsp;
Well-Formedness<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#xml-validation">11.4.</a>&nbsp;
Validation<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#xml-declaration">11.5.</a>&nbsp;
Inclusion of XML Declaration<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#xml-encoding">11.6.</a>&nbsp;
Character Encoding<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#xml-whitespace">11.7.</a>&nbsp;
Whitespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#xml-versions">11.8.</a>&nbsp;
XML Versions<br />
<a href="#i18n">12.</a>&nbsp;
Internationalization Considerations<br />
<a href="#security">13.</a>&nbsp;
Security Considerations<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-fundamentals">13.1.</a>&nbsp;
Fundamentals<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-threats">13.2.</a>&nbsp;
Threat Model<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-layers">13.3.</a>&nbsp;
Order of Layers<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-confidentiality">13.4.</a>&nbsp;
Confidentiality and Integrity<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-authentication">13.5.</a>&nbsp;
Peer Entity Authentication<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-strong">13.6.</a>&nbsp;
Strong Security<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates">13.7.</a>&nbsp;
Certificates<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates-generation">13.7.1.</a>&nbsp;
Certificate Generation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates-generation-general">13.7.1.1.</a>&nbsp;
General Considerations<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates-generation-server">13.7.1.2.</a>&nbsp;
Server Certificates<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates-generation-client">13.7.1.3.</a>&nbsp;
Client Certificates<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates-generation-xmppaddr">13.7.1.4.</a>&nbsp;
XmppAddr Identifier Type<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates-validation">13.7.2.</a>&nbsp;
Certificate Validation<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates-validation-server">13.7.2.1.</a>&nbsp;
Server Certificates<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates-validation-client">13.7.2.2.</a>&nbsp;
Client Certificates<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates-validation-streams">13.7.2.3.</a>&nbsp;
Checking of Certificates in Long-Lived Streams<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-certificates-validation-extensions">13.7.2.4.</a>&nbsp;
Use of Certificates in XMPP Extensions<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-mti">13.8.</a>&nbsp;
Mandatory-to-Implement TLS and SASL Technologies<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-mti-auth">13.8.1.</a>&nbsp;
For Authentication Only<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-mti-conf">13.8.2.</a>&nbsp;
For Confidentiality Only<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-mti-bothpass">13.8.3.</a>&nbsp;
For Confidentiality and Authentication with Passwords<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-mti-bothnopass">13.8.4.</a>&nbsp;
For Confidentiality and Authentication without Passwords<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-reuse">13.9.</a>&nbsp;
Technology Reuse<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-reuse-base64">13.9.1.</a>&nbsp;
Use of Base 64 in SASL<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-reuse-dns">13.9.2.</a>&nbsp;
Use of DNS<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-reuse-hash">13.9.3.</a>&nbsp;
Use of Hash Functions<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-reuse-sasl">13.9.4.</a>&nbsp;
Use of SASL<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-reuse-tls">13.9.5.</a>&nbsp;
Use of TLS<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-reuse-utf8">13.9.6.</a>&nbsp;
Use of UTF-8<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-reuse-xml">13.9.7.</a>&nbsp;
Use of XML<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-leaks">13.10.</a>&nbsp;
Information Leaks<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-leaks-ipaddress">13.10.1.</a>&nbsp;
IP Addresses<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-leaks-presence">13.10.2.</a>&nbsp;
Presence Information<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-harvesting">13.11.</a>&nbsp;
Directory Harvesting<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-dos">13.12.</a>&nbsp;
Denial of Service<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-firewalls">13.13.</a>&nbsp;
Firewalls<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-federation">13.14.</a>&nbsp;
Interdomain Federation<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#security-nonrepudiation">13.15.</a>&nbsp;
Non-Repudiation<br />
<a href="#iana">14.</a>&nbsp;
IANA Considerations<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#iana-ns-tls">14.1.</a>&nbsp;
XML Namespace Name for TLS Data<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#iana-ns-sasl">14.2.</a>&nbsp;
XML Namespace Name for SASL Data<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#iana-ns-streams">14.3.</a>&nbsp;
XML Namespace Name for Stream Errors<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#iana-ns-bind">14.4.</a>&nbsp;
XML Namespace Name for Resource Binding<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#iana-ns-stanzas">14.5.</a>&nbsp;
XML Namespace Name for Stanza Errors<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#iana-gssapi">14.6.</a>&nbsp;
GSSAPI Service Name<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#iana-ports">14.7.</a>&nbsp;
Port Numbers and Service Names<br />
<a href="#conformance">15.</a>&nbsp;
Conformance Requirements<br />
<a href="#rfc.references1">16.</a>&nbsp;
References<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rfc.references1">16.1.</a>&nbsp;
Normative References<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#rfc.references2">16.2.</a>&nbsp;
Informative References<br />
<a href="#schema">Appendix&nbsp;A.</a>&nbsp;
XML Schemas<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#schemas-stream">A.1.</a>&nbsp;
Stream Namespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#schemas-streamerror">A.2.</a>&nbsp;
Stream Error Namespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#schemas-starttls">A.3.</a>&nbsp;
STARTTLS Namespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#schemas-sasl">A.4.</a>&nbsp;
SASL Namespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#schemas-client">A.5.</a>&nbsp;
Client Namespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#schemas-server">A.6.</a>&nbsp;
Server Namespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#schemas-bind">A.7.</a>&nbsp;
Resource Binding Namespace<br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#schemas-stanzaerror">A.8.</a>&nbsp;
Stanza Error Namespace<br />
<a href="#contact">Appendix&nbsp;B.</a>&nbsp;
Contact Addresses<br />
<a href="#provisioning">Appendix&nbsp;C.</a>&nbsp;
Account Provisioning<br />
<a href="#diffs">Appendix&nbsp;D.</a>&nbsp;
Differences from RFC 3920<br />
<a href="#intro-ack">Appendix&nbsp;E.</a>&nbsp;
Acknowledgements<br />
</p>
<br clear="all" />

<a name="intro"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1"></a><h3>1.&nbsp;
Introduction</h3>

<a name="intro-overview"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1.1"></a><h3>1.1.&nbsp;
Overview</h3>

<p>The Extensible Messaging and Presence Protocol (XMPP) is an application profile of the Extensible Markup Language <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a> 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.
</p>
<a name="intro-history"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1.2"></a><h3>1.2.&nbsp;
History</h3>

<p>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 base Jabber protocol that would be suitable as an IETF instant messaging (IM) and presence technology in accordance with <a class='info' href='#IMP-REQS'>[IMP&#8209;REQS]<span> (</span><span class='info'>Day, M., Aggarwal, S., and J. Vincent, &ldquo;Instant Messaging / Presence Protocol Requirements,&rdquo; February&nbsp;2000.</span><span>)</span></a>.  In October 2004, <a class='info' href='#RFC3920'>[RFC3920]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; October&nbsp;2004.</span><span>)</span></a> and <a class='info' href='#RFC3921'>[RFC3921]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; October&nbsp;2004.</span><span>)</span></a> were published, representing the most complete definition of XMPP at that time.
</p>
<p>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 XMPP service providers, including a number of backward-compatible modifications summarized under <a class='info' href='#diffs'>Appendix&nbsp;D<span> (</span><span class='info'>Differences from RFC 3920</span><span>)</span></a>.  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.
</p>
<a name="intro-summary"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1.3"></a><h3>1.3.&nbsp;
Functional Summary</h3>

<p>This non-normative section provides a developer-friendly, functional summary of XMPP; refer to the sections that follow for a normative definition of XMPP.
</p>
<p>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 connection is:
</p>
<p>
        </p>
<ol class="text">
<li>Determine the IP address and port at which to connect,
          typically based on resolution of a fully qualified domain name (<a class='info' href='#tcp-resolution'>Section&nbsp;3.2<span> (</span><span class='info'>Resolution of Fully Qualified Domain Names</span><span>)</span></a>)
</li>
<li>Open a Transmission Control Protocol <a class='info' href='#TCP'>[TCP]<span> (</span><span class='info'>Postel, J., &ldquo;Transmission Control Protocol,&rdquo; September&nbsp;1981.</span><span>)</span></a> connection
</li>
<li>Open an XML stream over TCP (<a class='info' href='#streams-open'>Section&nbsp;4.2<span> (</span><span class='info'>Opening a Stream</span><span>)</span></a>)
</li>
<li>Preferably negotiate Transport Layer Security <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a> for channel encryption (<a class='info' href='#tls'>Section&nbsp;5<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a>)
</li>
<li>Authenticate using a Simple Authentication and Security Layer <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a> mechanism (<a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>)
</li>
<li>Bind a resource to the stream (<a class='info' href='#bind'>Section&nbsp;7<span> (</span><span class='info'>Resource Binding</span><span>)</span></a>)
</li>
<li>Exchange an unbounded number of XML stanzas with other entities on the network (<a class='info' href='#stanzas'>Section&nbsp;8<span> (</span><span class='info'>XML Stanzas</span><span>)</span></a>)
</li>
<li>Close the XML stream (<a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a>)
</li>
<li>Close the TCP connection
</li>
</ol><p>
      
</p>
<p>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:
</p>
<p>
        </p>
<ol class="text">
<li>Determine the IP address and port at which to connect,
          typically based on resolution of a fully qualified domain name (<a class='info' href='#tcp-resolution'>Section&nbsp;3.2<span> (</span><span class='info'>Resolution of Fully Qualified Domain Names</span><span>)</span></a>)
</li>
<li>Open a TCP connection
</li>
<li>Open an XML stream (<a class='info' href='#streams-open'>Section&nbsp;4.2<span> (</span><span class='info'>Opening a Stream</span><span>)</span></a>)
</li>
<li>Preferably negotiate TLS for channel encryption (<a class='info' href='#tls'>Section&nbsp;5<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a>)
</li>
<li>Authenticate using a Simple Authentication and Security Layer <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a> mechanism (<a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>) *
</li>
<li>Exchange an unbounded number of XML stanzas both directly for the servers and indirectly on behalf of entities associated with each server, such as connected clients (<a class='info' href='#stanzas'>Section&nbsp;8<span> (</span><span class='info'>XML Stanzas</span><span>)</span></a>)
</li>
<li>Close the XML stream (<a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a>)
</li>
<li>Close the TCP connection
</li>
</ol><p>
      
</p>
<p></p>
<blockquote class="text">
<p>* Interoperability Note: At the time of writing, most deployed servers still use the Server Dialback protocol <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a> to provide weak identity verification instead of using SASL with PKIX certificates 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 PKIX certificate presented by the peer server during TLS negotiation is self-signed and has not been previously accepted); for details, see <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>.  The solutions specified in this document offer a significantly stronger level of security (see also <a class='info' href='#security-strong'>Section&nbsp;13.6<span> (</span><span class='info'>Strong Security</span><span>)</span></a>).
</p>
</blockquote>

<p>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, <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a> defines extensions for basic instant messaging and presence functionality.  In addition, various specifications produced in the XSF's XEP series <a class='info' href='#XEP-0001'>[XEP&#8209;0001]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;XMPP Extension Protocols,&rdquo; March&nbsp;2010.</span><span>)</span></a> define extensions for a wide range of applications.
</p>
<a name="intro-terms"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.1.4"></a><h3>1.4.&nbsp;
Terminology</h3>

<p>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 <a class='info' href='#KEYWORDS'>[KEYWORDS]<span> (</span><span class='info'>Bradner, S., &ldquo;Key words for use in RFCs to Indicate Requirement Levels,&rdquo; March&nbsp;1997.</span><span>)</span></a>.
</p>
<p>Certain security-related terms are to be understood in the sense defined in <a class='info' href='#SEC-TERMS'>[SEC&#8209;TERMS]<span> (</span><span class='info'>Shirey, R., &ldquo;Internet Security Glossary, Version 2,&rdquo; August&nbsp;2007.</span><span>)</span></a>; such terms include, but are not limited to, "assurance", "attack", "authentication", "authorization", "certificate", "certification authority", "certification path", "confidentiality", "credential", "downgrade", "encryption", "hash value", "identity", "integrity", "signature", "self-signed certificate", "sign", "spoof", "tamper", "trust", "trust anchor", "validate", and "verify".
</p>
<p>Certain terms related to certificates, domains, and application service identity are to be understood in the sense defined in <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a>; these include, but are not limited to, "PKIX certificate", "source domain", "derived domain", and the identifier types "CN-ID", "DNS-ID", and "SRV-ID".
</p>
<p>Other security-related terms are to be understood in the sense defined in the referenced specifications (for example, "denial of service" as described in <a class='info' href='#DOS'>[DOS]<span> (</span><span class='info'>Handley, M., Rescorla, E., and IAB, &ldquo;Internet Denial-of-Service Considerations,&rdquo; December&nbsp;2006.</span><span>)</span></a> or "end entity certificate" as described in <a class='info' href='#PKIX'>[PKIX]<span> (</span><span class='info'>Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, &ldquo;Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile,&rdquo; May&nbsp;2008.</span><span>)</span></a>).
</p>
<p>The term "whitespace" is used to refer to any character or characters matching the "S" production from <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>, i.e., one or more instances of the SP, HTAB, CR, or LF rules defined in <a class='info' href='#ABNF'>[ABNF]<span> (</span><span class='info'>Crocker, D. and P. Overell, &ldquo;Augmented BNF for Syntax Specifications: ABNF,&rdquo; January&nbsp;2008.</span><span>)</span></a>.
</p>
<p>The terms "localpart", "domainpart", and "resourcepart" are defined in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<p>The term "bare JID" refers to an XMPP address of the form &lt;localpart@domainpart&gt; (for an account at a server) or of the form &lt;domainpart&gt; (for a server).
</p>
<p>The term "full JID" refers to an XMPP address of the form &lt;localpart@domainpart/resourcepart&gt; (for a particular authorized client or device associated with an account) or of the form &lt;domainpart/resourcepart&gt; (for a particular resource or script associated with a server).
</p>
<p>The term "XML stream" (also "stream") is defined under <a class='info' href='#streams-fundamentals'>Section&nbsp;4.1<span> (</span><span class='info'>Stream Fundamentals</span><span>)</span></a>.
</p>
<p>The term "XML stanza" (also "stanza") is defined under <a class='info' href='#streams-fundamentals'>Section&nbsp;4.1<span> (</span><span class='info'>Stream Fundamentals</span><span>)</span></a>.  There are three kinds of stanzas: message,
presence, and IQ (short for "Info/Query").  These communication primitives are
defined under Sections <a class='info' href='#stanzas-semantics-message'>8.2.1<span> (</span><span class='info'>Message Semantics</span><span>)</span></a>, <a class='info' href='#stanzas-semantics-presence'>8.2.2<span> (</span><span class='info'>Presence Semantics</span><span>)</span></a>, and <a class='info' href='#stanzas-semantics-iq'>8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>, respectively.
</p>
<p>The term "originating entity" refers to the entity that first generates a stanza that is sent over an XMPP network (e.g., a connected client, an add-on service, or a server).  The term "generated stanza" refers to the stanza so generated.
</p>
<p>The term "input stream" designates an XML stream over which a server receives data from a connected client or remote server, and the term "output stream" designates an XML stream over which a server sends data to a connected client or remote server.  The following terms designate some of the actions that a server can perform when processing data received over an input stream:
</p>
<p>
        </p>
<blockquote class="text">
<p>
            </p>
<blockquote class="text"><dl>
<dt>route:</dt>
<dd>pass the data to a remote server for direct processing by the remote server or eventual delivery to a client associated with the remote server
</dd>
<dt>deliver:</dt>
<dd>pass the data to a connected client
</dd>
<dt>ignore:</dt>
<dd>discard the data without acting upon it or returning an error to the sender
</dd>
</dl></blockquote>
          

</blockquote><p>
      
</p>
<p>When the term "ignore" is used with regard to client processing of data it receives, the phrase "without acting upon it" explicitly includes not presenting the data to a human user.
</p>
<p>Following the "XML Notation" used in <a class='info' href='#IRI'>[IRI]<span> (</span><span class='info'>Duerst, M. and M. Suignard, &ldquo;Internationalized Resource Identifiers (IRIs),&rdquo; January&nbsp;2005.</span><span>)</span></a> to represent characters that cannot be rendered in ASCII-only documents, some examples in this document use the form "&amp;#x...." as a notational device to represent <a class='info' href='#UNICODE'>[UNICODE]<span> (</span><span class='info'>The Unicode Consortium, &ldquo;The Unicode Standard, Version 6.0,&rdquo; 2010.</span><span>)</span></a> characters (e.g., the string "&amp;#x0159;" 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.
</p>
<p>Consistent with the convention used in <a class='info' href='#URI'>[URI]<span> (</span><span class='info'>Berners-Lee, T., Fielding, R., and L. Masinter, &ldquo;Uniform Resource Identifier (URI): Generic Syntax,&rdquo; January&nbsp;2005.</span><span>)</span></a>
      to represent Uniform Resource Identifiers, XMPP addresses in running text are enclosed between '&lt;' and '&gt;' (although natively they are not URIs).
</p>
<p>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):
</p>
<p>
        </p>
<ul class="text">
<li>C: = a client
</li>
<li>E: = any XMPP entity
</li>
<li>I: = an initiating entity
</li>
<li>P: = a peer server
</li>
<li>R: = a receiving entity
</li>
<li>S: = a server
</li>
<li>S1: = server1
</li>
<li>S2: = server2
</li>
</ul><p>
      
</p>
<p>Readers need to be aware that the examples are not exhaustive and that, in examples for some protocol flows, the alternate steps shown would not necessarily be triggered by the exact data sent in the previous step; in all cases the protocol definitions specified in this document or in normatively referenced documents rule over any examples provided here.  All examples are fictional and the information exchanged (e.g., usernames and passwords) does not represent any existing users or servers.
</p>
<a name="arch"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2"></a><h3>2.&nbsp;
Architecture</h3>

<p>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 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" <a class='info' href='#REST'>[REST]<span> (</span><span class='info'>Fielding, R., &ldquo;Architectural Styles and the Design of Network-based Software Architectures,&rdquo; .</span><span>)</span></a> architectural style familiar from the World Wide Web. &nbsp;Although the architecture of XMPP is similar in important ways to that of email (see <a class='info' href='#EMAIL-ARCH'>[EMAIL&#8209;ARCH]<span> (</span><span class='info'>Crocker, D., &ldquo;Internet Mail Architecture,&rdquo; July&nbsp;2009.</span><span>)</span></a>), it introduces several modifications to facilitate communication in close to real time.  The salient features of this ACTive architectural style are as follows.
</p>
<a name="arch-addresses"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.1"></a><h3>2.1.&nbsp;
Global Addresses</h3>

<p>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 &lt;domainpart&gt; (e.g., &lt;im.example.com&gt;), accounts hosted at a server are of the form &lt;localpart@domainpart&gt; (e.g., &lt;juliet@im.example.com&gt;, called a "bare JID"), and a particular connected device or resource that is currently authorized for interaction on behalf of an account is of the form &lt;localpart@domainpart/resourcepart&gt; (e.g., &lt;juliet@im.example.com/balcony&gt;, called a "full JID").  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 <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a> instead of this document.  The terms "localpart", "domainpart", and "resourcepart" are defined more formally in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<a name="arch-presence"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.2"></a><h3>2.2.&nbsp;
Presence</h3>

<p>XMPP includes the ability for an entity to advertise its network availability or "presence" to other entities.  In XMPP, this availability for communication is signaled end-to-end by means of a dedicated communication primitive: the &lt;presence/&gt; 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 <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<a name="arch-streams"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.3"></a><h3>2.3.&nbsp;
Persistent Streams</h3>

<p>Availability for communication is also built into each point-to-point "hop" through the use of persistent XML streams over long-lived TCP connections.  These "always-on" client-to-server and server-to-server streams enable each party to push data to the other party at any time for immediate routing or delivery.  XML streams are defined under <a class='info' href='#streams'>Section&nbsp;4<span> (</span><span class='info'>XML Streams</span><span>)</span></a>.
</p>
<a name="arch-data"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.4"></a><h3>2.4.&nbsp;
Structured Data</h3>

<p>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 <a class='info' href='#stanzas'>Section&nbsp;8<span> (</span><span class='info'>XML Stanzas</span><span>)</span></a>.
</p>
<a name="arch-network"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.2.5"></a><h3>2.5.&nbsp;
Distributed Network of Clients and Servers</h3>

<p>In practice, XMPP consists of a network of clients and servers that inter-communicate (however, communication between any two given deployed servers is strictly discretionary and a matter of local service policy).  Thus, for example, the user &lt;juliet@im.example.com&gt; associated with the server &lt;im.example.com&gt; might be able to exchange messages, presence, and other structured data with the user &lt;romeo@example.net&gt; associated with the server &lt;example.net&gt;.  This pattern is familiar from messaging protocols that make use of global addresses, such as the email network (see <a class='info' href='#SMTP'>[SMTP]<span> (</span><span class='info'>Klensin, J., &ldquo;Simple Mail Transfer Protocol,&rdquo; October&nbsp;2008.</span><span>)</span></a> and <a class='info' href='#EMAIL-ARCH'>[EMAIL&#8209;ARCH]<span> (</span><span class='info'>Crocker, D., &ldquo;Internet Mail Architecture,&rdquo; July&nbsp;2009.</span><span>)</span></a>).  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.
</p><br /><hr class="insert" />
<a name="figure-1"></a>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  example.net &lt;--------------&gt; im.example.com
     ^                                ^
     |                                |
     v                                v
romeo@example.net           juliet@im.example.com

</pre></div><table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b>&nbsp;Figure&nbsp;1: Distributed Client-Server Architecture&nbsp;</b></font><br /></td></tr></table><hr class="insert" />

<p></p>
<blockquote class="text">
<p>Informational Note: Architectures that employ <a class='info' href='#streams'>XML streams<span> (</span><span class='info'>XML Streams</span><span>)</span></a> and <a class='info' href='#stanzas'>XML stanzas<span> (</span><span class='info'>XML Stanzas</span><span>)</span></a> but that establish peer-to-peer connections directly between clients using technologies based on <a class='info' href='#LINKLOCAL'>[LINKLOCAL]<span> (</span><span class='info'>Cheshire, S., Aboba, B., and E. Guttman, &ldquo;Dynamic Configuration of IPv4 Link-Local Addresses,&rdquo; May&nbsp;2005.</span><span>)</span></a> have been deployed, but such architectures are not defined in this specification and are best described as "XMPP-like"; for details, see <a class='info' href='#XEP-0174'>[XEP&#8209;0174]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Link-Local Messaging,&rdquo; November&nbsp;2008.</span><span>)</span></a>.  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.
</p>
</blockquote>

<p>The following paragraphs describe the responsibilities of clients and servers on the network.
</p>
<p>A client is an entity that establishes an XML stream with a server by authenticating using the credentials of a registered account (via <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>) and that then completes <a class='info' href='#bind'>resource binding<span> (</span><span class='info'>Resource Binding</span><span>)</span></a> 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 other connected clients at the same server or routing them to remote servers.  Multiple clients can connect simultaneously to a server on behalf of the same registered account, where each client is differentiated by the resourcepart of an XMPP address (e.g., &lt;juliet@im.example.com/balcony&gt; vs. &lt;juliet@im.example.com/chamber&gt;), as defined under <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a> and <a class='info' href='#bind'>Section&nbsp;7<span> (</span><span class='info'>Resource Binding</span><span>)</span></a>.
</p>
<p>A server is an entity whose primary responsibilities are to:
</p>
<p>
        </p>
<ul class="text">
<li>Manage <a class='info' href='#streams'>XML streams<span> (</span><span class='info'>XML Streams</span><span>)</span></a> with connected clients and deliver <a class='info' href='#stanzas'>XML stanzas<span> (</span><span class='info'>XML Stanzas</span><span>)</span></a> 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.
</li>
<li>Subject to local service policies on server-to-server communication, manage <a class='info' href='#streams'>XML streams<span> (</span><span class='info'>XML Streams</span><span>)</span></a> with remote servers and route <a class='info' href='#stanzas'>XML stanzas<span> (</span><span class='info'>XML Stanzas</span><span>)</span></a> to those servers over the negotiated streams.
</li>
</ul><p>
      
</p>
<p>Depending on the application, the secondary responsibilities of an XMPP server can include:
</p>
<p>
        </p>
<ul class="text">
<li>Storing data that is used by clients (e.g., contact lists for users of XMPP-based instant messaging and presence applications as defined in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>); 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 connected client.
</li>
<li>Hosting add-on services that also use XMPP as the basis for communication but that provide additional functionality beyond that defined in this document or in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>; examples include multi-user conferencing services as specified in <a class='info' href='#XEP-0045'>[XEP&#8209;0045]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Multi-User Chat,&rdquo; July&nbsp;2007.</span><span>)</span></a> and publish-subscribe services as specified in <a class='info' href='#XEP-0060'>[XEP&#8209;0060]<span> (</span><span class='info'>Millard, P., Saint-Andre, P., and R. Meijer, &ldquo;Publish-Subscribe,&rdquo; July&nbsp;2010.</span><span>)</span></a>.
</li>
</ul><p>
      
</p>
<a name="tcp"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3"></a><h3>3.&nbsp;
TCP Binding</h3>

<a name="tcp-scope"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.1"></a><h3>3.1.&nbsp;
Scope</h3>

<p>As XMPP is defined in this specification, an initiating entity (client or server) MUST open a Transmission Control Protocol <a class='info' href='#TCP'>[TCP]<span> (</span><span class='info'>Postel, J., &ldquo;Transmission Control Protocol,&rdquo; September&nbsp;1981.</span><span>)</span></a> 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.
</p>
<p></p>
<blockquote class="text">
<p>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 <a class='info' href='#HTTP'>[HTTP]<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, &ldquo;Hypertext Transfer Protocol -- HTTP/1.1,&rdquo; June&nbsp;1999.</span><span>)</span></a> as specified in <a class='info' href='#XEP-0124'>[XEP&#8209;0124]<span> (</span><span class='info'>Paterson, I., Smith, D., and P. Saint-Andre, &ldquo;Bidirectional-streams Over Synchronous HTTP (BOSH),&rdquo; July&nbsp;2010.</span><span>)</span></a> and <a class='info' href='#XEP-0206'>[XEP&#8209;0206]<span> (</span><span class='info'>Paterson, I. and P. Saint-Andre, &ldquo;XMPP Over BOSH,&rdquo; July&nbsp;2010.</span><span>)</span></a>.  However, this specification defines only a binding of XMPP to TCP.
</p>
</blockquote>

<a name="tcp-resolution"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.2"></a><h3>3.2.&nbsp;
Resolution of Fully Qualified Domain Names</h3>

<p>Because XML streams are sent over TCP, the initiating entity
      needs to determine the IPv4 or IPv6 address (and port) of the
      receiving entity before it can attempt to open an XML stream.
      Typically this is done by resolving the receiving entity's fully
      qualified domain name or FQDN (see <a class='info' href='#DNS-CONCEPTS'>[DNS&#8209;CONCEPTS]<span> (</span><span class='info'>Mockapetris, P., &ldquo;Domain names - concepts and facilities,&rdquo; November&nbsp;1987.</span><span>)</span></a>).
</p>
<a name="tcp-resolution-prefer"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.2.1"></a><h3>3.2.1.&nbsp;
Preferred Process: SRV Lookup</h3>

<p>The preferred process for FQDN resolution is to use <a class='info' href='#DNS-SRV'>[DNS&#8209;SRV]<span> (</span><span class='info'>Gulbrandsen, A., Vixie, P., and L. Esibov, &ldquo;A DNS RR for specifying the location of services (DNS SRV),&rdquo; February&nbsp;2000.</span><span>)</span></a> records as follows:
</p>
<p>
          </p>
<ol class="text">
<li>The initiating entity constructs a DNS SRV query whose inputs are:
              
<ul class="text">
<li>a Service of "xmpp-client" (for client-to-server connections) or "xmpp-server" (for server-to-server connections)
</li>
<li>a Proto of "tcp"
</li>
<li>a Name corresponding to the "origin domain" <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a> of the XMPP service to which the initiating entity wishes to connect (e.g., "example.net" or "im.example.com")
</li>
</ul>
            
</li>
<li>The result is a query such as "_xmpp-client._tcp.example.net." or "_xmpp-server._tcp.im.example.com.".
</li>
<li>
              If a response is received, it will contain one or more combinations of a port and FDQN, each of which is weighted and prioritized as described in <a class='info' href='#DNS-SRV'>[DNS&#8209;SRV]<span> (</span><span class='info'>Gulbrandsen, A., Vixie, P., and L. Esibov, &ldquo;A DNS RR for specifying the location of services (DNS SRV),&rdquo; February&nbsp;2000.</span><span>)</span></a>.
              
              (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 because according to <a class='info' href='#DNS-SRV'>[DNS&#8209;SRV]<span> (</span><span class='info'>Gulbrandsen, A., Vixie, P., and L. Esibov, &ldquo;A DNS RR for specifying the location of services (DNS SRV),&rdquo; February&nbsp;2000.</span><span>)</span></a> such a Target "means that the service is decidedly not available at this domain".)
            
</li>
<li>The initiating entity chooses at least one of the returned FQDNs to resolve (following the rules in <a class='info' href='#DNS-SRV'>[DNS&#8209;SRV]<span> (</span><span class='info'>Gulbrandsen, A., Vixie, P., and L. Esibov, &ldquo;A DNS RR for specifying the location of services (DNS SRV),&rdquo; February&nbsp;2000.</span><span>)</span></a>), which it does by performing DNS "A" or "AAAA" lookups on the FDQN; this will result in an IPv4 or IPv6 address.
</li>
<li>The initiating entity uses the IP address(es) from the successfully resolved FDQN (with the corresponding port number returned by the SRV lookup) as the connection address for the receiving entity.
</li>
<li>If the initiating entity fails to connect using that IP address but the "A" or "AAAA" lookups returned more than one IP address, then the initiating entity uses the next resolved IP address for that FDQN as the connection address.
</li>
<li>If the initiating entity fails to connect using all resolved IP addresses for a given FDQN, then it repeats the process of resolution and connection for the next FQDN returned by the SRV lookup based on the priority and weight as defined in <a class='info' href='#DNS-SRV'>[DNS&#8209;SRV]<span> (</span><span class='info'>Gulbrandsen, A., Vixie, P., and L. Esibov, &ldquo;A DNS RR for specifying the location of services (DNS SRV),&rdquo; February&nbsp;2000.</span><span>)</span></a>.
</li>
<li>If the initiating entity receives a response to its SRV query but it is not able to establish an XMPP connection using the data received in the response, it SHOULD NOT attempt the fallback process described in the next section (this helps to prevent a state mismatch between inbound and outbound connections).
</li>
<li>If the initiating entity does not receive a response to its SRV query, it SHOULD attempt the fallback process described in the next section.
</li>
</ol><p>
        
</p>
<a name="tcp-resolution-fallback"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.2.2"></a><h3>3.2.2.&nbsp;
Fallback Processes</h3>

<p>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 of 5269 for server-to-server connections (these are the default ports as registered with the IANA as described under <a class='info' href='#iana-ports'>Section&nbsp;14.7<span> (</span><span class='info'>Port Numbers and Service Names</span><span>)</span></a>).
</p>
<p>If connections via TCP are unsuccessful, the initiating entity might attempt to find and use alternative connection methods such as the HTTP binding (see <a class='info' href='#XEP-0124'>[XEP&#8209;0124]<span> (</span><span class='info'>Paterson, I., Smith, D., and P. Saint-Andre, &ldquo;Bidirectional-streams Over Synchronous HTTP (BOSH),&rdquo; July&nbsp;2010.</span><span>)</span></a> and <a class='info' href='#XEP-0206'>[XEP&#8209;0206]<span> (</span><span class='info'>Paterson, I. and P. Saint-Andre, &ldquo;XMPP Over BOSH,&rdquo; July&nbsp;2010.</span><span>)</span></a>), which might be discovered using <a class='info' href='#DNS-TXT'>[DNS&#8209;TXT]<span> (</span><span class='info'>Rosenbaum, R., &ldquo;Using the Domain Name System To Store Arbitrary String Attributes,&rdquo; May&nbsp;1993.</span><span>)</span></a> records as described in <a class='info' href='#XEP-0156'>[XEP&#8209;0156]<span> (</span><span class='info'>Hildebrand, J. and P. Saint-Andre, &ldquo;Discovering Alternative XMPP Connection Methods,&rdquo; June&nbsp;2007.</span><span>)</span></a>.
</p>
<a name="tcp-resolution-srvnot"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.2.3"></a><h3>3.2.3.&nbsp;
When Not to Use SRV</h3>

<p>If the initiating entity has been explicitly configured to associate a particular FQDN (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 FQDN of apps.example.com), the initiating entity is encouraged to use the configured name instead of performing the preferred SRV resolution process on the origin domain.
</p>
<a name="tcp-resolution-srvadd"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.2.4"></a><h3>3.2.4.&nbsp;
Use of SRV Records with Add-On Services</h3>

<p>Many XMPP servers are implemented in such a way that they can host add-on services (beyond those defined in this specification and <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>) at DNS domain names that typically are "subdomains" of the main XMPP service (e.g., conference.example.net for a <a class='info' href='#XEP-0045'>[XEP&#8209;0045]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Multi-User Chat,&rdquo; July&nbsp;2007.</span><span>)</span></a> service associated with the example.net XMPP service) or "subdomains" of the first-level domain of the underlying service (e.g., muc.example.com for a <a class='info' href='#XEP-0045'>[XEP&#8209;0045]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Multi-User Chat,&rdquo; July&nbsp;2007.</span><span>)</span></a> service associated with the im.example.com XMPP service).  If an entity associated with a remote XMPP server wishes to communicate with such an add-on service, it would generate an appropriate XML stanza and the remote server would attempt to resolve the add-on service's DNS domain name via an SRV lookup on resource records such as "_xmpp-server._tcp.conference.example.net." or "_xmpp-server._tcp.muc.example.com.".  Therefore, if the administrators of an XMPP service wish to enable entities associated with remote servers to access such add-on services, they need to advertise the appropriate "_xmpp-server" SRV records in addition to the "_xmpp-server" record for their main XMPP service.  In case SRV records are not available, the fallback methods described under <a class='info' href='#tcp-resolution-fallback'>Section&nbsp;3.2.2<span> (</span><span class='info'>Fallback Processes</span><span>)</span></a> can be used to resolve the DNS domain names of add-on services.
</p>
<a name="tcp-reconnect"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.3"></a><h3>3.3.&nbsp;
Reconnection</h3>

<p>It can happen that an XMPP server goes offline unexpectedly while servicing TCP connections from connected clients and remote 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 performance and network congestion.  If an entity chooses to reconnect, it:
</p>
<p>
        </p>
<ul class="text">
<li>SHOULD set the number of seconds that expire before reconnecting to an unpredictable number between 0 and 60 (this helps to ensure that not all entities attempt to reconnect at exactly the same number of seconds after being disconnected).
</li>
<li>SHOULD back off increasingly on the time between subsequent reconnection attempts (e.g., in accordance with "truncated binary exponential backoff" as described in <a class='info' href='#ETHERNET'>[ETHERNET]<span> (</span><span class='info'>, &ldquo;Information technology - Telecommunications and information exchange between systems - Local and metropolitan area networks - Specific requirements - Part 3: Carrier sense multiple access with collision detection (CSMA/CD) access method and physical layer specifications,&rdquo; September&nbsp;1998.</span><span>)</span></a>) if the first reconnection attempt does not succeed.
</li>
</ul><p>
      
</p>
<p>It is RECOMMENDED to make use of TLS session resumption <a class='info' href='#TLS-RESUME'>[TLS&#8209;RESUME]<span> (</span><span class='info'>Salowey, J., Zhou, H., Eronen, P., and H. Tschofenig, &ldquo;Transport Layer Security (TLS) Session Resumption without Server-Side State,&rdquo; January&nbsp;2008.</span><span>)</span></a> when reconnecting.  A future version of this document, or a separate specification, might provide more detailed guidelines regarding methods for speeding the reconnection process.
</p>
<a name="streams-reliability"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.3.4"></a><h3>3.4.&nbsp;
Reliability</h3>

<p>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., <a class='info' href='#XEP-0198'>[XEP&#8209;0198]<span> (</span><span class='info'>Karneges, J., Hildebrand, J., Saint-Andre, P., Forno, F., Cridland, D., and M. Wild, &ldquo;Stream Management,&rdquo; February&nbsp;2011.</span><span>)</span></a>).
</p>
<a name="streams"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4"></a><h3>4.&nbsp;
XML Streams</h3>

<a name="streams-fundamentals"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.1"></a><h3>4.1.&nbsp;
Stream Fundamentals</h3>

<p>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.
</p>
<p>
        </p>
<blockquote class="text"><dl>
<dt>Definition of XML Stream:</dt>
<dd>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 &lt;stream&gt; tag with appropriate attributes and namespace declarations), while the end of the XML stream is denoted unambiguously by a closing XML &lt;/stream&gt; 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 <a class='info' href='#tls'>TLS negotiation<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a> or <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>) 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").
</dd>
<dt>Definition of XML Stanza:</dt>
<dd>An XML stanza is the basic unit of meaning in XMPP.  A stanza is a first-level element (at depth=1 of the stream) whose element name is "message", "presence", or "iq" and whose qualifying namespace is 'jabber:client' or 'jabber:server'.  By contrast, a first-level element qualified by any other namespace is not an XML stanza (stream errors, stream features, TLS-related elements, SASL-related elements, etc.), nor is a &lt;message/&gt;, &lt;presence/&gt;, or &lt;iq/&gt; element that is qualified by the 'jabber:client' or 'jabber:server' namespace but that occurs at a depth other than one (e.g., a &lt;message/&gt; element contained within an extension element (<a class='info' href='#stanzas-extended'>Section&nbsp;8.4<span> (</span><span class='info'>Extended Content</span><span>)</span></a>) for reporting purposes), nor is a &lt;message/&gt;, &lt;presence/&gt;, or &lt;iq/&gt; element that is qualified by a namespace other than 'jabber:client' or 'jabber:server'.  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 <a class='info' href='#XML-NAMES'>[XML&#8209;NAMES]<span> (</span><span class='info'>Thompson, H., Hollander, D., Layman, A., Bray, T., and R. Tobin, &ldquo;Namespaces in XML 1.0 (Third Edition),&rdquo; December&nbsp;2009.</span><span>)</span></a> as well as <a class='info' href='#stanzas-extended'>Section&nbsp;8.4<span> (</span><span class='info'>Extended Content</span><span>)</span></a> in this specification).
</dd>
</dl></blockquote><p>
      
</p>
<p>There are three kinds of stanzas: message, presence, and IQ (short for
"Info/Query").  These stanza types provide three different communication
primitives: a "push" mechanism for generalized messaging, a specialized
"publish-subscribe" mechanism for broadcasting information about network
availability, and a "request-response" mechanism for more structured exchanges
of data (similar to <a class='info' href='#HTTP'>[HTTP]<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, &ldquo;Hypertext Transfer Protocol -- HTTP/1.1,&rdquo; June&nbsp;1999.</span><span>)</span></a>).  Further explanations are provided
under Sections <a class='info' href='#stanzas-semantics-message'>8.2.1<span> (</span><span class='info'>Message Semantics</span><span>)</span></a>,
<a class='info' href='#stanzas-semantics-presence'>8.2.2<span> (</span><span class='info'>Presence Semantics</span><span>)</span></a>, and <a class='info' href='#stanzas-semantics-iq'>8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>, respectively.
</p>
<p>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, preferably preceded by an XML declaration specifying the XML version and the character encoding supported (see <a class='info' href='#xml-declaration'>Section&nbsp;11.5<span> (</span><span class='info'>Inclusion of XML Declaration</span><span>)</span></a> and <a class='info' href='#xml-encoding'>Section&nbsp;11.6<span> (</span><span class='info'>Character Encoding</span><span>)</span></a>).  Subject to local policies and service provisioning, the server then replies with a second XML stream back to the client, again preferably preceded by an XML declaration.  Once the client has completed <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a> and <a class='info' href='#bind'>resource binding<span> (</span><span class='info'>Resource Binding</span><span>)</span></a>, 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 &lt;/stream&gt; tag to the server  as further described under <a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a>.
</p>
<p>In essence, then, one XML stream functions as an envelope for the XML stanzas sent during a session and another XML stream functions as an envelope for the XML stanzas received during a session.  We can represent this in a simplistic fashion as follows.
</p><br /><hr class="insert" />
<a name="figure-2"></a>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+--------------------+--------------------+
| INITIAL STREAM     |  RESPONSE STREAM   |
+--------------------+--------------------+
| &lt;stream&gt;           |                    |
|--------------------|--------------------|
|                    | &lt;stream&gt;           |
|--------------------|--------------------|
| &lt;presence&gt;         |                    |
|   &lt;show/&gt;          |                    |
| &lt;/presence&gt;        |                    |
|--------------------|--------------------|
| &lt;message to='foo'&gt; |                    |
|   &lt;body/&gt;          |                    |
| &lt;/message&gt;         |                    |
|--------------------|--------------------|
| &lt;iq to='bar'       |                    |
|     type='get'&gt;    |                    |
|   &lt;query/&gt;         |                    |
| &lt;/iq&gt;              |                    |
|--------------------|--------------------|
|                    | &lt;iq from='bar'     |
|                    |     type='result'&gt; |
|                    |   &lt;query/&gt;         |
|                    | &lt;/iq&gt;              |
|--------------------|--------------------|
| [ ... ]            |                    |
|--------------------|--------------------|
|                    | [ ... ]            |
|--------------------|--------------------|
| &lt;/stream&gt;          |                    |
|--------------------|--------------------|
|                    | &lt;/stream&gt;          |
+--------------------+--------------------+
</pre></div><table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b>&nbsp;Figure&nbsp;2: A Simplistic View of Two Streams&nbsp;</b></font><br /></td></tr></table><hr class="insert" />

<p>Those who are accustomed to thinking of XML in a document-centric manner might find the following analogies useful:
</p>
<p>
        </p>
<ul class="text">
<li>The two XML streams are like two "documents" (matching the "document" production from <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>) that are built up through the accumulation of XML stanzas.
</li>
<li>The root &lt;stream/&gt; element is like the "document entity" for each "document" (as described in Section 4.8 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>).
</li>
<li>The XML stanzas sent over the streams are like "fragments" of the "documents" (as described in <a class='info' href='#XML-FRAG'>[XML&#8209;FRAG]<span> (</span><span class='info'>Grosso, P. and D. Veillard, &ldquo;XML Fragment Interchange,&rdquo; February&nbsp;2001.</span><span>)</span></a>).
</li>
</ul><p>
      
</p>
<p>However, these descriptions are merely analogies, because XMPP does not deal in documents and fragments but in streams and stanzas.
</p>
<p>The remainder of this section defines the following aspects of XML streams (along with related topics):
</p>
<p>
        </p>
<ul class="text">
<li>How to open a stream (<a class='info' href='#streams-open'>Section&nbsp;4.2<span> (</span><span class='info'>Opening a Stream</span><span>)</span></a>)
</li>
<li>The stream negotiation process (<a class='info' href='#streams-negotiation'>Section&nbsp;4.3<span> (</span><span class='info'>Stream Negotiation</span><span>)</span></a>)
</li>
<li>How to close a stream (<a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a>)
</li>
<li>The directionality of XML streams (<a class='info' href='#streams-direction'>Section&nbsp;4.5<span> (</span><span class='info'>Directionality</span><span>)</span></a>)
</li>
<li>How to handle peers that are silent (<a class='info' href='#streams-silence'>Section&nbsp;4.6<span> (</span><span class='info'>Handling of Silent Peers</span><span>)</span></a>)
</li>
<li>The XML attributes of a stream (<a class='info' href='#streams-attr'>Section&nbsp;4.7<span> (</span><span class='info'>Stream Attributes</span><span>)</span></a>)
</li>
<li>The XML namespaces of a stream (<a class='info' href='#streams-ns'>Section&nbsp;4.8<span> (</span><span class='info'>XML Namespaces</span><span>)</span></a>)
</li>
<li>Error handling related to XML streams (<a class='info' href='#streams-error'>Section&nbsp;4.9<span> (</span><span class='info'>Stream Errors</span><span>)</span></a>)
</li>
</ul><p>
      
</p>
<a name="streams-open"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.2"></a><h3>4.2.&nbsp;
Opening a Stream</h3>

<p>After connecting to the appropriate IP address and port of the receiving entity, the initiating entity opens a stream by sending a stream header (the "initial stream header") to the receiving entity.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>The receiving entity then replies by sending a stream header of its own (the "response stream header") to the initiating entity.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>The entities can then proceed with the remainder of the stream negotiation process.
</p>
<a name="streams-negotiation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3"></a><h3>4.3.&nbsp;
Stream Negotiation</h3>

<a name="streams-negotiation-basics"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3.1"></a><h3>4.3.1.&nbsp;
Basic Concepts</h3>

<p>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 (for client-to-server streams this means using SASL as described under <a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>).  However, the receiving entity can consider conditions other than authentication to be mandatory-to-negotiate, such as encryption using TLS as described under <a class='info' href='#tls'>Section&nbsp;5<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a>.  The receiving entity informs the initiating entity about such conditions by communicating "stream features": the set of particular protocol interactions that the initiating entity needs to complete before the receiving entity will accept XML stanzas from the initiating entity, as well as any protocol interactions that are voluntary-to-negotiate but that might improve the handling of an XML stream (e.g., establishment of application-layer compression as described in <a class='info' href='#XEP-0138'>[XEP&#8209;0138]<span> (</span><span class='info'>Hildebrand, J. and P. Saint-Andre, &ldquo;Stream Compression,&rdquo; May&nbsp;2009.</span><span>)</span></a>).
</p>
<p>The existence of conditions for connecting implies that
        streams need to be negotiated.  The order of layers (TCP, then
        TLS, then SASL, then XMPP as described under
        <a class='info' href='#security-layers'>Section&nbsp;13.3<span> (</span><span class='info'>Order of Layers</span><span>)</span></a>) 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.
</p>
<a name="streams-negotiation-features"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3.2"></a><h3>4.3.2.&nbsp;
Stream Features Format</h3>

<p>If the initiating entity includes in the initial stream header the 'version' attribute set to a value of at least "1.0" (see <a class='info' href='#streams-attr-version'>Section&nbsp;4.7.5<span> (</span><span class='info'>version</span><span>)</span></a>), after sending the response stream header the receiving entity MUST send a &lt;features/&gt; child element (typically prefixed by the stream namespace prefix as described under <a class='info' href='#streams-ns-declarations'>Section&nbsp;4.8.5<span> (</span><span class='info'>Namespace Declarations and Prefixes</span><span>)</span></a>) 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 &lt;features/&gt; element, qualified by a namespace that is different from the stream namespace and the content namespace.  The &lt;features/&gt; element can contain one child, contain multiple children, or be empty.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: The order of child elements contained in any given &lt;features/&gt; element is not significant.
</p>
</blockquote>

<p>If a particular stream feature is or can be mandatory-to-negotiate, the definition of that feature needs to do one of the following:
</p>
<p>
          </p>
<ol class="text">
<li>Declare that the feature is always mandatory-to-negotiate (e.g., this is true of resource binding for XMPP clients); or
</li>
<li>Specify a way for the receiving entity to flag the feature as mandatory-to-negotiate for this interaction (e.g., for STARTTLS, this is done by including an empty &lt;required/&gt; element in the advertisement for that stream feature, but that is not a generic format for all stream features); it is RECOMMENDED that stream feature definitions for new mandatory-to-negotiate features do so by including an empty &lt;required/&gt; element as is done for STARTTLS.
</li>
</ol><p>
        
</p>
<p></p>
<blockquote class="text">
<p>Informational Note: Because there is no generic format for indicating that a feature is mandatory-to-negotiate, it is possible that a feature that 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.
</p>
</blockquote>

<p>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 specify that a stream restart is expected after negotiation of the feature.
</p>
<p>A &lt;features/&gt; 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 features.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:features&gt;
     &lt;starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'&gt;
       &lt;required/&gt;
     &lt;/starttls&gt;
   &lt;/stream:features&gt;
</pre></div>
<p>A &lt;features/&gt; element MAY contain more than one mandatory-to-negotiate feature.  This means that the initiating entity can choose among the mandatory-to-negotiate features at this stage of the stream negotiation process.  As an 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 at the same stage of the stream negotiation process.  However, this applies only at a given stage of the stream negotiation process and does not apply to features that are mandatory-to-negotiate at different stages (e.g., the receiving entity would not advertise both STARTTLS and SASL as mandatory-to-negotiate, or both SASL and resource binding as mandatory-to-negotiate, because TLS would need to be negotiated before SASL and because SASL would need to be negotiated before resource binding).
</p>
<p>A &lt;features/&gt; element that contains both mandatory-to-negotiate and voluntary-to-negotiate features indicates that the negotiation is not complete but that the initiating entity MAY complete the voluntary-to-negotiate feature(s) before it attempts to negotiate the mandatory-to-negotiate feature(s).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:features&gt;
     &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/&gt;
     &lt;compression xmlns='http://jabber.org/features/compress'&gt;
       &lt;method&gt;zlib&lt;/method&gt;
       &lt;method&gt;lzw&lt;/method&gt;
     &lt;/compression&gt;
   &lt;/stream:features&gt;
</pre></div>
<p>A &lt;features/&gt; element that contains only voluntary-to-negotiate 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.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:features&gt;
     &lt;compression xmlns='http://jabber.org/features/compress'&gt;
       &lt;method&gt;zlib&lt;/method&gt;
       &lt;method&gt;lzw&lt;/method&gt;
     &lt;/compression&gt;
   &lt;/stream:features&gt;
</pre></div>
<p>An empty &lt;features/&gt; element indicates that the stream negotiation is complete and that the initiating entity is cleared to send XML stanzas.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:features/&gt;
</pre></div>
<a name="streams-negotiation-restart"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3.3"></a><h3>4.3.3.&nbsp;
Restarts</h3>

<p>On successful negotiation of a feature that necessitates a stream restart, both parties MUST consider the previous stream to be replaced but MUST NOT send a closing &lt;/stream&gt; tag and 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 <a class='info' href='#xml-declaration'>Section&nbsp;11.5<span> (</span><span class='info'>Inclusion of XML Declaration</span><span>)</span></a>.  When the receiving entity receives the new initial stream header, it MUST generate a new stream ID (instead of reusing the old stream ID) before sending a new response stream header (which SHOULD be preceded by an XML declaration as described under <a class='info' href='#xml-declaration'>Section&nbsp;11.5<span> (</span><span class='info'>Inclusion of XML Declaration</span><span>)</span></a>).
</p>
<a name="streams-negotiation-resend"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3.4"></a><h3>4.3.4.&nbsp;
Resending Features</h3>

<p>The receiving entity MUST send an updated list of stream features to the initiating entity after 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.
</p>
<a name="streams-negotiation-complete"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3.5"></a><h3>4.3.5.&nbsp;
Completion of Stream Negotiation</h3>

<p>The receiving entity indicates completion of the stream negotiation process by sending to the initiating entity either an empty &lt;features/&gt; element or a &lt;features/&gt; element that contains only voluntary-to-negotiate features.  After doing so, the receiving entity MAY send an empty &lt;features/&gt; element (e.g., after negotiation of such voluntary-to-negotiate 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 with a &lt;reset/&gt; stream error (<a class='info' href='#streams-error-conditions-reset'>Section&nbsp;4.9.3.16<span> (</span><span class='info'>reset</span><span>)</span></a>) 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.
</p>
<p></p>
<blockquote class="text">
<p>Informational Note: Resource binding as specified under <a class='info' href='#bind'>Section&nbsp;7<span> (</span><span class='info'>Resource Binding</span><span>)</span></a> is an historical exception to the foregoing rule, since it is mandatory-to-negotiate for clients but uses XML stanzas for negotiation purposes.
</p>
</blockquote>

<p>The initiating entity MUST NOT attempt to send <a class='info' href='#stanzas'>XML stanzas<span> (</span><span class='info'>XML Stanzas</span><span>)</span></a> 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.  Even if the initiating entity does attempt to do so, the receiving entity MUST NOT accept such stanzas and MUST close the stream with a &lt;not-authorized/&gt; stream error (<a class='info' href='#streams-error-conditions-not-authorized'>Section&nbsp;4.9.3.12<span> (</span><span class='info'>not-authorized</span><span>)</span></a>).  This rule applies to XML stanzas only (i.e., &lt;message/&gt;, &lt;presence/&gt;, and &lt;iq/&gt; elements qualified by the content namespace) and not to XML elements used for stream negotiation (e.g., elements used to complete <a class='info' href='#tls'>TLS negotiation<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a> or <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>).
</p>
<a name="streams-negotiation-address"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3.6"></a><h3>4.3.6.&nbsp;
Determination of Addresses</h3>

<p>After the parties to an XML stream have completed the appropriate aspects of stream negotiation, the receiving entity for a stream MUST determine the initiating entity's JID.
</p>
<p>For client-to-server communication, both <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a> and <a class='info' href='#bind'>resource binding<span> (</span><span class='info'>Resource Binding</span><span>)</span></a> MUST be completed before the server can determine the client's address.  The client's bare JID (&lt;localpart@domainpart&gt;) MUST be the authorization identity (as defined by <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a>), either (1) as directly communicated by the client during <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a> or (2) as derived by the server from the authentication identity if no authorization identity was specified during SASL negotiation.  The resourcepart of the full JID (&lt;localpart@domainpart/resourcepart&gt;) MUST be the resource negotiated by the client and server during <a class='info' href='#bind'>resource binding<span> (</span><span class='info'>Resource Binding</span><span>)</span></a>.  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.  The server MUST ensure that the resulting JID (including localpart, domainpart, resourcepart, and separator characters) conforms to the canonical format for XMPP addresses defined in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>; to meet this restriction, the server MAY replace the JID sent by the client with the canonicalized JID as determined by the server and communicate that JID to the client during resource binding.
</p>
<p>For server-to-server communication, the initiating server's bare JID (&lt;domainpart&gt;) MUST be the authorization identity (as defined by <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a>), either (1) as directly communicated by the initiating server during <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a> or (2) as derived by the receiving server from the authentication identity if no authorization identity was specified during SASL negotiation. In the absence of SASL negotiation, the receiving server MAY consider the authorization identity to be an identity negotiated within the relevant verification protocol (e.g., the 'from' attribute of the &lt;result/&gt; element in Server Dialback <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>).
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: Because it is possible for a third party to tamper with information that is sent over the stream before a security layer such as TLS is successfully negotiated, it is advisable for the receiving server to treat any such unprotected information with caution; this applies especially to the 'from' and 'to' addresses on the first initial stream header sent by the initiating entity.
</p>
</blockquote>

<a name="streams-negotiation-flowchart"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.3.7"></a><h3>4.3.7.&nbsp;
Flow Chart</h3>

<p>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.
</p><br /><hr class="insert" />
<a name="figure-3"></a>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
                +---------------------+
                | open TCP connection |
                +---------------------+
                           |
                           v
                    +---------------+
                    | send initial  |&lt;-------------------------+
                    | stream header |                          ^
                    +---------------+                          |
                           |                                   |
                           v                                   |
                   +------------------+                        |
                   | receive response |                        |
                   | stream header    |                        |
                   +------------------+                        |
                           |                                   |
                           v                                   |
                    +----------------+                         |
                    | receive stream |                         |
+------------------&gt;| features       |                         |
^   {OPTIONAL}      +----------------+                         |
|                          |                                   |
|                          v                                   |
|       +&lt;-----------------+                                   |
|       |                                                      |
|    {empty?} ----&gt; {all voluntary?} ----&gt; {some mandatory?}   |
|       |      no          |          no         |             |
|       | yes              | yes                 | yes         |
|       |                  v                     v             |
|       |           +---------------+    +----------------+    |
|       |           | MAY negotiate |    | MUST negotiate |    |
|       |           | any or none   |    | one feature    |    |
|       |           +---------------+    +----------------+    |
|       v                  |                     |             |
|   +---------+            v                     |             |
|   |  DONE   |&lt;----- {negotiate?}               |             |
|   +---------+   no       |                     |             |
|                     yes  |                     |             |
|                          v                     v             |
|                          +---------&gt;+&lt;---------+             |
|                                     |                        |
|                                     v                        |
+&lt;-------------------------- {restart mandatory?} ------------&gt;+
               no                                     yes

</pre></div><table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b>&nbsp;Figure&nbsp;3: Stream Negotiation Flow Chart&nbsp;</b></font><br /></td></tr></table><hr class="insert" />

<a name="streams-close"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.4"></a><h3>4.4.&nbsp;
Closing a Stream</h3>

<p>An XML stream from one entity to another can be closed at any time, either because a specific stream error (<a class='info' href='#streams-error'>Section&nbsp;4.9<span> (</span><span class='info'>Stream Errors</span><span>)</span></a>) has occurred or in the absence of an error (e.g., when a client simply ends its session).
</p>
<p>A stream is closed by sending a closing &lt;/stream&gt; tag.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
E: &lt;/stream:stream&gt;
</pre></div>
<p>If the parties are using either two streams over a single TCP connection or two streams over two TCP connections, the entity that sends the closing stream tag MUST behave as follows:
</p>
<p>
        </p>
<ol class="text">
<li>Wait for the other party to also close its outbound
          stream before terminating the underlying TCP connection(s);
          this gives the other party an opportunity to finish
          transmitting any outbound data to the closing entity before
          the termination of the TCP connection(s).
</li>
<li>Refrain from sending any further data over its outbound stream to the other entity, but continue to process data received from the other entity (and, if necessary, process such data).
</li>
<li>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).
</li>
<li>After receiving a reciprocal closing stream tag from the other party or waiting a reasonable amount of time with no response, terminate the underlying TCP connection(s).
</li>
</ol><p>
      
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: In accordance with Section 7.2.1 of <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a>, to help prevent a truncation attack the party that is closing the stream MUST send a TLS close_notify alert and MUST receive a responding close_notify alert from the other party before terminating the underlying TCP connection(s).
</p>
</blockquote>

<p>If the parties are using multiple streams over multiple TCP connections, there is no defined pairing of streams and therefore the behavior is a matter for implementation.
</p>
<a name="streams-direction"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.5"></a><h3>4.5.&nbsp;
Directionality</h3>

<p>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).
</p>
<p>Depending on the type of session that has been negotiated and the nature of the entities involved, the entities might use:
</p>
<p>
        </p>
<ul class="text">
<li>Two streams over a single TCP connection, where the security context negotiated for the first stream is applied to the second stream.  This is typical for client-to-server sessions, and a server MUST allow a client to use the same TCP connection for both streams.
</li>
<li>Two streams over two TCP connections, where each stream is separately secured.  In this approach, 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.
</li>
<li>Multiple streams over two or more TCP connections, where each stream is separately secured.  This approach is sometimes used for server-to-server communication between two large XMPP service providers; however, this can make it difficult to maintain coherence of data received over multiple streams in situations described under <a class='info' href='#rules-order'>Section&nbsp;10.1<span> (</span><span class='info'>In-Order Processing</span><span>)</span></a>, which is why a server MAY close the stream with a &lt;conflict/&gt; stream error (<a class='info' href='#streams-error-conditions-conflict'>Section&nbsp;4.9.3.3<span> (</span><span class='info'>conflict</span><span>)</span></a>) if a remote server attempts to negotiate more than one stream (as described under <a class='info' href='#streams-error-conditions-conflict'>Section&nbsp;4.9.3.3<span> (</span><span class='info'>conflict</span><span>)</span></a>).
</li>
</ul><p>
      
</p>
<p>This concept of directionality applies only to stanzas and explicitly does not apply to first-level children of the stream root that are used to bootstrap or manage the stream (e.g., first-level elements used for TLS negotiation, SASL negotiation, Server Dialback <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>, and Stream Management <a class='info' href='#XEP-0198'>[XEP&#8209;0198]<span> (</span><span class='info'>Karneges, J., Hildebrand, J., Saint-Andre, P., Forno, F., Cridland, D., and M. Wild, &ldquo;Stream Management,&rdquo; February&nbsp;2011.</span><span>)</span></a>).
</p>
<p>The foregoing considerations imply that while completing <a class='info' href='#tls'>STARTTLS negotiation<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a> and <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a> 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.  This separate TCP connection is then secured using a new round of TLS and/or SASL negotiation.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: For historical reasons, a server-to-server session always uses two TCP connections.  While that approach remains the standard behavior described in this document, extensions such as <a class='info' href='#XEP-0288'>[XEP&#8209;0288]<span> (</span><span class='info'>Hancke, P. and D. Cridland, &ldquo;Bidirectional Server-to-Server Connections,&rdquo; October&nbsp;2010.</span><span>)</span></a> enable servers to negotiate the use of a single TCP connection for bidirectional stanza exchange.
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>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.
</p>
</blockquote>

<a name="streams-silence"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6"></a><h3>4.6.&nbsp;
Handling of Silent Peers</h3>

<p>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 appear to be silent.  There are several reasons why this might happen:
</p>
<p>
        </p>
<ol class="text">
<li>The underlying TCP connection is dead.
</li>
<li>The XML stream is broken despite the fact that the underlying TCP connection is alive.
</li>
<li>The peer is idle and simply has not sent any XMPP traffic over its XML stream to the entity.
</li>
</ol><p>
      
</p>
<p>These three conditions are best handled separately, as described in the following sections.
</p>
<p></p>
<blockquote class="text">
<p>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 <a class='info' href='#streams-direction'>Section&nbsp;4.5<span> (</span><span class='info'>Directionality</span><span>)</span></a>); 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 somewhat frequent 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.
</p>
</blockquote>

<a name="streams-silence-dead"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6.1"></a><h3>4.6.1.&nbsp;
Dead Connection</h3>

<p>If the underlying TCP connection is dead, stream-level checks (e.g., <a class='info' href='#XEP-0199'>[XEP&#8209;0199]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;XMPP Ping,&rdquo; June&nbsp;2009.</span><span>)</span></a> and <a class='info' href='#XEP-0198'>[XEP&#8209;0198]<span> (</span><span class='info'>Karneges, J., Hildebrand, J., Saint-Andre, P., Forno, F., Cridland, D., and M. Wild, &ldquo;Stream Management,&rdquo; February&nbsp;2011.</span><span>)</span></a>) 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.
</p>
<p>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 <a class='info' href='#xml-whitespace'>Section&nbsp;11.7<span> (</span><span class='info'>Whitespace</span><span>)</span></a>; 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).  However, this is not allowed during TLS negotiation or SASL negotiation, as described under <a class='info' href='#tls-rules-data'>Section&nbsp;5.3.3<span> (</span><span class='info'>Data Formatting</span><span>)</span></a> and <a class='info' href='#sasl-rules-data'>Section&nbsp;6.3.5<span> (</span><span class='info'>Data Formatting</span><span>)</span></a>.
</p>
<a name="streams-silence-broken"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6.2"></a><h3>4.6.2.&nbsp;
Broken Stream</h3>

<p>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 <a class='info' href='#XEP-0199'>[XEP&#8209;0199]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;XMPP Ping,&rdquo; June&nbsp;2009.</span><span>)</span></a> or the more comprehensive Stream Management protocol defined in <a class='info' href='#XEP-0198'>[XEP&#8209;0198]<span> (</span><span class='info'>Karneges, J., Hildebrand, J., Saint-Andre, P., Forno, F., Cridland, D., and M. Wild, &ldquo;Stream Management,&rdquo; February&nbsp;2011.</span><span>)</span></a>.  In this case, it is appropriate for the entity to close a broken stream with a &lt;connection-timeout/&gt; stream error (<a class='info' href='#streams-error-conditions-connection-timeout'>Section&nbsp;4.9.3.4<span> (</span><span class='info'>connection-timeout</span><span>)</span></a>).
</p>
<a name="streams-silence-idle"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6.3"></a><h3>4.6.3.&nbsp;
Idle Peer</h3>

<p>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 itself MAY
        close the stream (as described under
        <a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a>) rather than leaving an unused
        stream open.  If the idle peer does not close the stream, the
        other party MAY either close the stream using the handshake
        described under <a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a> or close the
        stream with a stream error (e.g., &lt;resource-constraint/&gt;
        (<a class='info' href='#streams-error-conditions-resource-constraint'>Section&nbsp;4.9.3.17<span> (</span><span class='info'>resource-constraint</span><span>)</span></a>) if
        the entity has reached a limit on the number of open TCP
        connections or &lt;policy-violation/&gt;
        (<a class='info' href='#streams-error-conditions-policy-violation'>Section&nbsp;4.9.3.14<span> (</span><span class='info'>policy-violation</span><span>)</span></a>)
        if the connection has exceeded a local timeout policy).
        However, consistent with the order of layers (specified under
        <a class='info' href='#security-layers'>Section&nbsp;13.3<span> (</span><span class='info'>Order of Layers</span><span>)</span></a>), 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 time out such a stream.
</p>
<a name="streams-silence-check"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.6.4"></a><h3>4.6.4.&nbsp;
Use of Checking Methods</h3>

<p>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).
</p>
<a name="streams-attr"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7"></a><h3>4.7.&nbsp;
Stream Attributes</h3>

<p>The attributes of the root &lt;stream/&gt; element are defined in the following sections.
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: Until and unless the confidentiality and integrity of the stream are protected via TLS as described under <a class='info' href='#tls'>Section&nbsp;5<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a> or an equivalent security layer (such as the SASL GSSAPI mechanism), the attributes provided in a stream header could be tampered with by an attacker.
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>Implementation Note: The attributes of the root &lt;stream/&gt; element are not prepended by a namespace prefix because, as explained in <a class='info' href='#XML-NAMES'>[XML&#8209;NAMES]<span> (</span><span class='info'>Thompson, H., Hollander, D., Layman, A., Bray, T., and R. Tobin, &ldquo;Namespaces in XML 1.0 (Third Edition),&rdquo; December&nbsp;2009.</span><span>)</span></a>, "[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."
</p>
</blockquote>

<a name="streams-attr-from"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.1"></a><h3>4.7.1.&nbsp;
from</h3>

<p>The 'from' attribute specifies an XMPP identity of the entity sending the stream element.
</p>
<p>For initial stream headers in client-to-server communication, the 'from' attribute is the XMPP identity of the principal controlling the client, i.e., a JID of the form &lt;localpart@domainpart&gt;.  The client might not know the XMPP identity, e.g., because the XMPP identity is assigned at a level other than the XMPP application layer (as in the Generic Security Service Application Program Interface <a class='info' href='#GSS-API'>[GSS&#8209;API]<span> (</span><span class='info'>Linn, J., &ldquo;Generic Security Service Application Program Interface Version 2, Update 1,&rdquo; January&nbsp;2000.</span><span>)</span></a>) or is derived by the server from information provided by the client (as in some deployments of end-user certificates with the SASL EXTERNAL mechanism).  Furthermore, if the client considers the XMPP identity to be private information then it is advised not to include a 'from' attribute before the confidentiality and integrity of the stream are protected via TLS or an equivalent security layer.  However, if the client knows the XMPP identity then it SHOULD include the 'from' attribute after the confidentiality and integrity of the stream are protected via TLS or an equivalent security layer.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>For initial stream headers in server-to-server communication, the 'from' attribute is one of the configured FQDNs of the server, i.e., a JID of the form &lt;domainpart&gt;.  The initiating server might have more than one XMPP identity, e.g., in the case of a server that provides virtual hosting, so it will need to choose an identity that is associated with this output stream (e.g., based on the 'to' attribute of the stanza that triggered the stream negotiation attempt).  Because a server is a "public entity" on the XMPP network, it MUST include the 'from' attribute after the confidentiality and integrity of the stream are protected via TLS or an equivalent security layer.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='example.net'
       to='im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:server'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>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 its value to one of the receiving entity's FQDNs (which MAY be an FQDN other than that specified in the 'to' attribute of the initial stream header, as described under <a class='info' href='#streams-error-rules-host'>Section&nbsp;4.9.1.3<span> (</span><span class='info'>Stream Errors When the Host Is Unspecified or Unknown</span><span>)</span></a> and <a class='info' href='#streams-error-conditions-host-unknown'>Section&nbsp;4.9.3.6<span> (</span><span class='info'>host-unknown</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>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 <a class='info' href='#security-authentication'>Section&nbsp;13.5<span> (</span><span class='info'>Peer Entity Authentication</span><span>)</span></a>.
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: It is possible that implementations based on <a class='info' href='#RFC3920'>[RFC3920]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; October&nbsp;2004.</span><span>)</span></a> will not include the 'from' address on any stream headers (even ones whose confidentiality and integrity are protected); an entity SHOULD be liberal in accepting such stream headers.
</p>
</blockquote>

<a name="streams-attr-to"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.2"></a><h3>4.7.2.&nbsp;
to</h3>

<p>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 domainpart 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 <a class='info' href='#TLS-EXT'>[TLS&#8209;EXT]<span> (</span><span class='info'>Eastlake 3rd, D., &ldquo;Transport Layer Security (TLS) Extensions: Extension Definitions,&rdquo; January&nbsp;2011.</span><span>)</span></a>.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>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.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>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 domainpart specified in the 'from' attribute of the initial stream header.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='g4qSvGvBxJ+xeAd7QKezOQJFFlw='
       to='example.net'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:server'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>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 <a class='info' href='#security-authentication'>Section&nbsp;13.5<span> (</span><span class='info'>Peer Entity Authentication</span><span>)</span></a>.
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: It is possible that implementations based on <a class='info' href='#RFC3920'>[RFC3920]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; October&nbsp;2004.</span><span>)</span></a> will not include the 'to' address on stream headers; an entity SHOULD be liberal in accepting such stream headers.
</p>
</blockquote>

<a name="streams-attr-id"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.3"></a><h3>4.7.3.&nbsp;
id</h3>

<p>The 'id' attribute specifies 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).
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: The stream ID MUST be both unpredictable and non-repeating because it can be security-critical when reused by an authentication mechanisms, as is the case for Server Dialback <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a> and the "XMPP 0.9" authentication mechanism used before RFC 3920 defined the use of SASL in XMPP; for recommendations regarding randomness for security purposes, see <a class='info' href='#RANDOM'>[RANDOM]<span> (</span><span class='info'>Eastlake, D., Schiller, J., and S. Crocker, &ldquo;Randomness Requirements for Security,&rdquo; June&nbsp;2005.</span><span>)</span></a>.
</p>
</blockquote>

<p>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.
</p>
<p>For response stream headers, the receiving entity MUST include the 'id' attribute.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Interoperability Note: In RFC 3920, the text regarding inclusion of the 'id' attribute was ambiguous, leading some implementations to leave the attribute off the response stream header.
</p>
</blockquote>

<a name="streams-attr-xmllang"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.4"></a><h3>4.7.4.&nbsp;
xml:lang</h3>

<p>The 'xml:lang' attribute specifies 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 <a class='info' href='#stanzas-attributes-lang'>Section&nbsp;8.1.5<span> (</span><span class='info'>xml:lang</span><span>)</span></a>).  The syntax of this attribute is defined in Section 2.12 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>; in particular, the value of the 'xml:lang' attribute MUST conform to the NMTOKEN datatype (as defined in Section 2.3 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>) and MUST conform to the language identifier format defined in <a class='info' href='#LANGTAGS'>[LANGTAGS]<span> (</span><span class='info'>Phillips, A. and M. Davis, &ldquo;Tags for Identifying Languages,&rdquo; September&nbsp;2009.</span><span>)</span></a>.
</p>
<p>For initial stream headers, the initiating entity SHOULD include the 'xml:lang' attribute.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>For response stream headers, the receiving entity MUST include the 'xml:lang' attribute.  The following rules apply:
</p>
<p>
          </p>
<ul class="text">
<li>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 &lt;text/&gt; 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").
</li>
<li>If the receiving entity supports a language that matches the initiating entity's preferred language according to the "lookup scheme" specified in Section 3.4 of <a class='info' href='#LANGMATCH'>[LANGMATCH]<span> (</span><span class='info'>Phillips, A. and M. Davis, &ldquo;Matching of Language Tags,&rdquo; September&nbsp;2006.</span><span>)</span></a> (e.g., "de" instead of "de-CH"), then the value of the 'xml:lang' attribute SHOULD be the identifier for the matching language.
</li>
<li>If the receiving entity does not support the initiating entity's preferred language or a matching language according to the lookup scheme (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").
</li>
</ul><p>
        
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>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 <a class='info' href='#stanzas-attributes-lang'>Section&nbsp;8.1.5<span> (</span><span class='info'>xml:lang</span><span>)</span></a>, the initiating entity MAY include the 'xml:lang' attribute in any XML stanzas it sends over the stream.  If the initiating entity does not include the 'xml:lang' attribute in any such stanza, the receiving entity SHOULD add the 'xml:lang' attribute to the stanza when routing it to a remote server or delivering it to a connected client, 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 when routing it to a remote server or delivering it to a connected client.
</p>
<a name="streams-attr-version"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.5"></a><h3>4.7.5.&nbsp;
version</h3>

<p>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 <a class='info' href='#tls'>TLS negotiation<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a>, <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>, <a class='info' href='#streams-negotiation-features'>stream features<span> (</span><span class='info'>Stream Features Format</span><span>)</span></a>, and <a class='info' href='#streams-error'>stream errors<span> (</span><span class='info'>Stream Errors</span><span>)</span></a>.
</p>
<p>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 (&lt;message/&gt;,
&lt;presence/&gt;, and &lt;iq/&gt; as described under Sections <a class='info' href='#stanzas-semantics-message'>8.2.1<span> (</span><span class='info'>Message Semantics</span><span>)</span></a>, <a class='info' href='#stanzas-semantics-presence'>8.2.2<span> (</span><span class='info'>Presence Semantics</span><span>)</span></a>, and <a class='info' href='#stanzas-semantics-iq'>8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>, respectively).
</p>
<p>The numbering scheme for XMPP versions is "&lt;major&gt;.&lt;minor&gt;".  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.
</p>
<p>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.
</p>
<p>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).
</p>
<p>The following rules apply to the generation and handling of the 'version' attribute within stream headers:
</p>
<p>
          </p>
<ol class="text">
<li>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").
</li>
<li>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 "&lt;major&gt;.&lt;minor&gt;".
</li>
<li>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 close the stream with an &lt;unsupported-version/&gt; stream error (<a class='info' href='#streams-error-conditions-unsupported-version'>Section&nbsp;4.9.3.25<span> (</span><span class='info'>unsupported-version</span><span>)</span></a>).
</li>
<li>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.
</li>
</ol><p>
        
</p>
<a name="streams-attr-summary"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.7.6"></a><h3>4.7.6.&nbsp;
Summary of Stream Attributes</h3>

<p>The following table summarizes the attributes of the root &lt;stream/&gt; element.
</p><br /><hr class="insert" />
<a name="figure-4"></a>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
+----------+--------------------------+-------------------------+
|          | 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     |
+----------+--------------------------+-------------------------+
</pre></div><table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b>&nbsp;Figure&nbsp;4: Stream Attributes&nbsp;</b></font><br /></td></tr></table><hr class="insert" />

<a name="streams-ns"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.8"></a><h3>4.8.&nbsp;
XML Namespaces</h3>

<p>Readers are referred to the specification of XML namespaces <a class='info' href='#XML-NAMES'>[XML&#8209;NAMES]<span> (</span><span class='info'>Thompson, H., Hollander, D., Layman, A., Bray, T., and R. Tobin, &ldquo;Namespaces in XML 1.0 (Third Edition),&rdquo; December&nbsp;2009.</span><span>)</span></a> for a full understanding of the concepts used in this section, especially the concept of a "default namespace" as provided in Section 3 and Section 6.2 of that specification.
</p>
<a name="streams-ns-stream"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.8.1"></a><h3>4.8.1.&nbsp;
Stream Namespace</h3>

<p>The root &lt;stream/&gt; element ("stream header") MUST be qualified by the namespace 'http://etherx.jabber.org/streams' (the "stream namespace").  If this rule is violated, the entity that receives the offending stream header MUST close the stream with a stream error, which SHOULD be &lt;invalid-namespace/&gt; (<a class='info' href='#streams-error-conditions-invalid-namespace'>Section&nbsp;4.9.3.10<span> (</span><span class='info'>invalid-namespace</span><span>)</span></a>), although some existing implementations send &lt;bad-format/&gt; (<a class='info' href='#streams-error-conditions-bad-format'>Section&nbsp;4.9.3.1<span> (</span><span class='info'>bad-format</span><span>)</span></a>) instead.
</p>
<a name="streams-ns-content"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.8.2"></a><h3>4.8.2.&nbsp;
Content Namespace</h3>

<p>An entity MAY declare a "content namespace" as the default namespace for data sent over the stream (i.e., data other than elements qualified by the stream namespace).  If so, (1) the content namespace MUST be other than the stream namespace, and (2) the content namespace MUST be the same for the initial stream and the response stream so that both streams are qualified consistently.  The content namespace applies to all first-level child elements sent over the stream unless explicitly qualified by another namespace (i.e., the content namespace is the default namespace).
</p>
<p>Alternatively (i.e., instead of declaring the content namespace as the default namespace), an entity MAY explicitly qualify the namespace for each first-level child element of the stream, using so-called "prefix-free canonicalization".  These two styles are shown in the following examples.
</p>
<p>When a content namespace is declared as the default namespace, in rough outline a stream will look something like the following.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;stream:stream
    from='juliet@im.example.com'
    to='im.example.com'
    version='1.0'
    xml:lang='en'
    xmlns='jabber:client'
    xmlns:stream='http://etherx.jabber.org/streams'&gt;
  &lt;message&gt;
    &lt;body&gt;foo&lt;/body&gt;
  &lt;/message&gt;
&lt;/stream:stream&gt;
</pre></div>
<p>When a content namespace is not declared as the default namespace and so-called "prefix-free canonicalization" is used instead, in rough outline a stream will look something like the following.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;stream
    from='juliet@im.example.com'
    to='im.example.com'
    version='1.0'
    xml:lang='en'
    xmlns='http://etherx.jabber.org/streams'&gt;
  &lt;message xmlns='jabber:client'&gt;
    &lt;body&gt;foo&lt;/body&gt;
  &lt;/message&gt;
&lt;/stream&gt;
</pre></div>
<p>Traditionally, most XMPP implementations have used the content-namespace-as-default-namespace style rather than the prefix-free canonicalization style for stream headers; however, both styles are acceptable since they are semantically equivalent.
</p>
<a name="streams-ns-xmpp"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.8.3"></a><h3>4.8.3.&nbsp;
XMPP Content Namespaces</h3>

<p>XMPP as defined in this specification uses two content 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 content namespaces implies support for the <a class='info' href='#stanzas-attributes'>common attributes<span> (</span><span class='info'>Common Attributes</span><span>)</span></a> and <a class='info' href='#stanzas-semantics'>basic semantics<span> (</span><span class='info'>Basic Semantics</span><span>)</span></a> of all three core stanza types (message, presence, and IQ).
</p>
<p>An implementation MAY support content 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.
</p>
<p>An implementation MAY refuse to support any other content namespaces as default namespaces.  If an entity receives a first-level child element qualified by a content namespace it does not support, it MUST close the stream with an &lt;invalid-namespace/&gt; stream error (<a class='info' href='#streams-error-conditions-invalid-namespace'>Section&nbsp;4.9.3.10<span> (</span><span class='info'>invalid-namespace</span><span>)</span></a>).
</p>
<p>Client implementations MUST support the 'jabber:client' content namespace as a default namespace.  The 'jabber:server' content namespace is out of scope for an XMPP client, and a client MUST NOT send stanzas qualified by the 'jabber:server' namespace.
</p>
<p>Server implementations MUST support as default content namespaces both the 'jabber:client' namespace (when the stream is used for communication between a client and a server) and the 'jabber:server' namespace (when the stream is used for communication between two servers).  When communicating with a connected client, a server MUST NOT send stanzas qualified by the 'jabber:server' namespace; when communicating with a peer server, a server MUST NOT send stanzas qualified by the 'jabber:client' namespace.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: Because a client sends stanzas over a stream whose content namespace is 'jabber:client', if a server routes to a peer server a stanza it has received from a connected client then it needs to "re-scope" the stanza so that its content namespace is 'jabber:server'.  Similarly, if a server delivers to a connected client a stanza it has received from a peer server then it needs to "re-scope" the stanza so that its content namespace is 'jabber:client'.  This rule applies to XML stanzas as defined under <a class='info' href='#streams-fundamentals'>Section&nbsp;4.1<span> (</span><span class='info'>Stream Fundamentals</span><span>)</span></a> (i.e., a first-level &lt;message/&gt;, &lt;presence/&gt;, or &lt;iq/&gt; element qualified by the 'jabber:client' or 'jabber:server' namespace), and by namespace inheritance to all child elements of a stanza. However, the rule does not apply to elements qualified by namespaces other than 'jabber:client' and 'jabber:server' nor to any children of such elements (e.g., a &lt;message/&gt; element contained within an extension element (<a class='info' href='#stanzas-extended'>Section&nbsp;8.4<span> (</span><span class='info'>Extended Content</span><span>)</span></a>) for reporting purposes).  Although it is not forbidden for an entity to generate stanzas in which an extension element contains a child element qualified by the 'jabber:client' or 'jabber:server' namespace, existing implementations handle such stanzas inconsistently; therefore, implementers are advised to weigh the likely lack of interoperability against the possible utility of such stanzas.  Finally, servers are advised to apply stanza re-scoping to other stream connection methods and alternative XMPP connection methods, such as those specified in <a class='info' href='#XEP-0124'>[XEP&#8209;0124]<span> (</span><span class='info'>Paterson, I., Smith, D., and P. Saint-Andre, &ldquo;Bidirectional-streams Over Synchronous HTTP (BOSH),&rdquo; July&nbsp;2010.</span><span>)</span></a>, <a class='info' href='#XEP-0206'>[XEP&#8209;0206]<span> (</span><span class='info'>Paterson, I. and P. Saint-Andre, &ldquo;XMPP Over BOSH,&rdquo; July&nbsp;2010.</span><span>)</span></a>, <a class='info' href='#XEP-0114'>[XEP&#8209;0114]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Jabber Component Protocol,&rdquo; March&nbsp;2005.</span><span>)</span></a>, and <a class='info' href='#XEP-0225'>[XEP&#8209;0225]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Component Connections,&rdquo; October&nbsp;2008.</span><span>)</span></a>.
</p>
</blockquote>

<a name="streams-ns-other"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.8.4"></a><h3>4.8.4.&nbsp;
Other Namespaces</h3>

<p>Either party to a stream MAY send data qualified by namespaces other than the content namespace and the stream namespace.  For example, this is how data related to TLS negotiation and SASL negotiation are exchanged, as well as XMPP extensions such as Stream Management <a class='info' href='#XEP-0198'>[XEP&#8209;0198]<span> (</span><span class='info'>Karneges, J., Hildebrand, J., Saint-Andre, P., Forno, F., Cridland, D., and M. Wild, &ldquo;Stream Management,&rdquo; February&nbsp;2011.</span><span>)</span></a> and Server Dialback <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>.
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: For historical reasons, some server implementations expect a declaration of the 'jabber:server:dialback' namespace on server-to-server streams, as explained in <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>.
</p>
</blockquote>

<p>However, an XMPP server MUST NOT route or deliver data received over an input stream if that data is (a) qualified by another namespace and (b) addressed to an entity other than the server, unless the other party to the output stream over which the server would send the data has explicitly negotiated or advertised support for receiving arbitrary data from the server.  This rule is included because XMPP is designed for the exchange of XML stanzas (not arbitrary XML data), and because allowing an entity to send arbitrary data to other entities could significantly increase the potential for exchanging malicious information.  As an example of this rule, the server hosting the example.net domain would not route the following first-level XML element from &lt;romeo@example.net&gt; to &lt;juliet@example.com&gt;:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  &lt;ns1:foo xmlns:ns1='http://example.org/ns1'
           from='romeo@example.net/resource1'
           to='juliet@example.com'&gt;
    &lt;ns1:bar/&gt;
  &lt;/ns1:foo&gt;
</pre></div>
<p>This rule also applies to first-level elements that look like stanzas but that are improperly namespaced and therefore really are not stanzas at all (see also <a class='info' href='#streams-ns-declarations'>Section&nbsp;4.8.5<span> (</span><span class='info'>Namespace Declarations and Prefixes</span><span>)</span></a>), for example:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
  &lt;ns2:message xmlns:ns2='http://example.org/ns2'
               from='romeo@example.net/resource1'
               to='juliet@example.com'&gt;
    &lt;body&gt;hi&lt;/body&gt;
  &lt;/ns2:message&gt;
</pre></div>
<p>Upon receiving arbitrary first-level XML elements over an input stream, a server MUST either ignore the data or close the stream with a stream error, which SHOULD be &lt;unsupported-stanza-type/&gt; (<a class='info' href='#streams-error-conditions-unsupported-stanza-type'>Section&nbsp;4.9.3.24<span> (</span><span class='info'>unsupported-stanza-type</span><span>)</span></a>).
</p>
<a name="streams-ns-declarations"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.8.5"></a><h3>4.8.5.&nbsp;
Namespace Declarations and Prefixes</h3>

<p>Because the content namespace is other than the stream namespace, if a content namespace is declared as the default namespace then the following statements are true:
</p>
<p>
          </p>
<ol class="text">
<li>The stream header needs to contain a namespace declaration for both the content namespace and the stream namespace.
</li>
<li>The stream namespace declaration needs to include a namespace prefix for the stream namespace.
</li>
</ol><p>
        
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: For historical reasons, an implementation MAY accept only the prefix 'stream' for the stream namespace (resulting in prefixed names such as &lt;stream:stream&gt; and &lt;stream:features&gt;); this specification retains that allowance from <a class='info' href='#RFC3920'>[RFC3920]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; October&nbsp;2004.</span><span>)</span></a> for the purpose of backward compatibility.  Implementations are advised that using a prefix other than 'stream' for the stream namespace might result in interoperability problems.  If an entity receives a stream header with a stream namespace prefix it does not accept, it MUST close the stream with a stream error, which SHOULD be &lt;bad-namespace-prefix/&gt; (<a class='info' href='#streams-error-conditions-bad-namespace-prefix'>Section&nbsp;4.9.3.2<span> (</span><span class='info'>bad-namespace-prefix</span><span>)</span></a>), although some existing implementations send &lt;bad-format/&gt; (<a class='info' href='#streams-error-conditions-bad-format'>Section&nbsp;4.9.3.1<span> (</span><span class='info'>bad-format</span><span>)</span></a>) instead.
</p>
</blockquote>

<p>An implementation MUST NOT generate namespace prefixes for elements qualified by the content namespace (i.e., the default namespace for data sent over the stream) if the content namespace is 'jabber:client' or 'jabber:server'.  For example, the following is illegal:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;stream:stream
    from='juliet@im.example.com'
    to='im.example.com'
    version='1.0'
    xml:lang='en'
    xmlns='jabber:client'
    xmlns:stream='http://etherx.jabber.org/streams'&gt;

  &lt;foo:message xmlns:foo='jabber:client'&gt;
    &lt;foo:body&gt;foo&lt;/foo:body&gt;
  &lt;/foo:message&gt;
</pre></div>
<p>An XMPP entity SHOULD NOT accept data that violates this rule (in
particular, an XMPP server MUST NOT route or deliver such data to another
entity without first correcting the error); instead it SHOULD either ignore the data or close the stream with a stream error, which SHOULD be &lt;bad-namespace-prefix/&gt; (<a class='info' href='#streams-error-conditions-bad-namespace-prefix'>Section&nbsp;4.9.3.2<span> (</span><span class='info'>bad-namespace-prefix</span><span>)</span></a>).
</p>
<p>Namespaces declared in a stream header MUST apply only to that stream (e.g., the 'jabber:server:dialback' namespace used in Server Dialback <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>).  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 <a class='info' href='#stanzas-extended'>Section&nbsp;8.4<span> (</span><span class='info'>Extended Content</span><span>)</span></a>).  If either party to a stream declares such namespaces, the other party to the stream SHOULD close the stream with an &lt;invalid-namespace/&gt; stream error (<a class='info' href='#streams-error-conditions-invalid-namespace'>Section&nbsp;4.9.3.10<span> (</span><span class='info'>invalid-namespace</span><span>)</span></a>).  In any case, an entity MUST ensure that such namespaces are properly declared (according to this section) when routing or delivering stanzas from an input stream to an output stream.
</p>
<a name="streams-error"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9"></a><h3>4.9.&nbsp;
Stream Errors</h3>

<p>The root stream element MAY contain an &lt;error/&gt; child element that is qualified by the stream namespace.  The error child SHALL be sent by a compliant entity if it perceives that a stream-level error has occurred.
</p>
<a name="streams-error-rules"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.1"></a><h3>4.9.1.&nbsp;
Rules</h3>

<p>The following rules apply to stream-level errors.
</p>
<a name="streams-error-rules-unrecoverable"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.1.1"></a><h3>4.9.1.1.&nbsp;
Stream Errors Are Unrecoverable</h3>

<p>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 &lt;error/&gt; element with an appropriate child element specifying the error condition and then immediately close the stream as described under <a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a>.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message&gt;&lt;body&gt;No closing tag!&lt;/message&gt;

S: &lt;stream:error&gt;
     &lt;not-well-formed
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<p>The entity that receives the stream error then SHALL close the stream as explained under <a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a>.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-rules-setup"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.1.2"></a><h3>4.9.1.2.&nbsp;
Stream Errors Can Occur During Setup</h3>

<p>If the error is triggered by the initial stream header, the receiving entity MUST still send the opening &lt;stream&gt; tag, include the &lt;error/&gt; element as a child of the stream element, and send the closing &lt;/stream&gt; tag (preferably in the same TCP packet).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://wrong.namespace.example.org/'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;invalid-namespace
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-rules-host"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.1.3"></a><h3>4.9.1.3.&nbsp;
Stream Errors When the Host Is Unspecified or Unknown</h3>

<p>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 FQDN for the receiving entity or the empty string.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='unknown.host.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;host-unknown
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-rules-where"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.1.4"></a><h3>4.9.1.4.&nbsp;
Where Stream Errors Are Sent</h3>

<p>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:
</p>
<p>
            </p>
<ul class="text">
<li>Stream-level errors related to the initial stream are returned by the receiving entity on the response stream via the same TCP connection.
</li>
<li>Stanza errors triggered by outbound stanzas sent from the initiating entity over the initial stream via the same TCP connection are returned by the receiving entity on the response stream via the other ("return") TCP connection, since they are inbound stanzas from the perspective of the initiating entity.
</li>
</ul><p>
          
</p>
<a name="streams-error-syntax"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.2"></a><h3>4.9.2.&nbsp;
Syntax</h3>

<p>The syntax for stream errors is as follows, where XML data shown within the square brackets '[' and ']' is OPTIONAL.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;stream:error&gt;
  &lt;defined-condition xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
  [&lt;text xmlns='urn:ietf:params:xml:ns:xmpp-streams'
         xml:lang='langcode'&gt;
     OPTIONAL descriptive text
  &lt;/text&gt;]
  [OPTIONAL application-specific condition element]
&lt;/stream:error&gt;
</pre></div>
<p>The "defined-condition" MUST correspond to one of the stream error conditions defined under <a class='info' href='#streams-error-conditions'>Section&nbsp;4.9.3<span> (</span><span class='info'>Defined Stream Error Conditions</span><span>)</span></a>.  However, because additional error conditions might be defined in the future, if an entity receives a stream error condition that it does not understand then it MUST treat the unknown condition as equivalent to &lt;undefined-condition/&gt; (<a class='info' href='#streams-error-conditions-undefined-condition'>Section&nbsp;4.9.3.21<span> (</span><span class='info'>undefined-condition</span><span>)</span></a>).  If the designers of an XMPP protocol extension or the developers of an XMPP implementation need to communicate a stream error condition that is not defined in this specification, they can do so by defining an application-specific error condition element qualified by an application-specific namespace.
</p>
<p>The &lt;error/&gt; element:
</p>
<p></p>
<ul class="text">
<li>MUST contain a child element corresponding to one of the <a class='info' href='#streams-error-conditions'>defined stream error conditions<span> (</span><span class='info'>Defined Stream Error Conditions</span><span>)</span></a>; this element MUST be qualified by the 'urn:ietf:params:xml:ns:xmpp-streams' namespace.
</li>
<li>MAY contain a &lt;text/&gt; 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.
</li>
<li>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 <a class='info' href='#streams-error-app'>Section&nbsp;4.9.4<span> (</span><span class='info'>Application-Specific Conditions</span><span>)</span></a>).
</li>
</ul>

<p>The &lt;text/&gt; 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).
</p>
<a name="streams-error-conditions"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3"></a><h3>4.9.3.&nbsp;
Defined Stream Error Conditions</h3>

<p>The following stream-level error conditions are defined.
</p>
<a name="streams-error-conditions-bad-format"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.1"></a><h3>4.9.3.1.&nbsp;
bad-format</h3>

<p>The entity has sent XML that cannot be processed.
</p>
<p>(In the following example, the client sends an XMPP message that is not well-formed XML, which alternatively might trigger a &lt;not-well-formed/&gt; stream error (<a class='info' href='#streams-error-conditions-not-well-formed'>Section&nbsp;4.9.3.13<span> (</span><span class='info'>not-well-formed</span><span>)</span></a>).)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message&gt;
     &lt;body&gt;No closing tag!
   &lt;/message&gt;

S: &lt;stream:error&gt;
     &lt;bad-format
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<p>This error can be used instead of the more specific XML-related errors, such as &lt;bad-namespace-prefix/&gt;, &lt;invalid-xml/&gt;, &lt;not-well-formed/&gt;, &lt;restricted-xml/&gt;, and &lt;unsupported-encoding/&gt;.  However, the more specific errors are RECOMMENDED.
</p>
<a name="streams-error-conditions-bad-namespace-prefix"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.2"></a><h3>4.9.3.2.&nbsp;
bad-namespace-prefix</h3>

<p>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 <a class='info' href='#xml-ns'>Section&nbsp;11.2<span> (</span><span class='info'>XML Namespace Names and Prefixes</span><span>)</span></a>).
</p>
<p>(In the following example, the client specifies a namespace prefix of "foobar" for the XML stream namespace.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;foobar:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xmlns='jabber:client'
       xmlns:foobar='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;bad-namespace-prefix
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-conflict"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.3"></a><h3>4.9.3.3.&nbsp;
conflict</h3>

<p>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 or allows only one server-to-server stream for a given domain pair as a way of helping to ensure in-order processing as described under <a class='info' href='#rules-order'>Section&nbsp;10.1<span> (</span><span class='info'>In-Order Processing</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;conflict
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<p>If a client receives a &lt;conflict/&gt; stream error (<a class='info' href='#streams-error-conditions-conflict'>Section&nbsp;4.9.3.3<span> (</span><span class='info'>conflict</span><span>)</span></a>), during the resource binding aspect of its reconnection attempt it MUST NOT blindly request the resourcepart it used during the former session but instead MUST choose a different resourcepart; details are provided under <a class='info' href='#bind'>Section&nbsp;7<span> (</span><span class='info'>Resource Binding</span><span>)</span></a>.
</p>
<a name="streams-error-conditions-connection-timeout"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.4"></a><h3>4.9.3.4.&nbsp;
connection-timeout</h3>

<p>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 <a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a>, XMPP-level pings as defined in <a class='info' href='#XEP-0199'>[XEP&#8209;0199]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;XMPP Ping,&rdquo; June&nbsp;2009.</span><span>)</span></a>, and XMPP Stream Management as defined in <a class='info' href='#XEP-0198'>[XEP&#8209;0198]<span> (</span><span class='info'>Karneges, J., Hildebrand, J., Saint-Andre, P., Forno, F., Cridland, D., and M. Wild, &ldquo;Stream Management,&rdquo; February&nbsp;2011.</span><span>)</span></a>.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
P: &lt;stream:error&gt;
     &lt;connection-timeout
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Interoperability Note: RFC 3920 specified that the &lt;connection-timeout/&gt; stream error (<a class='info' href='#streams-error-conditions-connection-timeout'>Section&nbsp;4.9.3.4<span> (</span><span class='info'>connection-timeout</span><span>)</span></a>) 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.
</p>
</blockquote>

<a name="streams-error-conditions-host-gone"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.5"></a><h3>4.9.3.5.&nbsp;
host-gone</h3>

<p>The value of the 'to' attribute provided in the initial stream header corresponds to an FQDN that is no longer serviced by the receiving entity.
</p>
<p>(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><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
P: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='example.net'
       to='foo.im.example.com'
       version='1.0'
       xmlns='jabber:server'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='g4qSvGvBxJ+xeAd7QKezOQJFFlw='
       to='example.net'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:server'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;host-gone
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-host-unknown"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.6"></a><h3>4.9.3.6.&nbsp;
host-unknown</h3>

<p>The value of the 'to' attribute provided in the initial stream header does not correspond to an FQDN that is serviced by the receiving entity.
</p>
<p>(In the following example, the peer specifies a 'to' address of "example.org" when connecting to the "im.example.com" server, but the server knows nothing of that address.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
P: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='example.net'
       to='example.org'
       version='1.0'
       xmlns='jabber:server'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='g4qSvGvBxJ+xeAd7QKezOQJFFlw='
       to='example.net'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:server'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;host-unknown
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-improper-addressing"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.7"></a><h3>4.9.3.7.&nbsp;
improper-addressing</h3>

<p>A stanza sent between two servers lacks a 'to' or 'from' attribute, the 'from' or 'to' attribute has no value, or the value violates the rules for XMPP addresses <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<p>(In the following example, the peer sends a stanza without a 'to' address over a server-to-server stream.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
P: &lt;message from='juliet@im.example.com'&gt;
     &lt;body&gt;Wherefore art thou?&lt;/body&gt;
   &lt;/message&gt;

S: &lt;stream:error&gt;
     &lt;improper-addressing
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-internal-server-error"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.8"></a><h3>4.9.3.8.&nbsp;
internal-server-error</h3>

<p>The server has experienced a misconfiguration or other internal error that prevents it from servicing the stream.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;stream:error&gt;
     &lt;internal-server-error
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-invalid-from"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.9"></a><h3>4.9.3.9.&nbsp;
invalid-from</h3>

<p>The data provided in a 'from' attribute does not match an authorized JID or validated domain as negotiated (1) between two servers using SASL or Server Dialback, or (2) between a client and a server via SASL authentication and resource binding.
</p>
<p>(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><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
P: &lt;message from='romeo@example.org' to='juliet@im.example.com'&gt;
     &lt;body&gt;Neither, fair saint, if either thee dislike.&lt;/body&gt;
   &lt;/message&gt;

S: &lt;stream:error&gt;
     &lt;invalid-from
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-invalid-namespace"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.10"></a><h3>4.9.3.10.&nbsp;
invalid-namespace</h3>

<p>The stream namespace name is something other than "http://etherx.jabber.org/streams" (see <a class='info' href='#xml-ns'>Section&nbsp;11.2<span> (</span><span class='info'>XML Namespace Names and Prefixes</span><span>)</span></a>) or the content namespace declared as the default namespace is not supported (e.g., something other than "jabber:client" or "jabber:server").
</p>
<p>(In the following example, the client specifies a namespace of 'http://wrong.namespace.example.org/' for the stream.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xmlns='jabber:client'
       xmlns:stream='http://wrong.namespace.example.org/'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;invalid-namespace
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-invalid-xml"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.11"></a><h3>4.9.3.11.&nbsp;
invalid-xml</h3>

<p>The entity has sent invalid XML over the stream to a server that performs validation (see <a class='info' href='#xml-validation'>Section&nbsp;11.4<span> (</span><span class='info'>Validation</span><span>)</span></a>).
</p>
<p>(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><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
P: &lt;iq from='example.net'
       id='l3b1vs75'
       to='im.example.com'
       type='subscribe'&gt;
     &lt;ping xmlns='urn:xmpp:ping'/&gt;
   &lt;/iq&gt;

S: &lt;stream:error&gt;
     &lt;invalid-xml
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-not-authorized"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.12"></a><h3>4.9.3.12.&nbsp;
not-authorized</h3>

<p>The entity has attempted to send XML stanzas or other outbound data 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 data before sending the stream error.
</p>
<p>(In the following example, the client attempts to send XML stanzas before authenticating with the server.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

C: &lt;message to='romeo@example.net'&gt;
     &lt;body&gt;Wherefore art thou?&lt;/body&gt;
   &lt;/message&gt;

S: &lt;stream:error&gt;
     &lt;not-authorized
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-not-well-formed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.13"></a><h3>4.9.3.13.&nbsp;
not-well-formed</h3>

<p>The initiating entity has sent XML that violates the well-formedness rules of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a> or <a class='info' href='#XML-NAMES'>[XML&#8209;NAMES]<span> (</span><span class='info'>Thompson, H., Hollander, D., Layman, A., Bray, T., and R. Tobin, &ldquo;Namespaces in XML 1.0 (Third Edition),&rdquo; December&nbsp;2009.</span><span>)</span></a>.
</p>
<p>(In the following example, the client sends an XMPP message that is not namespace-well-formed.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message&gt;
     &lt;foo:body&gt;What is this foo?&lt;/foo:body&gt;
   &lt;/message&gt;

S: &lt;stream:error&gt;
     &lt;not-well-formed
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Interoperability Note: In RFC 3920, the name of this error condition was "xml-not-well-formed" instead of "not-well-formed".  The name was changed because the element name &lt;xml-not-well-formed/&gt; violates the constraint from Section 3 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a> that "names beginning with a match to (('X'|'x')('M'|'m')('L'|'l')) are reserved for standardization in this or future versions of this specification".
</p>
</blockquote>

<a name="streams-error-conditions-policy-violation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.14"></a><h3>4.9.3.14.&nbsp;
policy-violation</h3>

<p>The entity has violated some local service policy (e.g., a stanza exceeds a configured size limit); the server MAY choose to specify the policy in the &lt;text/&gt; element or in an application-specific condition element.
</p>
<p>(In the following example, the client sends an XMPP message that is too large according to the server's local service policy.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message to='juliet@im.example.com' id='foo'&gt;
     &lt;body&gt;[ ... the-emacs-manual ... ]&lt;/body&gt;
   &lt;/message&gt;

S: &lt;stream:error&gt;
     &lt;policy-violation
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
     &lt;stanza-too-big xmlns='urn:xmpp:errors'/&gt;
   &lt;/stream:error&gt;

S: &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-remote-connection-failed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.15"></a><h3>4.9.3.15.&nbsp;
remote-connection-failed</h3>

<p>The server is unable to properly connect to a remote entity that is needed for authentication or authorization (e.g., in certain scenarios related to Server Dialback <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>); this condition is not to be used when the cause of the error is within the administrative domain of the XMPP service provider, in which case the &lt;internal-server-error/&gt; condition is more appropriate.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;remote-connection-failed
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-reset"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.16"></a><h3>4.9.3.16.&nbsp;
reset</h3>

<p>The server is closing the stream because it has new (typically security-critical) features to offer, because the keys or certificates used to establish a secure context for the stream have expired or have been revoked during the life of the stream (<a class='info' href='#security-certificates-validation-streams'>Section&nbsp;13.7.2.3<span> (</span><span class='info'>Checking of Certificates in Long-Lived Streams</span><span>)</span></a>), because the TLS sequence number has wrapped (<a class='info' href='#tls-rules-renegotiation'>Section&nbsp;5.3.5<span> (</span><span class='info'>TLS Renegotiation</span><span>)</span></a>), etc.  The reset applies to the stream and to any security context established for that stream (e.g., via TLS and SASL), which means that encryption and authentication need to be negotiated again for the new stream (e.g., TLS session resumption cannot be used).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;stream:error&gt;
     &lt;reset
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-resource-constraint"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.17"></a><h3>4.9.3.17.&nbsp;
resource-constraint</h3>

<p>The server lacks the system resources necessary to service the stream.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;resource-constraint
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-restricted-xml"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.18"></a><h3>4.9.3.18.&nbsp;
restricted-xml</h3>

<p>The entity has attempted to send restricted XML features such as a comment, processing instruction, DTD subset, or XML entity reference (see <a class='info' href='#xml-restrictions'>Section&nbsp;11.1<span> (</span><span class='info'>XML Restrictions</span><span>)</span></a>).
</p>
<p>(In the following example, the client sends an XMPP message containing an XML comment.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message to='juliet@im.example.com'&gt;
     &lt;!--&lt;subject/&gt;--&gt;
     &lt;body&gt;This message has no subject.&lt;/body&gt;
   &lt;/message&gt;

S: &lt;stream:error&gt;
     &lt;restricted-xml
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-see-other-host"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.19"></a><h3>4.9.3.19.&nbsp;
see-other-host</h3>

<p>The server will not provide service to the initiating entity but is redirecting traffic to another host under the administrative control of the same service provider.  The XML character data of the &lt;see-other-host/&gt; element returned by the server MUST specify the alternate FQDN or IP address at which to connect, which MUST be a valid domainpart or a domainpart plus port number (separated by the ':' character in the form "domainpart:port").  If the domainpart is the same as the source domain, derived domain, or resolved IPv4 or IPv6 address to which the initiating entity originally connected (differing only by the port number), then the initiating entity SHOULD simply attempt to reconnect at that address.  (The format of an IPv6 address MUST follow <a class='info' href='#IPv6-ADDR'>[IPv6&#8209;ADDR]<span> (</span><span class='info'>Kawamura, S. and M. Kawashima, &ldquo;A Recommendation for IPv6 Address Text Representation,&rdquo; August&nbsp;2010.</span><span>)</span></a>, which includes the enclosing the IPv6 address in square brackets '[' and ']' as originally defined by <a class='info' href='#URI'>[URI]<span> (</span><span class='info'>Berners-Lee, T., Fielding, R., and L. Masinter, &ldquo;Uniform Resource Identifier (URI): Generic Syntax,&rdquo; January&nbsp;2005.</span><span>)</span></a>.)  Otherwise, the initiating entity MUST resolve the FQDN specified in the &lt;see-other-host/&gt; element as described under <a class='info' href='#tcp-resolution'>Section&nbsp;3.2<span> (</span><span class='info'>Resolution of Fully Qualified Domain Names</span><span>)</span></a>.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;see-other-host
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'&gt;
       [2001:41D0:1:A49b::1]:9222
     &lt;/see-other-host&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<p>When negotiating a stream with the host to which it has been redirected, the initiating entity MUST apply the same policies it would have applied to the original connection attempt (e.g., a policy requiring TLS), MUST specify the same 'to' address on the initial stream header, and MUST verify the identity of the new host using the same reference identifier(s) it would have used for the original connection attempt (in accordance with <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a>).  Even if the receiving entity returns a &lt;see-other-host/&gt; error before the confidentiality and integrity of the stream have been established (thus introducing the possibility of a denial-of-service attack), the fact that the initiating entity needs to verify the identity of the XMPP service based on the same reference identifiers implies that the initiating entity will not connect to a malicious entity.  To reduce the possibility of a denial-of-service attack, (a) the receiving entity SHOULD NOT close the stream with a &lt;see-other-host/&gt; stream error until after the confidentiality and integrity of the stream have been protected via TLS or an equivalent security layer (such as the SASL GSSAPI mechanism), and (b) the receiving entity MAY have a policy of following redirects only if it has authenticated the receiving entity.  In addition, the initiating entity SHOULD abort the connection attempt after a certain number of successive redirects (e.g., at least 2 but no more than 5).
</p>
<a name="streams-error-conditions-system-shutdown"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.20"></a><h3>4.9.3.20.&nbsp;
system-shutdown</h3>

<p>The server is being shut down and all active streams are being closed.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;stream:error&gt;
     &lt;system-shutdown
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-undefined-condition"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.21"></a><h3>4.9.3.21.&nbsp;
undefined-condition</h3>

<p>The error condition is not one of those defined by the other conditions in this list; this error condition SHOULD NOT be used except in conjunction with an application-specific condition.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;stream:error&gt;
     &lt;undefined-condition
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
     &lt;app-error xmlns='http://example.org/ns'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-unsupported-encoding"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.22"></a><h3>4.9.3.22.&nbsp;
unsupported-encoding</h3>

<p>The initiating entity has encoded the stream in an encoding that is not supported by the server (see <a class='info' href='#xml-encoding'>Section&nbsp;11.6<span> (</span><span class='info'>Character Encoding</span><span>)</span></a>) or has otherwise improperly encoded the stream (e.g., by violating the rules of the <a class='info' href='#UTF-8'>[UTF&#8209;8]<span> (</span><span class='info'>Yergeau, F., &ldquo;UTF-8, a transformation format of ISO 10646,&rdquo; November&nbsp;2003.</span><span>)</span></a> encoding).
</p>
<p>(In the following example, the client attempts to encode data using UTF-16 instead of UTF-8.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0' encoding='UTF-16'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;unsupported-encoding
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-unsupported-feature"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.23"></a><h3>4.9.3.23.&nbsp;
unsupported-feature</h3>

<p>The receiving entity has advertised a mandatory-to-negotiate stream feature that the initiating entity does not support, and has offered no other mandatory-to-negotiate feature alongside the unsupported feature.
</p>
<p>(In the following example, the receiving entity requires negotiation of an example feature, but the initiating entity does not support the feature.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:features&gt;
     &lt;example xmlns='urn:xmpp:example'&gt;
       &lt;required/&gt;
     &lt;/example&gt;
   &lt;/stream:features&gt;

I: &lt;stream:error&gt;
     &lt;unsupported-feature
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-unsupported-stanza-type"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.24"></a><h3>4.9.3.24.&nbsp;
unsupported-stanza-type</h3>

<p>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 the receiving entity does not understand the element name for the applicable namespace (which might be the content namespace declared as the default namespace).
</p>
<p>(In the following example, the client attempts to send a first-level child element of &lt;pubsub/&gt; qualified by the 'jabber:client' namespace, but the schema for that namespace defines no such element.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;pubsub xmlns='jabber:client'&gt;
     &lt;publish node='princely_musings'&gt;
       &lt;item id='ae890ac52d0df67ed7cfdf51b644e901'&gt;
         &lt;entry xmlns='http://www.w3.org/2005/Atom'&gt;
           &lt;title&gt;Soliloquy&lt;/title&gt;
           &lt;summary&gt;
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?
           &lt;/summary&gt;
           &lt;link rel='alternate' type='text/html'
                 href='http://denmark.example/2003/12/13/atom03'/&gt;
           &lt;id&gt;tag:denmark.example,2003:entry-32397&lt;/id&gt;
           &lt;published&gt;2003-12-13T18:30:02Z&lt;/published&gt;
           &lt;updated&gt;2003-12-13T18:30:02Z&lt;/updated&gt;
         &lt;/entry&gt;
       &lt;/item&gt;
     &lt;/publish&gt;
   &lt;/pubsub&gt;

S: &lt;stream:error&gt;
     &lt;unsupported-stanza-type
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-conditions-unsupported-version"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.3.25"></a><h3>4.9.3.25.&nbsp;
unsupported-version</h3>

<p>The 'version' attribute provided by the initiating entity in the stream header specifies a version of XMPP that is not supported by the server.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='11.0'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;
   &lt;stream:error&gt;
     &lt;unsupported-version
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-error-app"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.9.4"></a><h3>4.9.4.&nbsp;
Application-Specific Conditions</h3>

<p>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 &lt;error/&gt; element will contain two or three child elements.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message&gt;
     &lt;body&gt;
       My keyboard layout is:

       QWERTYUIOP{}|
       ASDFGHJKL:"
       ZXCVBNM&lt;&gt;?
     &lt;/body&gt;
   &lt;/message&gt;

S: &lt;stream:error&gt;
     &lt;not-well-formed
         xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
     &lt;text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'&gt;
       Some special application diagnostic information!
     &lt;/text&gt;
     &lt;escape-your-data xmlns='http://example.org/ns'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;
</pre></div>
<a name="streams-example"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.4.10"></a><h3>4.10.&nbsp;
Simplified Stream Examples</h3>

<p>This section contains two highly 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, but the reader needs to be aware that these examples elide many details (see <a class='info' href='#examples'>Section&nbsp;9<span> (</span><span class='info'>Detailed Examples</span><span>)</span></a> for more complete examples).
</p>
<p>A basic connection:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

[ ... stream negotiation ... ]

C:   &lt;message from='juliet@im.example.com/balcony'
              to='romeo@example.net'
              xml:lang='en'&gt;
       &lt;body&gt;Art thou not Romeo, and a Montague?&lt;/body&gt;
     &lt;/message&gt;

S:   &lt;message from='romeo@example.net/orchard'
              to='juliet@im.example.com/balcony'
              xml:lang='en'&gt;
       &lt;body&gt;Neither, fair saint, if either thee dislike.&lt;/body&gt;
     &lt;/message&gt;

C: &lt;/stream:stream&gt;

S: &lt;/stream:stream&gt;
</pre></div>
<p>A connection gone bad:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='juliet@im.example.com'
       to='im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;?xml version='1.0'?&gt;
   &lt;stream:stream
       from='im.example.com'
       id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

[ ... stream negotiation ... ]

C:   &lt;message from='juliet@im.example.com/balcony'
              to='romeo@example.net'
              xml:lang='en'&gt;
       &lt;body&gt;No closing tag!
     &lt;/message&gt;

S: &lt;stream:error&gt;
    &lt;not-well-formed
        xmlns='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
   &lt;/stream:error&gt;
   &lt;/stream:stream&gt;

</pre></div>
<p>More detailed examples are provided under <a class='info' href='#examples'>Section&nbsp;9<span> (</span><span class='info'>Detailed Examples</span><span>)</span></a>.
</p>
<a name="tls"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5"></a><h3>5.&nbsp;
STARTTLS Negotiation</h3>

<a name="tls-fundamentals"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.1"></a><h3>5.1.&nbsp;
Fundamentals</h3>

<p>XMPP includes a method for securing the stream from tampering and eavesdropping.  This channel encryption method makes use of the Transport Layer Security <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a> protocol, specifically a "STARTTLS" extension that is modeled after similar extensions for the <a class='info' href='#IMAP'>[IMAP]<span> (</span><span class='info'>Crispin, M., &ldquo;INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1,&rdquo; March&nbsp;2003.</span><span>)</span></a>, <a class='info' href='#POP3'>[POP3]<span> (</span><span class='info'>Myers, J. and M. Rose, &ldquo;Post Office Protocol - Version 3,&rdquo; May&nbsp;1996.</span><span>)</span></a>, and <a class='info' href='#ACAP'>[ACAP]<span> (</span><span class='info'>Newman, C. and J. Myers, &ldquo;ACAP -- Application Configuration Access Protocol,&rdquo; November&nbsp;1997.</span><span>)</span></a> protocols as described in <a class='info' href='#USINGTLS'>[USINGTLS]<span> (</span><span class='info'>Newman, C., &ldquo;Using TLS with IMAP, POP3 and ACAP,&rdquo; June&nbsp;1999.</span><span>)</span></a>.  The XML namespace name for the STARTTLS extension is 'urn:ietf:params:xml:ns:xmpp-tls'.
</p>
<a name="tls-support"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.2"></a><h3>5.2.&nbsp;
Support</h3>

<p>Support for STARTTLS is REQUIRED in XMPP client and server implementations.  An administrator of a given deployment MAY specify that TLS is mandatory-to-negotiate 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.
</p>
<a name="tls-rules"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.3"></a><h3>5.3.&nbsp;
Stream Negotiation Rules</h3>

<a name="tls-rules-mtn"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.3.1"></a><h3>5.3.1.&nbsp;
Mandatory-to-Negotiate</h3>

<p>If the receiving entity advertises only the STARTTLS feature or if the receiving entity includes the &lt;required/&gt; child element as explained under <a class='info' href='#tls-process-stream'>Section&nbsp;5.4.1<span> (</span><span class='info'>Exchange of Stream Headers and Stream Features</span><span>)</span></a>, 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).
</p>
<a name="tls-rules-restart"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.3.2"></a><h3>5.3.2.&nbsp;
Restart</h3>

<p>After TLS negotiation, the parties MUST restart the stream.
</p>
<a name="tls-rules-data"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.3.3"></a><h3>5.3.3.&nbsp;
Data Formatting</h3>

<p>During STARTTLS negotiation, the entities MUST NOT send any whitespace as separators between XML elements (i.e., from the last character of the first-level &lt;starttls/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' namespace as sent by the initiating entity, until the last character of the first-level &lt;proceed/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' namespace 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 readability.
</p>
<a name="tls-rules-order"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.3.4"></a><h3>5.3.4.&nbsp;
Order of TLS and SASL Negotiations</h3>

<p>If the initiating entity chooses to use TLS, STARTTLS negotiation MUST be completed before proceeding to <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>; 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.
</p>
<a name="tls-rules-renegotiation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.3.5"></a><h3>5.3.5.&nbsp;
TLS Renegotiation</h3>

<p>The TLS protocol allows either party in a TLS-protected channel to initiate a new handshake that establishes new cryptographic parameters (see <a class='info' href='#TLS-NEG'>[TLS&#8209;NEG]<span> (</span><span class='info'>Rescorla, E., Ray, M., Dispensa, S., and N. Oskov, &ldquo;Transport Layer Security (TLS) Renegotiation Indication Extension,&rdquo; February&nbsp;2010.</span><span>)</span></a>).  The cases most commonly mentioned are:
</p>
<p>
          </p>
<ol class="text">
<li>Refreshing encryption keys.
</li>
<li>Wrapping the TLS sequence number as explained in Section 6.1 of <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a>.
</li>
<li>Protecting client credentials by completing server authentication first and then completing client authentication over the protected channel.
</li>
</ol><p>
        
</p>
<p>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 <a class='info' href='#streams-error-conditions-reset'>Section&nbsp;4.9.3.16<span> (</span><span class='info'>reset</span><span>)</span></a>) instead of performing TLS renegotiation.
</p>
<p>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 TLS server might leak private information, it can be appropriate to complete TLS negotiation for the purpose of authenticating the TLS server to the TLS client and then attempt TLS renegotiation for the purpose of authenticating the TLS client to the TLS server.  However, this case is extremely rare because the credentials presented by an XMPP server or XMPP client acting as a TLS client are almost always public (i.e., a PKIX certificate), and therefore providing those credentials before authenticating the XMPP server acting as a TLS server would not in general leak private information.
</p>
<p>As a result, implementers are encouraged to carefully weigh the costs and benefits of TLS renegotiation before supporting it in their software, and XMPP entities that act as TLS clients are discouraged from attempting TLS renegotiation unless the certificate (or other credential information) sent during TLS negotiation is known to be private.
</p>
<p>Support for TLS renegotiation is strictly OPTIONAL.  However, implementations that support TLS renegotiation MUST implement and use the TLS Renegotiation Extension <a class='info' href='#TLS-NEG'>[TLS&#8209;NEG]<span> (</span><span class='info'>Rescorla, E., Ray, M., Dispensa, S., and N. Oskov, &ldquo;Transport Layer Security (TLS) Renegotiation Indication Extension,&rdquo; February&nbsp;2010.</span><span>)</span></a>.
</p>
<p>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, as described under <a class='info' href='#security-layers'>Section&nbsp;13.3<span> (</span><span class='info'>Order of Layers</span><span>)</span></a>).
</p>
<p>If an entity that supports TLS renegotiation detects a TLS renegotiation attempt that does not use the TLS Renegotiation Extension <a class='info' href='#TLS-NEG'>[TLS&#8209;NEG]<span> (</span><span class='info'>Rescorla, E., Ray, M., Dispensa, S., and N. Oskov, &ldquo;Transport Layer Security (TLS) Renegotiation Indication Extension,&rdquo; February&nbsp;2010.</span><span>)</span></a>, 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 as described under <a class='info' href='#security-layers'>Section&nbsp;13.3<span> (</span><span class='info'>Order of Layers</span><span>)</span></a>).
</p>
<a name="tls-rules-extensions"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.3.6"></a><h3>5.3.6.&nbsp;
TLS Extensions</h3>

<p>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.
</p>
<a name="tls-process"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.4"></a><h3>5.4.&nbsp;
Process</h3>

<a name="tls-process-stream"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.4.1"></a><h3>5.4.1.&nbsp;
Exchange of Stream Headers and Stream Features</h3>

<p>The initiating entity resolves the FQDN of the receiving entity as specified under <a class='info' href='#tcp'>Section&nbsp;3<span> (</span><span class='info'>TCP Binding</span><span>)</span></a>, opens a TCP connection to the advertised port at the resolved IP address, and sends an initial stream header to the receiving entity.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;stream:stream
     from='juliet@im.example.com'
     to='im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>The receiving entity MUST send a response stream header to the initiating entity over the TCP connection opened by the initiating entity.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:stream
     from='im.example.com'
     id='t7AMCin9zjMNwQKDnplntZPIDEI='
     to='juliet@im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>The receiving entity then MUST send stream features to the initiating entity.  If the receiving entity supports TLS, the stream features MUST include an advertisement for support of STARTTLS negotiation, i.e., a &lt;starttls/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' namespace.
</p>
<p>If the receiving entity considers STARTTLS negotiation to be mandatory-to-negotiate, the &lt;starttls/&gt; element MUST contain an empty &lt;required/&gt; child element.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:features&gt;
     &lt;starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'&gt;
       &lt;required/&gt;
     &lt;/starttls&gt;
   &lt;/stream:features&gt;
</pre></div>
<a name="tls-process-initiate"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.4.2"></a><h3>5.4.2.&nbsp;
Initiation of STARTTLS Negotiation</h3>

<a name="tls-process-initiate-command"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.4.2.1"></a><h3>5.4.2.1.&nbsp;
STARTTLS Command</h3>

<p>In order to begin the STARTTLS negotiation, the initiating entity issues the STARTTLS command (i.e., a &lt;starttls/&gt; 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.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/&gt;
</pre></div>
<p>The receiving entity MUST reply with either a &lt;proceed/&gt; element (proceed case) or a &lt;failure/&gt; element (failure case) qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' namespace.
</p>
<a name="tls-process-initiate-failure"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.4.2.2"></a><h3>5.4.2.2.&nbsp;
Failure Case</h3>

<p>If the failure case occurs, the receiving entity MUST return a &lt;failure/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' namespace, close the XML stream, and terminate the underlying TCP connection.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-tls'/&gt;

R: &lt;/stream:stream&gt;
</pre></div>
<p>Causes for the failure case include but are not limited to:
</p>
<p>
            </p>
<ol class="text">
<li>The initiating entity has sent a malformed STARTTLS command.
</li>
<li>The receiving entity did not offer the STARTTLS feature in its stream features.
</li>
<li>The receiving entity cannot complete STARTTLS negotiation because of an internal error.
</li>
</ol><p>
          
</p>
<p></p>
<blockquote class="text">
<p>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 <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a>.
</p>
</blockquote>

<p>If the failure case occurs, the initiating entity MAY attempt to reconnect as explained under <a class='info' href='#tcp-reconnect'>Section&nbsp;3.3<span> (</span><span class='info'>Reconnection</span><span>)</span></a>.
</p>
<a name="tls-process-initiate-proceed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.4.2.3"></a><h3>5.4.2.3.&nbsp;
Proceed Case</h3>

<p>If the proceed case occurs, the receiving entity MUST return a &lt;proceed/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-tls' namespace.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/&gt;
</pre></div>
<p>The receiving entity MUST consider the TLS negotiation to have begun immediately after sending the closing '&gt;' character of the &lt;proceed/&gt; element to the initiating entity.  The initiating entity MUST consider the TLS negotiation to have begun immediately after receiving the closing '&gt;' character of the &lt;proceed/&gt; element from the receiving entity.
</p>
<p>The entities now proceed to TLS negotiation as explained in the next section.
</p>
<a name="tls-process-neg"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.4.3"></a><h3>5.4.3.&nbsp;
TLS Negotiation</h3>

<a name="tls-process-neg-rules"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.4.3.1"></a><h3>5.4.3.1.&nbsp;
Rules</h3>

<p>In order to complete TLS negotiation over the TCP connection, the entities MUST follow the process defined in <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a>.
</p>
<p>The following rules apply:
</p>
<p>
            </p>
<ol class="text">
<li>The entities MUST NOT send any further XML data until the TLS negotiation is complete.
</li>
<li>When using any of the mandatory-to-implement (MTI) ciphersuites specified under <a class='info' href='#security-mti'>Section&nbsp;13.8<span> (</span><span class='info'>Mandatory-to-Implement TLS and SASL Technologies</span><span>)</span></a>, the receiving entity MUST present a certificate.
</li>
<li>So that mutual certificate authentication will be possible, the receiving entity SHOULD send a certificate request to the initiating entity, and the initiating entity SHOULD send a certificate to the receiving entity (but for privacy reasons might opt not to send a certificate until after the receiving entity has authenticated to the initiating entity).
</li>
<li>The receiving entity SHOULD choose which certificate to present based on the domainpart contained in the 'to' attribute of the initial stream header (in essence, this domainpart is functionally equivalent to the Server Name Indication defined for TLS in <a class='info' href='#TLS-EXT'>[TLS&#8209;EXT]<span> (</span><span class='info'>Eastlake 3rd, D., &ldquo;Transport Layer Security (TLS) Extensions: Extension Definitions,&rdquo; January&nbsp;2011.</span><span>)</span></a>).
</li>
<li>To determine if the TLS negotiation will succeed, the initiating entity MUST attempt to validate the receiving entity's certificate in accordance with the certificate validation procedures specified under <a class='info' href='#security-certificates-validation'>Section&nbsp;13.7.2<span> (</span><span class='info'>Certificate Validation</span><span>)</span></a>.
</li>
<li>If the initiating entity presents a certificate, the receiving entity too MUST attempt to validate the initiating entity's certificate in accordance with the certificate validation procedures specified under <a class='info' href='#security-certificates-validation'>Section&nbsp;13.7.2<span> (</span><span class='info'>Certificate Validation</span><span>)</span></a>.
</li>
<li>Following successful TLS negotiation, all further data transmitted by either party MUST be protected with the negotiated algorithms, keys, and secrets (i.e., encrypted, integrity-protected, or both depending on the ciphersuite used).
</li>
</ol><p>
          
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: See <a class='info' href='#security-mti'>Section&nbsp;13.8<span> (</span><span class='info'>Mandatory-to-Implement TLS and SASL Technologies</span><span>)</span></a> regarding ciphersuites that MUST be supported for TLS; naturally, other ciphersuites MAY be supported as well.
</p>
</blockquote>

<a name="tls-process-neg-failure"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.4.3.2"></a><h3>5.4.3.2.&nbsp;
TLS Failure</h3>

<p>If the TLS negotiation results in failure, the receiving entity MUST terminate the TCP connection.
</p>
<p>The receiving entity MUST NOT send a closing &lt;/stream&gt; tag before terminating the TCP connection (since the failure has occurred at the TLS layer, not the XMPP layer as described under <a class='info' href='#security-layers'>Section&nbsp;13.3<span> (</span><span class='info'>Order of Layers</span><span>)</span></a>).
</p>
<p>The initiating entity MAY attempt to reconnect as explained under <a class='info' href='#tcp-reconnect'>Section&nbsp;3.3<span> (</span><span class='info'>Reconnection</span><span>)</span></a>, with or without attempting TLS negotiation (in accordance with local service policy, user-configured preferences, etc.).
</p>
<a name="tls-process-neg-success"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.5.4.3.3"></a><h3>5.4.3.3.&nbsp;
TLS Success</h3>

<p>If the TLS negotiation is successful, then the entities MUST proceed as follows.
</p>
<p>
            </p>
<ol class="text">
<li>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).
</li>
<li>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).
</li>
<li>The initiating entity MUST send a new initial stream header to the receiving entity over the encrypted connection (as specified under <a class='info' href='#streams-negotiation-restart'>Section&nbsp;4.3.3<span> (</span><span class='info'>Restarts</span><span>)</span></a>, the initiating entity MUST NOT send a closing &lt;/stream&gt; 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).
                <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;stream:stream
     from='juliet@im.example.com'
     to='im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
              
</li>
<li>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 reusing the old stream ID).
                <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:stream
     from='im.example.com'
     id='vgKi/bkYME8OAj4rlXMkpucAqe4='
     to='juliet@im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
              
</li>
<li>The receiving entity also MUST send stream features to the initiating entity, which MUST NOT include the STARTTLS feature but which SHOULD include the SASL stream feature as described under <a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a> (see especially <a class='info' href='#sasl-process-stream'>Section&nbsp;6.4.1<span> (</span><span class='info'>Exchange of Stream Headers and Stream Features</span><span>)</span></a> regarding the few reasons why the SASL stream feature would not be offered here).
                <div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:features&gt;
     &lt;mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
       &lt;mechanism&gt;EXTERNAL&lt;/mechanism&gt;
       &lt;mechanism&gt;SCRAM-SHA-1-PLUS&lt;/mechanism&gt;
       &lt;mechanism&gt;SCRAM-SHA-1&lt;/mechanism&gt;
       &lt;mechanism&gt;PLAIN&lt;/mechanism&gt;
     &lt;/mechanisms&gt;
   &lt;/stream:features&gt;
</pre></div>
              
</li>
</ol><p>
          
</p>
<a name="sasl"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6"></a><h3>6.&nbsp;
SASL Negotiation</h3>

<a name="sasl-fundamentals"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.1"></a><h3>6.1.&nbsp;
Fundamentals</h3>

<p>XMPP includes a method for authenticating a stream by means of an XMPP-specific profile of the Simple Authentication and Security Layer protocol (see <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a>).  SASL provides a generalized method for adding authentication support to connection-based protocols, and XMPP uses an XML namespace profile of SASL that conforms to the profiling requirements of <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a>.  The XML namespace name for the SASL extension is 'urn:ietf:params:xml:ns:xmpp-sasl'.
</p>
<a name="sasl-support"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.2"></a><h3>6.2.&nbsp;
Support</h3>

<p>Support for SASL negotiation is REQUIRED in XMPP client and server implementations.
</p>
<a name="sasl-rules"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3"></a><h3>6.3.&nbsp;
Stream Negotiation Rules</h3>

<a name="sasl-rules-mtn"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3.1"></a><h3>6.3.1.&nbsp;
Mandatory-to-Negotiate</h3>

<p>The parties to a stream MUST consider SASL as mandatory-to-negotiate.
</p>
<a name="sasl-rules-restart"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3.2"></a><h3>6.3.2.&nbsp;
Restart</h3>

<p>After SASL negotiation, the parties MUST restart the stream.
</p>
<a name="sasl-rules-preferences"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3.3"></a><h3>6.3.3.&nbsp;
Mechanism Preferences</h3>

<p>Any entity that will act as a SASL client or a SASL server MUST
maintain an ordered list of its preferred SASL mechanisms according to the
client or server, where the list is ordered according to local policy or user
configuration (which SHOULD be in order of perceived strength to enable the
strongest authentication possible).  The initiating entity MUST maintain its
own preference order independent of the preference order of the receiving
entity.  A client MUST try SASL mechanisms in its preference order.  For example, if the server offers the ordered list "PLAIN SCRAM-SHA-1 GSSAPI" or "SCRAM-SHA-1 GSSAPI PLAIN" but the client's ordered list is "GSSAPI SCRAM-SHA-1", the client MUST try GSSAPI first and then SCRAM-SHA-1 but MUST NOT try PLAIN (since PLAIN is not on its list).
</p>
<a name="sasl-rules-offers"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3.4"></a><h3>6.3.4.&nbsp;
Mechanism Offers</h3>

<p>If the receiving entity considers <a class='info' href='#tls'>TLS negotiation<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a> to be mandatory-to-negotiate before it will accept authentication with a particular SASL mechanism, it MUST NOT advertise that mechanism in its list of available SASL mechanisms before TLS negotiation has been completed.
</p>
<p>The receiving entity SHOULD offer the SASL EXTERNAL mechanism if both of the following conditions hold:
</p>
<p>
          </p>
<ol class="text">
<li>During TLS negotiation the initiating entity presented a certificate that is acceptable to the receiving entity for purposes of strong identity verification in accordance with local service policies (e.g., because said certificate is unexpired, is unrevoked, and is anchored to a root trusted by the receiving entity).
</li>
<li>The receiving entity expects that the initiating entity will be able to authenticate and authorize as the identity provided in the certificate; in the case of a server-to-server stream, the receiving entity might have such an expectation because a DNS domain name presented in the initiating entity's certificate matches the domain referenced in the 'from' attribute of the initial stream header, where the matching rules of <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a> apply; in the case of a client-to-server stream, the receiving entity might have such an expectation because the bare JID presented in the initiating entity's certificate matches a user account that is registered with the server or because other information contained in the initiating entity's certificate matches that of an entity that has permission to use the server for access to an XMPP network.
</li>
</ol><p>
        
</p>
<p>However, the receiving entity MAY offer the SASL EXTERNAL mechanism under other circumstances, as well.
</p>
<p>When the receiving entity offers the SASL EXTERNAL mechanism, the receiving entity SHOULD list the EXTERNAL mechanism first among its offered SASL mechanisms and the initiating entity SHOULD attempt SASL negotiation using the EXTERNAL mechanism first (this preference will tend to increase the likelihood that the parties can negotiate mutual certificate authentication).
</p>
<p><a class='info' href='#security-mti'>Section&nbsp;13.8<span> (</span><span class='info'>Mandatory-to-Implement TLS and SASL Technologies</span><span>)</span></a> specifies SASL mechanisms that MUST be supported; naturally, other SASL mechanisms MAY be supported as well.
</p>
<p></p>
<blockquote class="text">
<p>Informational Note: Best practices for the use of SASL in the context of XMPP are described in <a class='info' href='#XEP-0175'>[XEP&#8209;0175]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Best Practices for Use of SASL ANONYMOUS,&rdquo; September&nbsp;2009.</span><span>)</span></a> for the ANONYMOUS mechanism and in <a class='info' href='#XEP-0178'>[XEP&#8209;0178]<span> (</span><span class='info'>Saint-Andre, P. and P. Millard, &ldquo;Best Practices for Use of SASL EXTERNAL with Certificates,&rdquo; February&nbsp;2007.</span><span>)</span></a> for the EXTERNAL mechanism.
</p>
</blockquote>

<a name="sasl-rules-data"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3.5"></a><h3>6.3.5.&nbsp;
Data Formatting</h3>

<p>The following data formatting rules apply to the SASL negotiation:
</p>
<p>
          </p>
<ol class="text">
<li>During SASL negotiation, the entities MUST NOT send any whitespace as separators between XML elements (i.e., from the last character of the first-level &lt;auth/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace as sent by the initiating entity, until the last character of the first-level &lt;success/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace as sent by the receiving entity).  This prohibition helps to ensure proper security layer byte precision.  Any such whitespace shown in the SASL examples provided in this document is included only for the sake of readability.
</li>
<li>Any XML character data contained within the XML elements MUST be encoded using base 64, where the encoding adheres to the definition in Section 4 of <a class='info' href='#BASE64'>[BASE64]<span> (</span><span class='info'>Josefsson, S., &ldquo;The Base16, Base32, and Base64 Data Encodings,&rdquo; October&nbsp;2006.</span><span>)</span></a> and where the padding bits are set to zero.
</li>
<li>As formally specified in the XML schema for the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace under <a class='info' href='#schemas-sasl'>Appendix&nbsp;A.4<span> (</span><span class='info'>SASL Namespace</span><span>)</span></a>, the receiving entity MAY include one or more application-specific child elements inside the &lt;mechanisms/&gt; element to provide information that might be needed by the initiating entity in order to complete successful SASL negotiation using one or more of the offered mechanisms; however, the syntax and semantics of all such elements are out of scope for this specification (see <a class='info' href='#XEP-0233'>[XEP&#8209;0233]<span> (</span><span class='info'>Miller, M., Saint-Andre, P., and J. Hildebrand, &ldquo;Domain-Based Service Names in XMPP SASL Negotiation,&rdquo; June&nbsp;2010.</span><span>)</span></a> for one example).
</li>
</ol><p>
        
</p>
<a name="sasl-rules-layers"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3.6"></a><h3>6.3.6.&nbsp;
Security Layers</h3>

<p>Upon successful SASL negotiation that involves negotiation
        of a security layer, both the initiating entity and the
        receiving entity MUST discard any application-layer state (i.e, state from the XMPP layer, excluding state from the TLS negotiation or SASL negotiation).
</p>
<a name="sasl-rules-username"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3.7"></a><h3>6.3.7.&nbsp;
Simple User Name</h3>

<p>Some SASL mechanisms (e.g., CRAM-MD5, DIGEST-MD5, and SCRAM) specify that the authentication identity used in the context of such mechanisms is a "simple user name" (see Section 2 of <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a> as well as <a class='info' href='#SASLPREP'>[SASLPREP]<span> (</span><span class='info'>Zeilenga, K., &ldquo;SASLprep: Stringprep Profile for User Names and Passwords,&rdquo; February&nbsp;2005.</span><span>)</span></a>).  The exact form of the simple user name in any particular mechanism or deployment thereof is a local matter, and a simple user name does not necessarily map to an application identifier such as a JID or JID component (e.g., a localpart).  However, in the absence of local information provided by the server, an XMPP client SHOULD assume that the authentication identity for such a SASL mechanism is a simple user name equal to the localpart of the user's JID.
</p>
<a name="sasl-rules-authzid"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3.8"></a><h3>6.3.8.&nbsp;
Authorization Identity</h3>

<p>An authorization identity is an OPTIONAL identity included by the initiating entity to specify an identity to act as (see Section 2 of <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a>).  In client-to-server streams, it would most likely be used by an administrator to perform some management task on behalf of another user, whereas in server-to-server streams it would most likely be used to specify a particular add-on service at an XMPP service (e.g., a multi-user chat server at conference.example.com that is hosted by the example.com XMPP service).  If the initiating entity wishes to act on behalf of another entity and the selected SASL mechanism supports transmission of an authorization identity, the initiating entity MUST provide an authorization identity during SASL negotiation.  If the initiating entity does not wish to act on behalf of another entity, it MUST NOT provide an authorization identity.
</p>
<p>In the case of client-to-server communication, the value of an authorization identity MUST be a bare JID (&lt;localpart@domainpart&gt;) rather than a full JID (&lt;localpart@domainpart/resourcepart&gt;).
</p>
<p>In the case of server-to-server communication, the value of an authorization identity MUST be a domainpart only (&lt;domainpart&gt;).
</p>
<p>If the initiating entity provides an authorization identity during SASL negotiation, the receiving entity is responsible for verifying that the initiating entity is in fact allowed to assume the specified authorization identity; if not, the receiving entity MUST return an &lt;invalid-authzid/&gt; SASL error as described under <a class='info' href='#sasl-errors-invalid-authzid'>Section&nbsp;6.5.6<span> (</span><span class='info'>invalid-authzid</span><span>)</span></a>.
</p>
<a name="sasl-rules-realms"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3.9"></a><h3>6.3.9.&nbsp;
Realms</h3>

<p>The receiving entity MAY include a realm when negotiating certain SASL mechanisms (e.g., both the GSSAPI and DIGEST-MD5 mechanisms allow the authentication exchange to include a realm, though in different ways, whereas the EXTERNAL, SCRAM, and PLAIN mechanisms do not).  If the receiving entity does not communicate a realm, the initiating entity MUST NOT assume that any realm exists.  The realm MUST be used only for the purpose of authentication; in particular, an initiating entity MUST NOT attempt to derive an XMPP domainpart from the realm information provided by the receiving entity.
</p>
<a name="sasl-rules-roundtrips"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.3.10"></a><h3>6.3.10.&nbsp;
Round Trips</h3>

<p><a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a> specifies that a using protocol such as XMPP can define two methods by which the protocol can save round trips where allowed for the SASL mechanism:
</p>
<p>
          </p>
<ol class="text">
<li>When the SASL client (the XMPP "initiating entity") requests an authentication exchange, it can include "initial response" data with its request if appropriate for the SASL mechanism in use.  In XMPP, this is done by including the initial response as the XML character data of the &lt;auth/&gt; element.
</li>
<li>At the end of the authentication exchange, the SASL server (the XMPP "receiving entity") can include "additional data with success" if appropriate for the SASL mechanism in use.  In XMPP, this is done by including the additional data as the XML character data of the &lt;success/&gt; element.
</li>
</ol><p>
        
</p>
<p>For the sake of protocol efficiency, it is REQUIRED for clients and servers to support these methods and RECOMMENDED to use them; however, clients and servers MUST support the less efficient modes as well.
</p>
<a name="sasl-process"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.4"></a><h3>6.4.&nbsp;
Process</h3>

<p>The process for SASL negotiation is as follows.
</p>
<a name="sasl-process-stream"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.4.1"></a><h3>6.4.1.&nbsp;
Exchange of Stream Headers and Stream Features</h3>

<p>If SASL negotiation follows successful <a class='info' href='#tls'>STARTTLS negotiation<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a>, then the SASL negotiation occurs over the protected stream that has already been negotiated.  If not, the initiating entity resolves the FQDN of the receiving entity as specified under <a class='info' href='#tcp'>Section&nbsp;3<span> (</span><span class='info'>TCP Binding</span><span>)</span></a>, opens a TCP connection to the advertised port at the resolved IP address, and sends an initial stream header to the receiving entity.  In either case, the receiving entity will receive an initial stream from the initiating entity.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;stream:stream
     from='juliet@im.example.com'
     to='im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>When the receiving entity processes an initial stream header from the initiating entity, it MUST send a response stream header to the initiating entity (for which it MUST generate a unique stream ID. If TLS negotiation has already succeeded, then this stream ID MUST be different from the stream ID sent before TLS negotiation succeeded).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:stream
     from='im.example.com'
     id='vgKi/bkYME8OAj4rlXMkpucAqe4='
     to='juliet@im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>The receiving entity also MUST send stream features to the initiating entity.  The stream features SHOULD include an advertisement for support of SASL negotiation, i.e., a &lt;mechanisms/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace.  Typically there are only three cases in which support for SASL negotiation would not be advertised here:
</p>
<p>
          </p>
<ul class="text">
<li>TLS negotiation needs to happen before SASL can be offered (i.e., TLS is required and the receiving entity is responding to the very first initial stream header it has received for this connection attempt).
</li>
<li>SASL negotiation is impossible for a server-to-server connection (i.e., the initiating server has not provided a certificate that would enable strong authentication and therefore the receiving server is falling back to weak identity verification using the Server Dialback protocol <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>).
</li>
<li>SASL has already been negotiated (i.e., the receiving entity is responding to an initial stream header sent as a stream restart after successful SASL negotiation).
</li>
</ul><p>
        
</p>
<p>The &lt;mechanisms/&gt; element MUST contain one &lt;mechanism/&gt; child element for each authentication mechanism the receiving entity offers to the initiating entity.  As noted, the order of &lt;mechanism/&gt; elements in the XML indicates the preference order of the SASL mechanisms according to the receiving entity (which is not necessarily the preference order according to the initiating entity).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:features&gt;
     &lt;mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
       &lt;mechanism&gt;EXTERNAL&lt;/mechanism&gt;
       &lt;mechanism&gt;SCRAM-SHA-1-PLUS&lt;/mechanism&gt;
       &lt;mechanism&gt;SCRAM-SHA-1&lt;/mechanism&gt;
       &lt;mechanism&gt;PLAIN&lt;/mechanism&gt;
     &lt;/mechanisms&gt;
   &lt;/stream:features&gt;
</pre></div>
<a name="sasl-process-neg-initiate"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.4.2"></a><h3>6.4.2.&nbsp;
Initiation</h3>

<p>In order to begin the SASL negotiation, the initiating entity sends an &lt;auth/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace and includes an appropriate value for the 'mechanism' attribute, thus starting the handshake for that particular authentication mechanism.  This element MAY contain XML character data (in SASL terminology, the "initial response") if the mechanism supports or requires it. If the initiating entity needs to send a zero-length initial response, it MUST transmit the response as a single equals sign character ("="), which indicates that the response is present but contains no data.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
         mechanism='PLAIN'&gt;AGp1bGlldAByMG0zMG15cjBtMzA=&lt;/auth&gt;
</pre></div>
<p>If the initiating entity subsequently sends another &lt;auth/&gt; element and the ongoing authentication handshake has not yet completed, the receiving entity MUST discard the ongoing handshake and MUST process a new handshake for the subsequently requested SASL mechanism.
</p>
<a name="sasl-process-neg-challengeresponse"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.4.3"></a><h3>6.4.3.&nbsp;
Challenge-Response Sequence</h3>

<p>If necessary, the receiving entity challenges the initiating entity by sending a &lt;challenge/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY contain XML character data (which MUST be generated in accordance with the definition of the SASL mechanism chosen by the initiating entity).
</p>
<p>The initiating entity responds to the challenge by sending a &lt;response/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY contain XML character data (which MUST be generated in accordance with the definition of the SASL mechanism chosen by the initiating entity).
</p>
<p>If necessary, the receiving entity sends more challenges and the initiating entity sends more responses.
</p>
<p>This series of challenge/response pairs continues until one of three things happens:
</p>
<p>
          </p>
<ul class="text">
<li>The initiating entity aborts the handshake for this authentication mechanism.
</li>
<li>The receiving entity reports failure of the handshake.
</li>
<li>The receiving entity reports success of the handshake.
</li>
</ul><p>
        
</p>
<p>These scenarios are described in the following sections.
</p>
<a name="sasl-process-neg-abort"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.4.4"></a><h3>6.4.4.&nbsp;
Abort</h3>

<p>The initiating entity aborts the handshake for this authentication mechanism by sending an &lt;abort/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;abort xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/&gt;
</pre></div>
<p>Upon receiving an &lt;abort/&gt; element, the receiving entity MUST return a &lt;failure/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace and containing an &lt;aborted/&gt; child element.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;aborted/&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-process-neg-failure"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.4.5"></a><h3>6.4.5.&nbsp;
SASL Failure</h3>

<p>The receiving entity reports failure of the handshake for this authentication mechanism by sending a &lt;failure/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace (the particular cause of failure MUST be communicated in an appropriate child element of the &lt;failure/&gt; element as defined under <a class='info' href='#sasl-errors'>Section&nbsp;6.5<span> (</span><span class='info'>SASL Errors</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;not-authorized/&gt;
   &lt;/failure&gt;
</pre></div>
<p>Where appropriate for the chosen SASL mechanism, the
        receiving entity SHOULD allow a configurable but reasonable
        number of retries (at least 2 and no more than 5); this
        enables the initiating entity (e.g., an end-user client) to
        tolerate incorrectly provided credentials (e.g., a mistyped password) without being forced to reconnect (which it would if the receiving entity immediately returned a SASL failure and closed the stream).
</p>
<p>If the initiating entity attempts a reasonable number of retries with the same SASL mechanism and all attempts fail, it MAY fall back to the next mechanism in its ordered list by sending a new &lt;auth/&gt; request to the receiving entity, thus starting a new handshake for that authentication mechanism.  If all handshakes fail and there are no remaining mechanisms in the initiating entity's list of supported and acceptable mechanisms, the initiating entity SHOULD simply close the stream as described under <a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a> (instead of waiting for the stream to time out).
</p>
<p>If the initiating entity exceeds the number of retries, the receiving entity MUST close the stream with a stream error, which SHOULD be &lt;policy-violation/&gt; (<a class='info' href='#streams-error-conditions-policy-violation'>Section&nbsp;4.9.3.14<span> (</span><span class='info'>policy-violation</span><span>)</span></a>), although some existing implementations send &lt;not-authorized/&gt; (<a class='info' href='#streams-error-conditions-not-authorized'>Section&nbsp;4.9.3.12<span> (</span><span class='info'>not-authorized</span><span>)</span></a>) instead.
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: For server-to-server streams, if the receiving entity cannot offer the SASL EXTERNAL mechanism or any other SASL mechanism based on the security context established during TLS negotiation, the receiving entity MAY attempt to complete weak identity verification using the Server Dialback protocol <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>; however, if according to local service policies weak identity verification is insufficient then the receiving entity SHOULD instead close the stream with a &lt;policy-violation/&gt; stream error (<a class='info' href='#streams-error-conditions-policy-violation'>Section&nbsp;4.9.3.14<span> (</span><span class='info'>policy-violation</span><span>)</span></a>) instead of waiting for the stream to time out.
</p>
</blockquote>

<a name="sasl-process-neg-success"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.4.6"></a><h3>6.4.6.&nbsp;
SASL Success</h3>

<p>Before considering the SASL handshake to be a success, if the initiating entity provided a 'from' attribute on an initial stream header whose confidentiality and integrity were protected via TLS or an equivalent security layer (such as the SASL GSSAPI mechanism) then the receiving entity SHOULD correlate the authentication identity resulting from the SASL negotiation with that 'from' address; if the two identities do not match then the receiving entity SHOULD terminate the connection attempt (however, the receiving entity might have legitimate reasons not to terminate the connection attempt, for example, because it has overridden a connecting client's address to correct the JID format or assign a JID based on information presented in an end-user certificate).
</p>
<p>The receiving entity reports success of the handshake by sending a &lt;success/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace; this element MAY contain XML character data (in SASL terminology, "additional data with success") if the chosen SASL mechanism supports or requires it. If the receiving entity needs to send additional data of zero length, it MUST transmit the data as a single equals sign character ("=").
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Informational Note: For client-to-server streams, the authorization identity communicated during SASL negotiation is used to determine the canonical address for the initiating client according to the receiving server, as described under <a class='info' href='#streams-negotiation-address'>Section&nbsp;4.3.6<span> (</span><span class='info'>Determination of Addresses</span><span>)</span></a>.
</p>
</blockquote>

<p>Upon receiving the &lt;success/&gt; element, the initiating entity MUST initiate a new stream over the existing TCP connection by sending a new initial stream header to the receiving entity (as specified under <a class='info' href='#streams-negotiation-restart'>Section&nbsp;4.3.3<span> (</span><span class='info'>Restarts</span><span>)</span></a>, the initiating entity MUST NOT send a closing &lt;/stream&gt; 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 SASL negotiation).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;stream:stream
     from='juliet@im.example.com'
     to='im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>Upon receiving the new initial stream header from the initiating entity, the receiving entity MUST respond by sending a new response stream header to the initiating entity (for which it MUST generate a new stream ID instead of reusing the old stream ID).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:stream
     from='im.example.com'
     id='gPybzaOzBmaADgxKXu9UClbprp0='
     to='juliet@im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>The receiving entity MUST also send stream features, containing any further available features or containing no features (via an empty &lt;features/&gt; element).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
R: &lt;stream:features&gt;
     &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/&gt;
   &lt;/stream:features&gt;
</pre></div>
<a name="sasl-errors"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5"></a><h3>6.5.&nbsp;
SASL Errors</h3>

<p>The syntax of SASL errors is as follows, where the XML data shown within the square brackets '[' and ']' is OPTIONAL.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
  &lt;defined-condition/&gt;
  [&lt;text xml:lang='langcode'&gt;
      OPTIONAL descriptive text
  &lt;/text&gt;]
&lt;/failure&gt;
</pre></div>
<p>The "defined-condition" MUST be one of the SASL-related error conditions defined in the following sections.  However, because additional error conditions might be defined in the future, if an entity receives a SASL error condition that it does not understand then it MUST treat the unknown condition as a generic authentication failure, i.e., as equivalent to &lt;not-authorized/&gt; (<a class='info' href='#sasl-errors-not-authorized'>Section&nbsp;6.5.10<span> (</span><span class='info'>not-authorized</span><span>)</span></a>).
</p>
<p>Inclusion of the &lt;text/&gt; element is OPTIONAL, and can be used to provide application-specific information about the error condition, which information MAY be displayed to a human but only as a supplement to the defined condition.
</p>
<p>Because XMPP itself defines an application profile of SASL and there is no expectation that more specialized XMPP applications will be built on top of SASL, the SASL error format does not provide extensibility for application-specific error conditions as is done for XML streams (<a class='info' href='#streams-error-app'>Section&nbsp;4.9.4<span> (</span><span class='info'>Application-Specific Conditions</span><span>)</span></a>) and XML stanzas (<a class='info' href='#stanzas-error-app'>Section&nbsp;8.3.4<span> (</span><span class='info'>Application-Specific Conditions</span><span>)</span></a>).
</p>
<a name="sasl-errors-aborted"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.1"></a><h3>6.5.1.&nbsp;
aborted</h3>

<p>The receiving entity acknowledges that the authentication handshake has been aborted by the initiating entity; sent in reply to the &lt;abort/&gt; element.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;abort xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;aborted/&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-errors-account-disabled"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.2"></a><h3>6.5.2.&nbsp;
account-disabled</h3>

<p>The account of the initiating entity has been temporarily disabled; sent in reply to an &lt;auth/&gt; element (with or without initial response data) or a &lt;response/&gt; element.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
         mechanism='PLAIN'&gt;AGp1bGlldAByMG0zMG15cjBtMzA=&lt;/auth&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;account-disabled/&gt;
     &lt;text xml:lang='en'&gt;Call 212-555-1212 for assistance.&lt;/text&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-errors-credentials-expired"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.3"></a><h3>6.5.3.&nbsp;
credentials-expired</h3>

<p>The authentication failed because the initiating entity provided credentials that have expired; sent in reply to a &lt;response/&gt; element or an &lt;auth/&gt; element with initial response data.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     [ ... ]
   &lt;/response&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;credentials-expired/&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-errors-encryption-required"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.4"></a><h3>6.5.4.&nbsp;
encryption-required</h3>

<p>The mechanism requested by the initiating entity cannot be used unless the confidentiality and integrity of the underlying stream are protected (typically via TLS); sent in reply to an &lt;auth/&gt; element (with or without initial response data).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
         mechanism='PLAIN'&gt;AGp1bGlldAByMG0zMG15cjBtMzA=&lt;/auth&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;encryption-required/&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-errors-incorrect-encoding"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.5"></a><h3>6.5.5.&nbsp;
incorrect-encoding</h3>

<p>The data provided by the initiating entity could not be processed because the base 64 encoding is incorrect (e.g., because the encoding does not adhere to the definition in Section 4 of <a class='info' href='#BASE64'>[BASE64]<span> (</span><span class='info'>Josefsson, S., &ldquo;The Base16, Base32, and Base64 Data Encodings,&rdquo; October&nbsp;2006.</span><span>)</span></a>); sent in reply to a &lt;response/&gt; element or an &lt;auth/&gt; element with initial response data.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
         mechanism='DIGEST-MD5'&gt;[ ... ]&lt;/auth&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;incorrect-encoding/&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-errors-invalid-authzid"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.6"></a><h3>6.5.6.&nbsp;
invalid-authzid</h3>

<p>The authzid provided by the initiating entity is invalid, either because it is incorrectly formatted or because the initiating entity does not have permissions to authorize that ID; sent in reply to a &lt;response/&gt; element or an &lt;auth/&gt; element with initial response data.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     [ ... ]
   &lt;/response&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;invalid-authzid/&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-errors-invalid-mechanism"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.7"></a><h3>6.5.7.&nbsp;
invalid-mechanism</h3>

<p>The initiating entity did not specify a mechanism, or requested a mechanism that is not supported by the receiving entity; sent in reply to an &lt;auth/&gt; element.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
         mechanism='CRAM-MD5'/&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;invalid-mechanism/&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-errors-malformed-request"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.8"></a><h3>6.5.8.&nbsp;
malformed-request</h3>

<p>The request is malformed (e.g., the &lt;auth/&gt; element includes initial response data but the mechanism does not allow that, or the data sent violates the syntax for the specified SASL mechanism); sent in reply to an &lt;abort/&gt;, &lt;auth/&gt;, &lt;challenge/&gt;, or &lt;response/&gt; element.
</p>
<p>(In the following example, the XML character data of the &lt;auth/&gt; element contains more than 255 UTF-8-encoded Unicode characters and therefore violates the "token" production for the SASL ANONYMOUS mechanism as specified in <a class='info' href='#ANONYMOUS'>[ANONYMOUS]<span> (</span><span class='info'>Zeilenga, K., &ldquo;Anonymous Simple Authentication and Security Layer (SASL) Mechanism,&rdquo; June&nbsp;2006.</span><span>)</span></a>.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
         mechanism='ANONYMOUS'&gt;[ ... some-long-token ... ]&lt;/auth&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;malformed-request/&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-errors-mechanism-too-weak"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.9"></a><h3>6.5.9.&nbsp;
mechanism-too-weak</h3>

<p>The mechanism requested by the initiating entity is weaker than server policy permits for that initiating entity; sent in reply to an &lt;auth/&gt; element (with or without initial response data).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
         mechanism='PLAIN'&gt;AGp1bGlldAByMG0zMG15cjBtMzA=&lt;/auth&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;mechanism-too-weak/&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-errors-not-authorized"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.10"></a><h3>6.5.10.&nbsp;
not-authorized</h3>

<p>The authentication failed because the initiating entity did not provide proper credentials, or because some generic authentication failure has occurred but the receiving entity does not wish to disclose specific information about the cause of the failure; sent in reply to a &lt;response/&gt; element or an &lt;auth/&gt; element with initial response data.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     [ ... ]
   &lt;/response&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;not-authorized/&gt;
   &lt;/failure&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Security Warning: This error condition includes but is not limited to the case of incorrect credentials or a nonexistent username.  In order to discourage directory harvest attacks, no differentiation is made between incorrect credentials and a nonexistent username.
</p>
</blockquote>

<a name="sasl-errors-temporary-auth-failure"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.5.11"></a><h3>6.5.11.&nbsp;
temporary-auth-failure</h3>

<p>The authentication failed because of a temporary error condition within the receiving entity, and it is advisable for the initiating entity to try again later; sent in reply to an &lt;auth/&gt; element or a &lt;response/&gt; element.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
I: &lt;response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     [ ... ]
   &lt;/response&gt;

R: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;temporary-auth-failure/&gt;
   &lt;/failure&gt;
</pre></div>
<a name="sasl-def"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.6.6"></a><h3>6.6.&nbsp;
SASL Definition</h3>

<p>The profiling requirements of <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a> require that the
following information be supplied by the definition of a using protocol.
</p>
<p></p>
<blockquote class="text"><dl>
<dt>service name:</dt>
<dd>"xmpp"
</dd>
<dt>initiation sequence:</dt>
<dd>After the initiating entity provides
an opening XML stream header and the receiving entity replies in kind, the
receiving entity provides a list of acceptable authentication methods.  The
initiating entity chooses one method from the list and sends it to the
receiving entity as the value of the 'mechanism' attribute possessed by an
&lt;auth/&gt; element, optionally including an initial response to avoid a
round trip.
</dd>
<dt>exchange sequence:</dt>
<dd>Challenges and responses are carried
through the exchange of &lt;challenge/&gt; elements from receiving entity to
initiating entity and &lt;response/&gt; elements from initiating entity to
receiving entity.  The receiving entity reports failure by sending a
&lt;failure/&gt; element and success by sending a &lt;success/&gt; element; the
initiating entity aborts the exchange by sending an &lt;abort/&gt; element.
Upon successful negotiation, both sides consider the original XML stream to be
closed and new stream headers are sent by both entities.
</dd>
<dt>security layer negotiation:</dt>
<dd>The security layer takes
effect immediately after sending the closing '&gt;' character of the
&lt;success/&gt; element for the receiving entity, and immediately after
receiving the closing '&gt;' character of the &lt;success/&gt; element for the
initiating entity.  The order of layers is first <a class='info' href='#TCP'>[TCP]<span> (</span><span class='info'>Postel, J., &ldquo;Transmission Control Protocol,&rdquo; September&nbsp;1981.</span><span>)</span></a>, then
<a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a>, then <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a>, then XMPP.
</dd>
<dt>use of the authorization identity:</dt>
<dd>The authorization
identity can be used in XMPP to denote the non-default
&lt;localpart@domainpart&gt; of a client; an empty string is equivalent to an
absent authorization identity.
</dd>
</dl></blockquote>

<a name="bind"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7"></a><h3>7.&nbsp;
Resource Binding</h3>

<a name="bind-fundamentals"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.1"></a><h3>7.1.&nbsp;
Fundamentals</h3>

<p>After a client authenticates with a server, it MUST bind a specific resource to the stream so that the server can properly address the client.  That is, there MUST be an XMPP resource associated with the bare JID (&lt;localpart@domainpart&gt;) of the client, so that the address for use over that stream is a full JID of the form &lt;localpart@domainpart/resource&gt; (including the resourcepart).  This ensures that the server can deliver XML stanzas to and receive XML stanzas from the client in relation to entities other than the server itself or the client's account, as explained under <a class='info' href='#rules'>Section&nbsp;10<span> (</span><span class='info'>Server Rules for Processing XML Stanzas</span><span>)</span></a>.
</p>
<p></p>
<blockquote class="text">
<p>Informational Note: The client could exchange stanzas with the server itself or the client's account before binding a resource since the full JID is needed only for addressing outside the context of the stream negotiated between the client and the server, but this is not commonly done.
</p>
</blockquote>

<p>After a client has bound a resource to the stream, it is referred to as a "connected resource".  A server SHOULD allow an entity to maintain multiple connected resources simultaneously, where each connected resource is associated with a distinct XML stream and is differentiated from the other connected resources by a distinct resourcepart.
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: A server SHOULD enable the administrator of an XMPP service to limit the number of connected resources in order to prevent certain denial-of-service attacks as described under <a class='info' href='#security-dos'>Section&nbsp;13.12<span> (</span><span class='info'>Denial of Service</span><span>)</span></a>.
</p>
</blockquote>

<p>If, before completing the resource binding step, the client attempts to send an XML stanza to an entity other than the server itself or the client's account, the server MUST NOT process the stanza and MUST close the stream with a &lt;not-authorized/&gt; stream error (<a class='info' href='#streams-error-conditions-not-authorized'>Section&nbsp;4.9.3.12<span> (</span><span class='info'>not-authorized</span><span>)</span></a>).
</p>
<p>The XML namespace name for the resource binding extension is 'urn:ietf:params:xml:ns:xmpp-bind'.
</p>
<a name="bind-support"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.2"></a><h3>7.2.&nbsp;
Support</h3>

<p>Support for resource binding is REQUIRED in XMPP client and server implementations.
</p>
<a name="bind-rules"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.3"></a><h3>7.3.&nbsp;
Stream Negotiation Rules</h3>

<a name="bind-rules-mtn"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.3.1"></a><h3>7.3.1.&nbsp;
Mandatory-to-Negotiate</h3>

<p>The parties to a stream MUST consider resource binding as mandatory-to-negotiate.
</p>
<a name="bind-rules-restart"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.3.2"></a><h3>7.3.2.&nbsp;
Restart</h3>

<p>After resource binding, the parties MUST NOT restart the stream.
</p>
<a name="bind-feature"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.4"></a><h3>7.4.&nbsp;
Advertising Support</h3>

<p>Upon sending a new response stream header to the client after successful SASL negotiation, the server MUST include a &lt;bind/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-bind' namespace in the stream features it presents to the client.
</p>
<p>The server MUST NOT include the resource binding stream feature until after the client has authenticated, typically by means of successful SASL negotiation.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;stream:stream
       from='im.example.com'
       id='gPybzaOzBmaADgxKXu9UClbprp0='
       to='juliet@im.example.com'
       version='1.0'
       xml:lang='en'
       xmlns='jabber:client'
       xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;stream:features&gt;
     &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/&gt;
   &lt;/stream:features&gt;
</pre></div>
<p>Upon being informed that resource binding is mandatory-to-negotiate, the client MUST bind a resource to the stream as described in the following sections.
</p>
<a name="bind-generation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.5"></a><h3>7.5.&nbsp;
Generation of Resource Identifiers</h3>

<p>A resourcepart MUST at a minimum be unique among the connected resources for that &lt;localpart@domainpart&gt;.  Enforcement of this policy is the responsibility of the server.
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: A resourcepart can be security-critical.  For example, if a malicious entity can guess a client's resourcepart then it might be able to determine if the client (and therefore the controlling principal) is online or offline, thus resulting in a presence leak as described under <a class='info' href='#security-leaks-presence'>Section&nbsp;13.10.2<span> (</span><span class='info'>Presence Information</span><span>)</span></a>.  To prevent that possibility, a client can either (1) generate a random resourcepart on its own or (2) ask the server to generate a resourcepart on its behalf.  One method for ensuring that the resourcepart is random is to generate a Universally Unique Identifier (UUID) as specified in <a class='info' href='#UUID'>[UUID]<span> (</span><span class='info'>Leach, P., Mealling, M., and R. Salz, &ldquo;A Universally Unique IDentifier (UUID) URN Namespace,&rdquo; July&nbsp;2005.</span><span>)</span></a>.
</p>
</blockquote>

<a name="bind-servergen"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.6"></a><h3>7.6.&nbsp;
Server-Generated Resource Identifier</h3>

<p>A server MUST be able to generate an XMPP resourcepart on behalf of a client.  The resourcepart generated by the server MUST be random (see <a class='info' href='#RANDOM'>[RANDOM]<span> (</span><span class='info'>Eastlake, D., Schiller, J., and S. Crocker, &ldquo;Randomness Requirements for Security,&rdquo; June&nbsp;2005.</span><span>)</span></a>).
</p>
<a name="bind-servergen-success"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.6.1"></a><h3>7.6.1.&nbsp;
Success Case</h3>

<p>A client requests a server-generated resourcepart by sending an IQ stanza of type "set" (see <a class='info' href='#stanzas-semantics-iq'>Section&nbsp;8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>) containing an empty &lt;bind/&gt; element qualified by the 'urn:ietf:params:xml:ns:xmpp-bind' namespace.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq id='tn281v37' type='set'&gt;
    &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/&gt;
   &lt;/iq&gt;
</pre></div>
<p>Once the server has generated an XMPP resourcepart for the client, it MUST return an IQ stanza of type "result" to the client, which MUST include a &lt;jid/&gt; child element that specifies the full JID for the connected resource as determined by the server.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='tn281v37' type='result'&gt;
    &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'&gt;
      &lt;jid&gt;
        juliet@im.example.com/4db06f06-1ea4-11dc-aca3-000bcd821bfb
      &lt;/jid&gt;
    &lt;/bind&gt;
   &lt;/iq&gt;
</pre></div>
<a name="bind-servergen-error"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.6.2"></a><h3>7.6.2.&nbsp;
Error Cases</h3>

<p>When a client asks the server to generate a resourcepart during resource binding, the following stanza error conditions are defined:
</p>
<p>
          </p>
<ul class="text">
<li>The account has reached a limit on the number of simultaneous connected resources allowed.
</li>
<li>The client is otherwise not allowed to bind a resource to the stream.
</li>
</ul><p>
        
</p>
<p>Naturally, it is possible that error conditions not specified here might occur, as described under <a class='info' href='#stanzas-error'>Section&nbsp;8.3<span> (</span><span class='info'>Stanza Errors</span><span>)</span></a>.
</p>
<a name="bind-servergen-error-resourceconstraint"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.6.2.1"></a><h3>7.6.2.1.&nbsp;
Resource Constraint</h3>

<p>If the account has reached a limit on the number of simultaneous connected resources allowed, the server MUST return a &lt;resource-constraint/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-resource-constraint'>Section&nbsp;8.3.3.18<span> (</span><span class='info'>resource-constraint</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='tn281v37' type='error'&gt;
     &lt;error type='wait'&gt;
       &lt;resource-constraint
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<a name="bind-servergen-error-notallowed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.6.2.2"></a><h3>7.6.2.2.&nbsp;
Not Allowed</h3>

<p>If the client is otherwise not allowed to bind a resource to the stream, the server MUST return a &lt;not-allowed/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-not-allowed'>Section&nbsp;8.3.3.10<span> (</span><span class='info'>not-allowed</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='tn281v37' type='error'&gt;
     &lt;error type='cancel'&gt;
       &lt;not-allowed
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<a name="bind-clientsubmit"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.7"></a><h3>7.7.&nbsp;
Client-Submitted Resource Identifier</h3>

<p>Instead of asking the server to generate a resourcepart on its behalf, a client MAY attempt to submit a resourcepart that it has generated or that the controlling user has provided.
</p>
<a name="bind-clientsubmit-success"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.7.1"></a><h3>7.7.1.&nbsp;
Success Case</h3>

<p>A client asks its server to accept a client-submitted resourcepart by sending an IQ stanza of type "set" containing a &lt;bind/&gt; element with a child &lt;resource/&gt; element containing non-zero-length XML character data.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq id='wy2xa82b4' type='set'&gt;
     &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'&gt;
       &lt;resource&gt;balcony&lt;/resource&gt;
     &lt;/bind&gt;
   &lt;/iq&gt;
</pre></div>
<p>The server SHOULD accept the client-submitted resourcepart.  It does so by returning an IQ stanza of type "result" to the client, including a &lt;jid/&gt; child element that specifies the full JID for the connected resource and contains without modification the client-submitted text.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='wy2xa82b4' type='result'&gt;
    &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'&gt;
      &lt;jid&gt;juliet@im.example.com/balcony&lt;/jid&gt;
    &lt;/bind&gt;
   &lt;/iq&gt;
</pre></div>
<p>Alternatively, in accordance with local service policies the server MAY refuse the client-submitted resourcepart and override it with a resourcepart that the server generates.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='wy2xa82b4' type='result'&gt;
    &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'&gt;
      &lt;jid&gt;
   juliet@im.example.com/balcony 4db06f06-1ea4-11dc-aca3-000bcd821bfb
      &lt;/jid&gt;
    &lt;/bind&gt;
   &lt;/iq&gt;
</pre></div>
<a name="bind-clientsubmit-error"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.7.2"></a><h3>7.7.2.&nbsp;
Error Cases</h3>

<p>When a client attempts to submit its own XMPP resourcepart during resource binding, the following stanza error conditions are defined in addition to those described under <a class='info' href='#bind-servergen-error'>Section&nbsp;7.6.2<span> (</span><span class='info'>Error Cases</span><span>)</span></a>:
</p>
<p>
          </p>
<ul class="text">
<li>The provided resourcepart cannot be processed by the server.
</li>
<li>The provided resourcepart is already in use.
</li>
</ul><p>
        
</p>
<p>Naturally, it is possible that error conditions not specified here might occur, as described under <a class='info' href='#stanzas-error'>Section&nbsp;8.3<span> (</span><span class='info'>Stanza Errors</span><span>)</span></a>.
</p>
<a name="bind-clientsubmit-error-badrequest"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.7.2.1"></a><h3>7.7.2.1.&nbsp;
Bad Request</h3>

<p>If the provided resourcepart cannot be processed by the server (e.g., because it is of zero length or because it otherwise violates the rules for resourceparts specified in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>), the server can return a &lt;bad-request/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-bad-request'>Section&nbsp;8.3.3.1<span> (</span><span class='info'>bad-request</span><span>)</span></a>) but SHOULD instead process the resourcepart so that it is in conformance.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='wy2xa82b4' type='error'&gt;
     &lt;error type='modify'&gt;
       &lt;bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<a name="bind-clientsubmit-error-conflict"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.7.2.2"></a><h3>7.7.2.2.&nbsp;
Conflict</h3>

<p>If there is a currently connected client whose session
          has the resourcepart being requested by the newly connecting client, the server MUST do one of the following (which of these the server does is a matter for implementation or local service policy, although suggestions are provided below).
</p>
<p>
            </p>
<ol class="text">
<li>Override the resourcepart provided by the newly connecting client with a server-generated resourcepart.
              
              This behavior is encouraged, because it simplifies the resource binding process for client implementations.
</li>
<li>Disallow the resource binding attempt of the newly
              connecting client and maintain the session of the
              currently connected client.
              
              This behavior is neither encouraged nor discouraged, despite the fact that it was implicitly encouraged in RFC 3920; however, note that handling of the &lt;conflict/&gt; error is unevenly supported among existing client implementations, which often treat it as an authentication error and have been observed to discard cached credentials when receiving it.
</li>
<li>Terminate the session of the currently connected
              client and allow the resource binding attempt of the
              newly connecting client.
              
              Although this was the traditional behavior of early XMPP
              server implementations, it is now discouraged because it
              can lead to a never-ending cycle of two clients
              effectively disconnecting each other; however, note that
              this behavior can be appropriate in some deployment
              scenarios or if the server knows that the currently connected client has a dead connection or broken stream as described under <a class='info' href='#streams-silence'>Section&nbsp;4.6<span> (</span><span class='info'>Handling of Silent Peers</span><span>)</span></a>.
</li>
</ol><p>
          
</p>
<p>If the server follows behavior #1, it returns an
          &lt;iq/&gt; stanza of type "result" to the newly connecting client, where the &lt;jid/&gt; child of the &lt;bind/&gt; element contains XML character data that indicates the full JID of the client, including the resourcepart that was generated by the server.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='wy2xa82b4' type='result'&gt;
    &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'&gt;
      &lt;jid&gt;
   juliet@im.example.com/balcony 4db06f06-1ea4-11dc-aca3-000bcd821bfb
      &lt;/jid&gt;
    &lt;/bind&gt;
   &lt;/iq&gt;
</pre></div>
<p>If the server follows behavior #2, it sends a &lt;conflict/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-conflict'>Section&nbsp;8.3.3.2<span> (</span><span class='info'>conflict</span><span>)</span></a>) in response to the resource binding attempt of the newly connecting client but maintains the XML stream so that the newly connecting client has an opportunity to negotiate a non-conflicting resourcepart (i.e., the newly connecting client needs to choose a different resourcepart before making another attempt to bind a resource).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='wy2xa82b4' type='error'&gt;
     &lt;error type='modify'&gt;
       &lt;conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<p>If the server follows behavior #3, it returns a &lt;conflict/&gt; stream error (<a class='info' href='#streams-error-conditions-conflict'>Section&nbsp;4.9.3.3<span> (</span><span class='info'>conflict</span><span>)</span></a>) to the currently connected client (as described under <a class='info' href='#streams-error-conditions-conflict'>Section&nbsp;4.9.3.3<span> (</span><span class='info'>conflict</span><span>)</span></a>) and returns an IQ stanza of type "result" (indicating success) in response to the resource binding attempt of the newly connecting client.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='wy2xa82b4' type='result'&gt;
     &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'&gt;
       &lt;jid&gt;
         juliet@im.example.com/balcony
       &lt;/jid&gt;
     &lt;/bind&gt;
   &lt;/iq&gt;
</pre></div>
<a name="bind-clientsubmit-retries"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.7.7.3"></a><h3>7.7.3.&nbsp;
Retries</h3>

<p>If an error occurs when a client submits a resourcepart, the server SHOULD allow a configurable but reasonable number of retries (at least 5 and no more than 10); this enables the client to tolerate incorrectly provided resourceparts (e.g., bad data formats or duplicate text strings) without being forced to reconnect.
</p>
<p>After the client has reached the retry limit, the server MUST close the stream with a &lt;policy-violation/&gt; stream error (<a class='info' href='#streams-error-conditions-policy-violation'>Section&nbsp;4.9.3.14<span> (</span><span class='info'>policy-violation</span><span>)</span></a>).
</p>
<a name="stanzas"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8"></a><h3>8.&nbsp;
XML Stanzas</h3>

<p>After a client and a server (or two servers) have completed stream negotiation, either party can send XML stanzas.  Three kinds of XML stanza are defined for the 'jabber:client' and 'jabber:server' namespaces: &lt;message/&gt;, &lt;presence/&gt;, and &lt;iq/&gt;.  In addition, there are five common attributes for these stanza types.  These common attributes, as well as the basic semantics of the three stanza types, are defined in this specification; more detailed information regarding the syntax of XML stanzas for instant messaging and presence applications is provided in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>, and for other applications in the relevant XMPP extension specifications.
</p>
<p>Support for the XML stanza syntax and semantics defined in this specification is REQUIRED in XMPP client and server implementations.
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: A server MUST NOT process a partial stanza and MUST NOT attach meaning to the transmission timing of any part of a stanza (before receipt of the closing tag).
</p>
</blockquote>

<a name="stanzas-attributes"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1"></a><h3>8.1.&nbsp;
Common Attributes</h3>

<p>The following five attributes are common to message, presence, and IQ stanzas.
</p>
<a name="stanzas-attributes-to"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1.1"></a><h3>8.1.1.&nbsp;
to</h3>

<p>The 'to' attribute specifies the JID of the intended recipient for the stanza.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message to='romeo@example.net'&gt;
  &lt;body&gt;Art thou not Romeo, and a Montague?&lt;/body&gt;
&lt;/message&gt;
</pre></div>
<p>For information about server processing of inbound and outbound XML stanzas based on the 'to' address, refer to <a class='info' href='#rules'>Section&nbsp;10<span> (</span><span class='info'>Server Rules for Processing XML Stanzas</span><span>)</span></a>.
</p>
<a name="stanzas-attributes-to-c2s"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1.1.1"></a><h3>8.1.1.1.&nbsp;
Client-to-Server Streams</h3>

<p>The following rules apply to inclusion of the 'to' attribute in stanzas sent from a connected client to its server over an XML stream qualified by the 'jabber:client' namespace.
</p>
<p>
            </p>
<ol class="text">
<li>A stanza with a specific intended recipient (e.g., a conversation partner, a remote service, the server itself, even another resource associated with the user's bare JID) MUST possess a 'to' attribute whose value is an XMPP address.
</li>
<li>A stanza sent from a client to a server for direct processing by the server (e.g., roster processing as described in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a> or presence sent to the server for broadcasting to other entities) MUST NOT possess a 'to' attribute.
</li>
</ol><p>
          
</p>
<p>The following rules apply to inclusion of the 'to' attribute in stanzas sent from a server to a connected client over an XML stream qualified by the 'jabber:client' namespace.
</p>
<p>
            </p>
<ol class="text">
<li>If the server has received the stanza from another connected client or from a peer server, the server MUST NOT modify the 'to' address before delivering the stanza to the client.
</li>
<li>If the server has itself generated the stanza (e.g., a response to an IQ stanza of type "get" or "set", even if the stanza did not include a 'to' address), the stanza MAY include a 'to' address, which MUST be the full JID of the client; however, if the stanza does not include a 'to' address then the client MUST treat it as if the 'to' address were included with a value of the client's full JID.
</li>
</ol><p>
          
</p>
<p></p>
<blockquote class="text">
<p>Implementation Note: It is the server's responsibility to deliver only stanzas that are addressed to the client's full JID or the user's bare JID; thus, there is no need for the client to check the 'to' address of incoming stanzas.  However, if the client does check the 'to' address then it is suggested to check at most the bare JID portion (not the full JID), since the 'to' address might be the user's bare JID, the client's current full JID, or even a full JID with a different resourcepart (e.g., in the case of so-called "offline messages" as described in <a class='info' href='#XEP-0160'>[XEP&#8209;0160]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Best Practices for Handling Offline Messages,&rdquo; January&nbsp;2006.</span><span>)</span></a>).
</p>
</blockquote>

<a name="stanzas-attributes-to-s2s"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1.1.2"></a><h3>8.1.1.2.&nbsp;
Server-to-Server Streams</h3>

<p>The following rules apply to inclusion of the 'to' attribute in the context of XML streams qualified by the 'jabber:server' namespace (i.e., server-to-server streams).
</p>
<p>
            </p>
<ol class="text">
<li>A stanza MUST possess a 'to' attribute whose value is an XMPP address; if a server receives a stanza that does not meet this restriction, it MUST close the stream with an &lt;improper-addressing/&gt; stream error (<a class='info' href='#streams-error-conditions-improper-addressing'>Section&nbsp;4.9.3.7<span> (</span><span class='info'>improper-addressing</span><span>)</span></a>).
</li>
<li>The domainpart of the JID contained in the stanza's 'to' attribute MUST match the FQDN of the receiving server (or any validated domain thereof) as communicated via SASL negotiation (see <a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>), Server Dialback (see <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>), or similar means; if a server receives a stanza that does not meet this restriction, it MUST close the stream with a &lt;host-unknown/&gt; stream error (<a class='info' href='#streams-error-conditions-host-unknown'>Section&nbsp;4.9.3.6<span> (</span><span class='info'>host-unknown</span><span>)</span></a>) or a &lt;host-gone/&gt; stream error (<a class='info' href='#streams-error-conditions-host-gone'>Section&nbsp;4.9.3.5<span> (</span><span class='info'>host-gone</span><span>)</span></a>).
</li>
</ol><p>
          
</p>
<a name="stanzas-attributes-from"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1.2"></a><h3>8.1.2.&nbsp;
from</h3>

<p>The 'from' attribute specifies the JID of the sender.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message from='juliet@im.example.com/balcony'
         to='romeo@example.net'&gt;
  &lt;body&gt;Art thou not Romeo, and a Montague?&lt;/body&gt;
&lt;/message&gt;
</pre></div>
<a name="stanzas-attributes-from-c2s"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1.2.1"></a><h3>8.1.2.1.&nbsp;
Client-to-Server Streams</h3>

<p>The following rules apply to the 'from' attribute in the context of XML streams qualified by the 'jabber:client' namespace (i.e., client-to-server streams).
</p>
<p>
            </p>
<ol class="text">
<li>When a server receives an XML stanza from a connected client, the server MUST add a 'from' attribute to the stanza or override the 'from' attribute specified by the client, where the value of the 'from' attribute MUST be the full JID (&lt;localpart@domainpart/resource&gt;) determined by the server for the connected resource that generated the stanza (see <a class='info' href='#streams-negotiation-address'>Section&nbsp;4.3.6<span> (</span><span class='info'>Determination of Addresses</span><span>)</span></a>), or the bare JID (&lt;localpart@domainpart&gt;) in the case of subscription-related presence stanzas (see <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</li>
<li>When the server generates a stanza on its own behalf for delivery to the client from the server itself, the stanza MUST include a 'from' attribute whose value is the bare JID (i.e., &lt;domainpart&gt;) of the server as agreed upon during stream negotiation (e.g., based on the 'to' attribute of the initial stream header).
</li>
<li>When the server generates a stanza from the server for delivery to the client on behalf of the account of the connected client (e.g., in the context of data storage services provided by the server on behalf of the client), the stanza MUST either (a) not include a 'from' attribute or (b) include a 'from' attribute whose value is the account's bare JID (&lt;localpart@domainpart&gt;).
</li>
<li>A server MUST NOT send to the client a stanza without a 'from' attribute if the stanza was not generated by the server on its own behalf (e.g., if it was generated by another client or a peer server and the server is merely delivering it to the client on behalf of some other entity); therefore, when a client receives a stanza that does not include a 'from' attribute, it MUST assume that the stanza is from the user's account on the server.
</li>
</ol><p>
          
</p>
<a name="stanzas-attributes-from-s2s"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1.2.2"></a><h3>8.1.2.2.&nbsp;
Server-to-Server Streams</h3>

<p>The following rules apply to the 'from' attribute in the context of XML streams qualified by the 'jabber:server' namespace (i.e., server-to-server streams).
</p>
<p>
            </p>
<ol class="text">
<li>A stanza MUST possess a 'from' attribute whose value is an XMPP address; if a server receives a stanza that does not meet this restriction, it MUST close the stream with an &lt;improper-addressing/&gt; stream error (<a class='info' href='#streams-error-conditions-improper-addressing'>Section&nbsp;4.9.3.7<span> (</span><span class='info'>improper-addressing</span><span>)</span></a>).
</li>
<li>The domainpart of the JID contained in the stanza's 'from' attribute MUST match the FQDN of the sending server (or any validated domain thereof) as communicated via SASL negotiation (see <a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>), Server Dialback (see <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>), or similar means; if a server receives a stanza that does not meet this restriction, it MUST close the stream with an &lt;invalid-from/&gt; stream error (<a class='info' href='#streams-error-conditions-invalid-from'>Section&nbsp;4.9.3.9<span> (</span><span class='info'>invalid-from</span><span>)</span></a>).
</li>
</ol><p>
          
</p>
<p>Enforcement of these rules helps to prevent certain denial-of-service attacks as described under <a class='info' href='#security-dos'>Section&nbsp;13.12<span> (</span><span class='info'>Denial of Service</span><span>)</span></a>.
</p>
<a name="stanzas-attributes-id"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1.3"></a><h3>8.1.3.&nbsp;
id</h3>

<p>The 'id' attribute is used by the originating entity to track any response or error stanza that it might receive in relation to the generated stanza from another entity (such as an intermediate server or the intended recipient).
</p>
<p>It is up to the originating entity whether the value of the 'id' attribute is unique only within its current stream or unique globally.
</p>
<p>For &lt;message/&gt; and &lt;presence/&gt; stanzas, it is RECOMMENDED for the originating entity to include an 'id' attribute; for &lt;iq/&gt; stanzas, it is REQUIRED.
</p>
<p>If the generated stanza includes an 'id' attribute then it is REQUIRED for the response or error stanza to also include an 'id' attribute, where the value of the 'id' attribute MUST match that of the generated stanza.
</p>
<p>The semantics of IQ stanzas impose additional restrictions as described under <a class='info' href='#stanzas-semantics-iq'>Section&nbsp;8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>.
</p>
<a name="stanzas-attributes-type"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1.4"></a><h3>8.1.4.&nbsp;
type</h3>

<p>The 'type' attribute specifies the purpose or context of the message, presence, or IQ stanza.  The particular allowable values for the 'type' attribute vary depending on whether the stanza is a message, presence, or IQ stanza.  The defined values for message and presence stanzas are specific to instant messaging and presence applications and therefore are defined in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>, whereas the values for IQ stanzas specify the part of the semantics for all structured request-response exchanges (no matter what the payload) and therefore are specified under <a class='info' href='#stanzas-semantics-iq'>Section&nbsp;8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>.  The only 'type' value common to all three kinds of stanzas is "error" as described under <a class='info' href='#stanzas-error'>Section&nbsp;8.3<span> (</span><span class='info'>Stanza Errors</span><span>)</span></a>.
</p>
<a name="stanzas-attributes-lang"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.1.5"></a><h3>8.1.5.&nbsp;
xml:lang</h3>

<p>A stanza SHOULD possess an 'xml:lang' attribute (as defined in Section 2.12 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>) if the stanza contains XML character data that is intended to be presented to a human user (as explained in <a class='info' href='#CHARSETS'>[CHARSETS]<span> (</span><span class='info'>Alvestrand, H., &ldquo;IETF Policy on Character Sets and Languages,&rdquo; January&nbsp;1998.</span><span>)</span></a>, "internationalization is for humans").  The value of the 'xml:lang' attribute specifies the default language of any such human-readable XML character data.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;presence from='romeo@example.net/orchard' xml:lang='en'&gt;
  &lt;show&gt;dnd&lt;/show&gt;
  &lt;status&gt;Wooing Juliet&lt;/status&gt;
&lt;/presence&gt;
</pre></div>
<p>The value of the 'xml:lang' attribute MAY be overridden by the 'xml:lang' attribute of a specific child element.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;presence from='romeo@example.net/orchard' xml:lang='en'&gt;
  &lt;show&gt;dnd&lt;/show&gt;
  &lt;status&gt;Wooing Juliet&lt;/status&gt;
  &lt;status xml:lang='cs'&gt;Dvo&amp;#x0159;&amp;#x00ED;m se Julii&lt;/status&gt;
&lt;/presence&gt;
</pre></div>
<p>If an outbound stanza generated by a client does not possess an 'xml:lang' attribute, the client's server SHOULD add an 'xml:lang' attribute whose value is that specified for the client's output stream as defined under <a class='info' href='#streams-attr-xmllang'>Section&nbsp;4.7.4<span> (</span><span class='info'>xml:lang</span><span>)</span></a>.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;presence from='romeo@example.net/orchard'&gt;
     &lt;show&gt;dnd&lt;/show&gt;
     &lt;status&gt;Wooing Juliet&lt;/status&gt;
   &lt;/presence&gt;

S: &lt;presence from='romeo@example.net/orchard'
             to='juliet@im.example.com'
             xml:lang='en'&gt;
     &lt;show&gt;dnd&lt;/show&gt;
     &lt;status&gt;Wooing Juliet&lt;/status&gt;
   &lt;/presence&gt;
</pre></div>
<p>If an inbound stanza received by a client or server does not possess an 'xml:lang' attribute, an implementation MUST assume that the default language is that specified for the entity's input stream as defined under <a class='info' href='#streams-attr-xmllang'>Section&nbsp;4.7.4<span> (</span><span class='info'>xml:lang</span><span>)</span></a>.
</p>
<p>The value of the 'xml:lang' attribute MUST conform to the NMTOKEN datatype (as defined in Section 2.3 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>) and MUST conform to the format defined in <a class='info' href='#LANGTAGS'>[LANGTAGS]<span> (</span><span class='info'>Phillips, A. and M. Davis, &ldquo;Tags for Identifying Languages,&rdquo; September&nbsp;2009.</span><span>)</span></a>.
</p>
<p>A server MUST NOT modify or delete 'xml:lang' attributes on stanzas it receives from other entities.
</p>
<a name="stanzas-semantics"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.2"></a><h3>8.2.&nbsp;
Basic Semantics</h3>

<a name="stanzas-semantics-message"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.2.1"></a><h3>8.2.1.&nbsp;
Message Semantics</h3>

<p>The &lt;message/&gt; stanza is a "push" mechanism whereby one entity pushes information to another entity, similar to the communications that occur in a system such as email.  All message stanzas will possess a 'to' attribute that specifies the intended recipient of the message (see <a class='info' href='#stanzas-attributes-to'>Section&nbsp;8.1.1<span> (</span><span class='info'>to</span><span>)</span></a> and <a class='info' href='#rules-noto'>Section&nbsp;10.3<span> (</span><span class='info'>No 'to' Address</span><span>)</span></a>), unless the message is being sent to the bare JID of a connected client's account.  Upon receiving a message stanza with a 'to' address, a server SHOULD attempt to route or deliver it to the intended recipient (see <a class='info' href='#rules'>Section&nbsp;10<span> (</span><span class='info'>Server Rules for Processing XML Stanzas</span><span>)</span></a> for general routing and delivery rules related to XML stanzas).
</p>
<a name="stanzas-semantics-presence"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.2.2"></a><h3>8.2.2.&nbsp;
Presence Semantics</h3>

<p>The &lt;presence/&gt; stanza is a specialized "broadcast" or "publish-subscribe" mechanism, whereby multiple entities receive information (in this case, network availability information) about an entity to which they have subscribed.  In general, a publishing client SHOULD send a presence stanza with no 'to' attribute, in which case the server to which the client is connected will broadcast that stanza to all subscribed entities.  However, a publishing client MAY also send a presence stanza with a 'to' attribute, in which case the server will route or deliver that stanza to the intended recipient.  Although the &lt;presence/&gt; stanza is most often used by XMPP clients, it can also be used by servers, add-on services, and any other kind of XMPP entity.  See <a class='info' href='#rules'>Section&nbsp;10<span> (</span><span class='info'>Server Rules for Processing XML Stanzas</span><span>)</span></a> for general routing and delivery rules related to XML stanzas, and <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a> for rules specific to presence applications.
</p>
<a name="stanzas-semantics-iq"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.2.3"></a><h3>8.2.3.&nbsp;
IQ Semantics</h3>

<p>Info/Query, or IQ, is a "request-response" mechanism, similar in some ways to the Hypertext Transfer Protocol <a class='info' href='#HTTP'>[HTTP]<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, &ldquo;Hypertext Transfer Protocol -- HTTP/1.1,&rdquo; June&nbsp;1999.</span><span>)</span></a>.  The semantics of IQ enable an entity to make a request of, and receive a response from, another entity.  The data content of the request and response is defined by the schema or other structural definition associated with the XML namespace that qualifies the direct child element of the IQ element (see <a class='info' href='#stanzas-extended'>Section&nbsp;8.4<span> (</span><span class='info'>Extended Content</span><span>)</span></a>), and the interaction is tracked by the requesting entity through use of the 'id' attribute.  Thus, IQ interactions follow a common pattern of structured data exchange such as get/result or set/result (although an error can be returned in reply to a request if appropriate):
</p><br /><hr class="insert" />
<a name="figure-5"></a>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
Requesting                  Responding
  Entity                      Entity
----------                  ----------
    |                            |
    | &lt;iq id='1' type='get'&gt;     |
    |   [ ... payload ... ]      |
    | &lt;/iq&gt;                      |
    | -------------------------&gt; |
    |                            |
    | &lt;iq id='1' type='result'&gt;  |
    |   [ ... payload ... ]      |
    | &lt;/iq&gt;                      |
    | &lt;------------------------- |
    |                            |
    | &lt;iq id='2' type='set'&gt;     |
    |   [ ... payload ... ]      |
    | &lt;/iq&gt;                      |
    | -------------------------&gt; |
    |                            |
    | &lt;iq id='2' type='error'&gt;   |
    |   [ ... condition ... ]    |
    | &lt;/iq&gt;                      |
    | &lt;------------------------- |
    |                            |
</pre></div><table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b>&nbsp;Figure&nbsp;5: Semantics of IQ Stanzas&nbsp;</b></font><br /></td></tr></table><hr class="insert" />

<p>To enforce these semantics, the following rules apply:
</p>
<p></p>
<ol class="text">
<li>The 'id' attribute is REQUIRED for IQ stanzas.
</li>
<li>The 'type' attribute is REQUIRED for IQ stanzas.  The value MUST be one of the following; if not, the recipient or an intermediate router MUST return a &lt;bad-request/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-bad-request'>Section&nbsp;8.3.3.1<span> (</span><span class='info'>bad-request</span><span>)</span></a>).
            
            
<ul class="text">
<li>get -- The stanza requests information, inquires about what data is needed in order to complete further operations, etc.
</li>
<li>set -- The stanza provides data that is needed for an operation to be completed, sets new values, replaces existing values, etc.
</li>
<li>result -- The stanza is a response to a successful get or set request.
</li>
<li>error -- The stanza reports an error that has occurred regarding processing or delivery of a get or set request (see <a class='info' href='#stanzas-error'>Section&nbsp;8.3<span> (</span><span class='info'>Stanza Errors</span><span>)</span></a>).
</li>
</ul>
          
</li>
<li>An entity that receives an IQ request of type "get" or "set" MUST reply with an IQ response of type "result" or "error".  The response MUST preserve the 'id' attribute of the request (or be empty if the generated stanza did not include an 'id' attribute).
</li>
<li>An entity that receives a stanza of type "result" or "error" MUST NOT respond to the stanza by sending a further IQ response of type "result" or "error"; however, the requesting entity MAY send another request (e.g., an IQ of type "set" to provide obligatory information discovered through a get/result pair).
</li>
<li>An IQ stanza of type "get" or "set" MUST contain exactly one child element, which specifies the semantics of the particular request.
</li>
<li>An IQ stanza of type "result" MUST include zero or one child elements.
</li>
<li>An IQ stanza of type "error" MAY include the child element contained in the associated "get" or "set" and MUST include an &lt;error/&gt; child; for details, see <a class='info' href='#stanzas-error'>Section&nbsp;8.3<span> (</span><span class='info'>Stanza Errors</span><span>)</span></a>.
</li>
</ol>

<a name="stanzas-error"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3"></a><h3>8.3.&nbsp;
Stanza Errors</h3>

<p>Stanza-related errors are handled in a manner similar to <a class='info' href='#streams-error'>stream errors<span> (</span><span class='info'>Stream Errors</span><span>)</span></a>.  Unlike stream errors, stanza errors are recoverable; therefore, they do not result in termination of the XML stream and underlying TCP connection.  Instead, the entity that discovers the error condition returns an error stanza, which is a stanza that:
</p>
<p>
        </p>
<ul class="text">
<li>is of the same kind (message, presence, or IQ) as the generated stanza that triggered the error
</li>
<li>has a 'type' attribute set to a value of "error"
</li>
<li>typically swaps the 'from' and 'to' addresses of the generated stanza
</li>
<li>mirrors the 'id' attribute (if any) of the generated stanza that triggered the error
</li>
<li>contains an &lt;error/&gt; child element that specifies the error condition and therefore provides a hint regarding actions that the sender might be able to take in an effort to remedy the error (however, it is not always possible to remedy the error)
</li>
</ul><p>
      
</p>
<a name="stanzas-error-rules"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.1"></a><h3>8.3.1.&nbsp;
Rules</h3>

<p>The following rules apply to stanza errors:
</p>
<p></p>
<ol class="text">
<li>The receiving or processing entity that detects an error condition in relation to a stanza SHOULD return an error stanza (and MUST do so for IQ stanzas).
</li>
<li>The error stanza SHOULD simply swap the 'from' and 'to' addresses from the generated stanza, unless doing so would (1) result in an information leak (see under <a class='info' href='#security-leaks'>Section&nbsp;13.10<span> (</span><span class='info'>Information Leaks</span><span>)</span></a>) or other breach of security, or (2) force the sender of the error stanza to include a malformed JID in the 'from' or 'to' address of the error stanza.
</li>
<li>If the generated stanza was &lt;message/&gt; or &lt;presence/&gt; and included an 'id' attribute then it is REQUIRED for the error stanza to also include an 'id' attribute.  If the generated stanza was &lt;iq/&gt; then the error stanza MUST include an 'id' attribute.  In all cases, the value of the 'id' attribute MUST match that of the generated stanza (or be empty if the generated stanza did not include an 'id' attribute).
</li>
<li>An error stanza MUST contain an &lt;error/&gt; child element.
</li>
<li>The entity that returns an error stanza MAY pass along its JID to the sender of the generated stanza (e.g., for diagnostic or tracking purposes) through the addition of a 'by' attribute to the &lt;error/&gt; child element.
</li>
<li>The entity that returns an error stanza MAY include the original XML sent so that the sender can inspect and, if necessary, correct the XML before attempting to resend (however, this is a courtesy only and the originating entity MUST NOT depend on receiving the original payload). Naturally, the entity MUST NOT include the original data if it not well-formed XML, violates the XML restrictions of XMPP (see under <a class='info' href='#xml-restrictions'>Section&nbsp;11.1<span> (</span><span class='info'>XML Restrictions</span><span>)</span></a>), or is otherwise harmful (e.g., exceeds a size limit).
</li>
<li>An &lt;error/&gt; child MUST NOT be included if the 'type' attribute has a value other than "error" (or if there is no 'type' attribute).
</li>
<li>An entity that receives an error stanza MUST NOT respond to the stanza with a further error stanza; this helps to prevent looping.
</li>
</ol>

<a name="stanzas-error-syntax"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.2"></a><h3>8.3.2.&nbsp;
Syntax</h3>

<p>The syntax for stanza-related errors is as follows, where XML data shown within the square brackets '[' and ']' is OPTIONAL, 'intended-recipient' is the JID of the entity to which the original stanza was addressed, 'sender' is the JID of the originating entity, and 'error-generator' is the entity that detects the fact that an error has occurred and thus returns an error stanza.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;stanza-kind from='intended-recipient' to='sender' type='error'&gt;
  [OPTIONAL to include sender XML here]
  &lt;error [by='error-generator']
         type='error-type'&gt;
    &lt;defined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
    [&lt;text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'
           xml:lang='langcode'&gt;
      OPTIONAL descriptive text
    &lt;/text&gt;]
    [OPTIONAL application-specific condition element]
  &lt;/error&gt;
&lt;/stanza-kind&gt;
</pre></div>
<p>The "stanza-kind" MUST be one of message, presence, or iq.
</p>
<p>The "error-type" MUST be one of the following:
</p>
<p>
          </p>
<ul class="text">
<li>auth -- retry after providing credentials
</li>
<li>cancel -- do not retry (the error cannot be remedied)
</li>
<li>continue -- proceed (the condition was only a warning)
</li>
<li>modify -- retry after changing the data sent
</li>
<li>wait -- retry after waiting (the error is temporary)
</li>
</ul><p>
        
</p>
<p>The "defined-condition" MUST correspond to one of the stanza error conditions defined under <a class='info' href='#stanzas-error-conditions'>Section&nbsp;8.3.3<span> (</span><span class='info'>Defined Conditions</span><span>)</span></a>.  However, because additional error conditions might be defined in the future, if an entity receives a stanza error condition that it does not understand then it MUST treat the unknown condition as equivalent to &lt;undefined-condition/&gt; (<a class='info' href='#stanzas-error-conditions-undefined-condition'>Section&nbsp;8.3.3.21<span> (</span><span class='info'>undefined-condition</span><span>)</span></a>).  If the designers of an XMPP protocol extension or the developers of an XMPP implementation need to communicate a stanza error condition that is not defined in this specification, they can do so by defining an application-specific error condition element qualified by an application-specific namespace.
</p>
<p>The &lt;error/&gt; element:
</p>
<p></p>
<ul class="text">
<li>MUST contain a defined condition element.
</li>
<li>MAY contain a &lt;text/&gt; 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-stanzas' namespace and SHOULD possess an 'xml:lang' attribute specifying the natural language of the XML character data.
</li>
<li>MAY contain a child element for an application-specific error condition; this element MUST be qualified by an application-specific namespace that defines the syntax and semantics of the element.
</li>
</ul>

<p>The &lt;text/&gt; element is OPTIONAL.  If included, it is to 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 SHOULD 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).
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: The syntax defined in <a class='info' href='#RFC3920'>[RFC3920]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; October&nbsp;2004.</span><span>)</span></a> included a legacy 'code' attribute, whose semantics have been replaced by the defined condition elements; information about mapping defined condition elements to values of the legacy 'code' attribute can be found in <a class='info' href='#XEP-0086'>[XEP&#8209;0086]<span> (</span><span class='info'>Norris, R. and P. Saint-Andre, &ldquo;Error Condition Mappings,&rdquo; February&nbsp;2004.</span><span>)</span></a>.
</p>
</blockquote>

<a name="stanzas-error-conditions"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3"></a><h3>8.3.3.&nbsp;
Defined Conditions</h3>

<p>The following conditions are defined for use in stanza errors.
</p>
<p>The error-type value that is RECOMMENDED for each defined condition is the usual expected type; however, in some circumstances a different type might be more appropriate.
</p>
<a name="stanzas-error-conditions-bad-request"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.1"></a><h3>8.3.3.1.&nbsp;
bad-request</h3>

<p>The sender has sent a stanza containing XML that does not conform to the appropriate schema or that cannot be processed (e.g., an IQ stanza that includes an unrecognized value of the 'type' attribute, or an element that is qualified by a recognized namespace but that violates the defined syntax for the element); the associated error type SHOULD be "modify".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@im.example.com/balcony'
       id='zj3v142b'
       to='im.example.com'
       type='subscribe'&gt;
     &lt;ping xmlns='urn:xmpp:ping'/&gt;
   &lt;/iq&gt;

S: &lt;iq from='im.example.com'
       id='zj3v142b'
       to='juliet@im.example.com/balcony'
       type='error'&gt;
     &lt;error type='modify'&gt;
       &lt;bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<a name="stanzas-error-conditions-conflict"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.2"></a><h3>8.3.3.2.&nbsp;
conflict</h3>

<p>Access cannot be granted because an existing resource exists with the same name or address; the associated error type SHOULD be "cancel".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq id='wy2xa82b4' type='set'&gt;
     &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'&gt;
       &lt;resource&gt;balcony&lt;/resource&gt;
     &lt;/bind&gt;
   &lt;/iq&gt;

S: &lt;iq id='wy2xa82b4' type='error'&gt;
     &lt;error type='cancel'&gt;
       &lt;conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<a name="stanzas-error-conditions-feature-not-implemented"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.3"></a><h3>8.3.3.3.&nbsp;
feature-not-implemented</h3>

<p>The feature represented in the XML stanza is not implemented by the intended recipient or an intermediate server and therefore the stanza cannot be processed (e.g., the entity understands the namespace but does not recognize the element name); the associated error type SHOULD be "cancel" or "modify".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='juliet@im.example.com/balcony'
       id='9u2bax16'
       to='pubsub.example.com'
       type='get'&gt;
     &lt;pubsub xmlns='http://jabber.org/protocol/pubsub'&gt;
       &lt;subscriptions/&gt;
     &lt;/pubsub&gt;
   &lt;/iq&gt;

E: &lt;iq from='pubsub.example.com'
       id='9u2bax16'
       to='juliet@im.example.com/balcony'
       type='error'&gt;
     &lt;error type='cancel'&gt;
       &lt;feature-not-implemented
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
       &lt;unsupported
           xmlns='http://jabber.org/protocol/pubsub#errors'
           feature='retrieve-subscriptions'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<a name="stanzas-error-conditions-forbidden"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.4"></a><h3>8.3.3.4.&nbsp;
forbidden</h3>

<p>The requesting entity does not possess the necessary permissions to perform an action that only certain authorized roles or individuals are allowed to complete (i.e., it typically relates to authorization rather than authentication); the associated error type SHOULD be "auth".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;presence
       from='juliet@im.example.com/balcony'
       id='y2bs71v4'
       to='characters@muc.example.com/JulieC'&gt;
     &lt;x xmlns='http://jabber.org/protocol/muc'/&gt;
   &lt;/presence&gt;

E: &lt;presence
       from='characters@muc.example.com/JulieC'
       id='y2bs71v4'
       to='juliet@im.example.com/balcony'
       type='error'&gt;
     &lt;error type='auth'&gt;
       &lt;forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/presence&gt;
</pre></div>
<a name="stanzas-error-conditions-gone"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.5"></a><h3>8.3.3.5.&nbsp;
gone</h3>

<p>The recipient or server can no longer be contacted at this address, typically on a permanent basis (as opposed to the &lt;redirect/&gt; error condition, which is used for temporary addressing failures); the associated error type SHOULD be "cancel" and the error stanza SHOULD include a new address (if available) as the XML character data of the &lt;gone/&gt; element (which MUST be a Uniform Resource Identifier <a class='info' href='#URI'>[URI]<span> (</span><span class='info'>Berners-Lee, T., Fielding, R., and L. Masinter, &ldquo;Uniform Resource Identifier (URI): Generic Syntax,&rdquo; January&nbsp;2005.</span><span>)</span></a> or Internationalized Resource Identifier <a class='info' href='#IRI'>[IRI]<span> (</span><span class='info'>Duerst, M. and M. Suignard, &ldquo;Internationalized Resource Identifiers (IRIs),&rdquo; January&nbsp;2005.</span><span>)</span></a> at which the entity can be contacted, typically an XMPP IRI as specified in <a class='info' href='#XMPP-URI'>[XMPP&#8209;URI]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Internationalized Resource Identifiers (IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP),&rdquo; February&nbsp;2008.</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message
       from='juliet@im.example.com/churchyard'
       id='sj2b371v'
       to='romeo@example.net'
       type='chat'&gt;
     &lt;body&gt;Thy lips are warm.&lt;/body&gt;
   &lt;/message&gt;

S: &lt;message
       from='romeo@example.net'
       id='sj2b371v'
       to='juliet@im.example.com/churchyard'
       type='error'&gt;
     &lt;error by='example.net'
            type='cancel'&gt;
       &lt;gone xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'&gt;
         xmpp:romeo@afterlife.example.net
       &lt;/gone&gt;
     &lt;/error&gt;
   &lt;/message&gt;
</pre></div>
<a name="stanzas-error-conditions-internal-server-error"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.6"></a><h3>8.3.3.6.&nbsp;
internal-server-error</h3>

<p>The server has experienced a misconfiguration or other
          internal error that prevents it from processing the stanza;
          the associated error type SHOULD be "cancel".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;presence
       from='juliet@im.example.com/balcony'
       id='y2bs71v4'
       to='characters@muc.example.com/JulieC'&gt;
     &lt;x xmlns='http://jabber.org/protocol/muc'/&gt;
   &lt;/presence&gt;

E: &lt;presence
       from='characters@muc.example.com/JulieC'
       id='y2bs71v4'
       to='juliet@im.example.com/balcony'
       type='error'&gt;
     &lt;error type='cancel'&gt;
       &lt;internal-server-error
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/presence&gt;
</pre></div>
<a name="stanzas-error-conditions-item-not-found"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.7"></a><h3>8.3.3.7.&nbsp;
item-not-found</h3>

<p>The addressed JID or item requested cannot be found; the associated error type SHOULD be "cancel".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;presence from='userfoo@example.com/bar'
             id='pwb2n78i'
             to='nosuchroom@conference.example.org/foo'/&gt;

S: &lt;presence from='nosuchroom@conference.example.org/foo'
             id='pwb2n78i'
             to='userfoo@example.com/bar'
             type='error'&gt;
     &lt;error type='cancel'&gt;
       &lt;item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/presence&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Security Warning: An application MUST NOT return this error if doing so would provide information about the intended recipient's network availability to an entity that is not authorized to know such information (for a more detailed discussion of presence authorization, refer to the discussion of presence subscriptions in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>); instead it MUST return a &lt;service-unavailable/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-service-unavailable'>Section&nbsp;8.3.3.19<span> (</span><span class='info'>service-unavailable</span><span>)</span></a>).
</p>
</blockquote>

<a name="stanzas-error-conditions-jid-malformed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.8"></a><h3>8.3.3.8.&nbsp;
jid-malformed</h3>

<p>The sending entity has provided (e.g., during resource binding) or communicated (e.g., in the 'to' address of a stanza) an XMPP address or aspect thereof that violates the rules defined in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>; the associated error type SHOULD be "modify".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;presence
       from='juliet@im.example.com/balcony'
       id='y2bs71v4'
       to='ch@r@cters@muc.example.com/JulieC'&gt;
     &lt;x xmlns='http://jabber.org/protocol/muc'/&gt;
   &lt;/presence&gt;

E: &lt;presence
       from='ch@r@cters@muc.example.com/JulieC'
       id='y2bs71v4'
       to='juliet@im.example.com/balcony'
       type='error'&gt;
     &lt;error by='muc.example.com'
            type='modify'&gt;
       &lt;jid-malformed
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/presence&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Implementation Note: Enforcement of the format for XMPP localparts is primarily the responsibility of the service at which the associated account or entity is located (e.g., the example.com service is responsible for returning &lt;jid-malformed/&gt; errors related to all JIDs of the form &lt;localpart@example.com&gt;), whereas enforcement of the format for XMPP domainparts is primarily the responsibility of the service that seeks to route a stanza to the service identified by that domainpart (e.g., the example.org service is responsible for returning &lt;jid-malformed/&gt; errors related to stanzas that users of that service have to tried send to JIDs of the form &lt;localpart@example.com&gt;).  However, any entity that detects a malformed JID MAY return this error.
</p>
</blockquote>

<a name="stanzas-error-conditions-not-acceptable"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.9"></a><h3>8.3.3.9.&nbsp;
not-acceptable</h3>

<p>The recipient or server understands the request but cannot process it because the request does not meet criteria defined by the recipient or server (e.g., a request to subscribe to information that does not simultaneously include configuration parameters needed by the recipient); the associated error type SHOULD be "modify".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message to='juliet@im.example.com' id='yt2vs71m'&gt;
     &lt;body&gt;[ ... the-emacs-manual ... ]&lt;/body&gt;
   &lt;/message&gt;

S: &lt;message from='juliet@im.example.com' id='yt2vs71m'&gt;
     &lt;error type='modify'&gt;
       &lt;not-acceptable
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/message&gt;
</pre></div>
<a name="stanzas-error-conditions-not-allowed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.10"></a><h3>8.3.3.10.&nbsp;
not-allowed</h3>

<p>The recipient or server does not allow any entity to perform the action (e.g., sending to entities at a blacklisted domain); the associated error type SHOULD be "cancel".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;presence
       from='juliet@im.example.com/balcony'
       id='y2bs71v4'
       to='characters@muc.example.com/JulieC'&gt;
     &lt;x xmlns='http://jabber.org/protocol/muc'/&gt;
   &lt;/presence&gt;

E: &lt;presence
       from='characters@muc.example.com/JulieC'
       id='y2bs71v4'
       to='juliet@im.example.com/balcony'
       type='error'&gt;
     &lt;error type='cancel'&gt;
       &lt;not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/presence&gt;
</pre></div>
<a name="stanzas-error-conditions-not-authorized"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.11"></a><h3>8.3.3.11.&nbsp;
not-authorized</h3>

<p>The sender needs to provide credentials before being allowed to perform the action, or has provided improper credentials (the name "not-authorized", which was borrowed from the "401 Unauthorized" error of <a class='info' href='#HTTP'>[HTTP]<span> (</span><span class='info'>Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, &ldquo;Hypertext Transfer Protocol -- HTTP/1.1,&rdquo; June&nbsp;1999.</span><span>)</span></a>, might lead the reader to think that this condition relates to authorization, but instead it is typically used in relation to authentication); the associated error type SHOULD be "auth".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;presence
       from='juliet@im.example.com/balcony'
       id='y2bs71v4'
       to='characters@muc.example.com/JulieC'&gt;
     &lt;x xmlns='http://jabber.org/protocol/muc'/&gt;
   &lt;/presence&gt;

E: &lt;presence
       from='characters@muc.example.com/JulieC'
       id='y2bs71v4'
       to='juliet@im.example.com/balcony'&gt;
     &lt;error type='auth'&gt;
       &lt;not-authorized xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/presence&gt;
</pre></div>
<a name="stanzas-error-conditions-policy-violation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.12"></a><h3>8.3.3.12.&nbsp;
policy-violation</h3>

<p>The entity has violated some local service policy (e.g., a message contains words that are prohibited by the service) and the server MAY choose to specify the policy in the &lt;text/&gt; element or in an application-specific condition element; the associated error type SHOULD be "modify" or "wait" depending on the policy being violated.
</p>
<p>(In the following example, the client sends an XMPP message containing words that are forbidden according to the server's local service policy.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message from='romeo@example.net/foo'
            to='bill@im.example.com'
            id='vq71f4nb'&gt;
     &lt;body&gt;%#&amp;@^!!!&lt;/body&gt;
   &lt;/message&gt;

S: &lt;message from='bill@im.example.com'
            id='vq71f4nb'
            to='romeo@example.net/foo'&gt;
     &lt;error by='example.net' type='modify'&gt;
       &lt;policy-violation
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/message&gt;
</pre></div>
<a name="stanzas-error-conditions-recipient-unavailable"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.13"></a><h3>8.3.3.13.&nbsp;
recipient-unavailable</h3>

<p>The intended recipient is temporarily unavailable, undergoing maintenance, etc.; the associated error type SHOULD be "wait".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;presence
       from='juliet@im.example.com/balcony'
       id='y2bs71v4'
       to='characters@muc.example.com/JulieC'&gt;
     &lt;x xmlns='http://jabber.org/protocol/muc'/&gt;
   &lt;/presence&gt;

E: &lt;presence
       from='characters@muc.example.com/JulieC'
       id='y2bs71v4'
       to='juliet@im.example.com/balcony'&gt;
     &lt;error type='wait'&gt;
       &lt;recipient-unavailable
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/presence&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Security Warning: An application MUST NOT return this error if doing so would provide information about the intended recipient's network availability to an entity that is not authorized to know such information (for a more detailed discussion of presence authorization, refer to the discussion of presence subscriptions in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>); instead it MUST return a &lt;service-unavailable/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-service-unavailable'>Section&nbsp;8.3.3.19<span> (</span><span class='info'>service-unavailable</span><span>)</span></a>).
</p>
</blockquote>

<a name="stanzas-error-conditions-redirect"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.14"></a><h3>8.3.3.14.&nbsp;
redirect</h3>

<p>The recipient or server is redirecting requests for this information to another entity, typically in a temporary fashion (as opposed to the &lt;gone/&gt; error condition, which is used for permanent addressing failures); the associated error type SHOULD be "modify" and the error stanza SHOULD contain the alternate address in the XML character data of the &lt;redirect/&gt; element (which MUST be a URI or IRI with which the sender can communicate, typically an XMPP IRI as specified in <a class='info' href='#XMPP-URI'>[XMPP&#8209;URI]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Internationalized Resource Identifiers (IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP),&rdquo; February&nbsp;2008.</span><span>)</span></a>).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;presence
       from='juliet@im.example.com/balcony'
       id='y2bs71v4'
       to='characters@muc.example.com/JulieC'&gt;
     &lt;x xmlns='http://jabber.org/protocol/muc'/&gt;
   &lt;/presence&gt;

E: &lt;presence
       from='characters@muc.example.com/JulieC'
       id='y2bs71v4'
       to='juliet@im.example.com/balcony'
       type='error'&gt;
     &lt;error type='modify'&gt;
       &lt;redirect xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'&gt;
         xmpp:characters@conference.example.org
       &lt;/redirect&gt;
     &lt;/error&gt;
   &lt;/presence&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Security Warning: An application receiving a stanza-level redirect SHOULD warn a human user of the redirection attempt and request approval before proceeding to communicate with the entity whose address is contained in the XML character data of the &lt;redirect/&gt; element, because that entity might have a different identity or might enforce different security policies.  The end-to-end authentication or signing of XMPP stanzas could help to mitigate this risk, since it would enable the sender to determine if the entity to which it has been redirected has the same identity as the entity it originally attempted to contact.  An application MAY have a policy of following redirects only if it has authenticated the receiving entity.  In addition, an application SHOULD abort the communication attempt after a certain number of successive redirects (e.g., at least 2 but no more than 5).
</p>
</blockquote>

<a name="stanzas-error-conditions-registration-required"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.15"></a><h3>8.3.3.15.&nbsp;
registration-required</h3>

<p>The requesting entity is not authorized to access the requested service because prior registration is necessary (examples of prior registration include members-only rooms in XMPP multi-user chat <a class='info' href='#XEP-0045'>[XEP&#8209;0045]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Multi-User Chat,&rdquo; July&nbsp;2007.</span><span>)</span></a> and gateways to non-XMPP instant messaging services, which traditionally required registration in order to use the gateway <a class='info' href='#XEP-0100'>[XEP&#8209;0100]<span> (</span><span class='info'>Saint-Andre, P. and D. Smith, &ldquo;Gateway Interaction,&rdquo; October&nbsp;2005.</span><span>)</span></a>); the associated error type SHOULD be "auth".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;presence
       from='juliet@im.example.com/balcony'
       id='y2bs71v4'
       to='characters@muc.example.com/JulieC'&gt;
     &lt;x xmlns='http://jabber.org/protocol/muc'/&gt;
   &lt;/presence&gt;

E: &lt;presence
       from='characters@muc.example.com/JulieC'
       id='y2bs71v4'
       to='juliet@im.example.com/balcony'&gt;
     &lt;error type='auth'&gt;
       &lt;registration-required
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/presence&gt;
</pre></div>
<a name="stanzas-error-conditions-remote-server-not-found"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.16"></a><h3>8.3.3.16.&nbsp;
remote-server-not-found</h3>

<p>A remote server or service specified as part or all of the JID of the intended recipient does not exist or cannot be resolved (e.g., there is no _xmpp-server._tcp DNS SRV record, the A or AAAA fallback resolution fails, or A/AAAA lookups succeed but there is no response on the IANA-registered port 5269); the associated error type SHOULD be "cancel".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message
       from='romeo@example.net/home'
       id='ud7n1f4h'
       to='bar@example.org'
       type='chat'&gt;
    &lt;body&gt;yt?&lt;/body&gt;
   &lt;/message&gt;

E: &lt;message
       from='bar@example.org'
       id='ud7n1f4h'
       to='romeo@example.net/home'
       type='error'&gt;
     &lt;error type='cancel'&gt;
       &lt;remote-server-not-found
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/message&gt;
</pre></div>
<a name="stanzas-error-conditions-remote-server-timeout"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.17"></a><h3>8.3.3.17.&nbsp;
remote-server-timeout</h3>

<p>A remote server or service specified as part or all of the JID of the intended recipient (or needed to fulfill a request) was resolved but communications could not be established within a reasonable amount of time (e.g., an XML stream cannot be established at the resolved IP address and port, or an XML stream can be established but stream negotiation fails because of problems with TLS, SASL, Server Dialback, etc.); the associated error type SHOULD be "wait" (unless the error is of a more permanent nature, e.g., the remote server is found but it cannot be authenticated or it violates security policies).
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message
       from='romeo@example.net/home'
       id='ud7n1f4h'
       to='bar@example.org'
       type='chat'&gt;
    &lt;body&gt;yt?&lt;/body&gt;
   &lt;/message&gt;

E: &lt;message
       from='bar@example.org'
       id='ud7n1f4h'
       to='romeo@example.net/home'
       type='error'&gt;
     &lt;error type='wait'&gt;
       &lt;remote-server-timeout
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/message&gt;
</pre></div>
<a name="stanzas-error-conditions-resource-constraint"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.18"></a><h3>8.3.3.18.&nbsp;
resource-constraint</h3>

<p>The server or recipient is busy or lacks the system resources necessary to service the request; the associated error type SHOULD be "wait".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='romeo@example.net/foo'
       id='kj4vz31m'
       to='pubsub.example.com'
       type='get'&gt;
     &lt;pubsub xmlns='http://jabber.org/protocol/pubsub'&gt;
       &lt;items node='my_musings'/&gt;
     &lt;/pubsub&gt;
   &lt;/iq&gt;

E: &lt;iq from='pubsub.example.com'
       id='kj4vz31m'
       to='romeo@example.net/foo'
       type='error'&gt;
     &lt;error type='wait'&gt;
       &lt;resource-constraint
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<a name="stanzas-error-conditions-service-unavailable"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.19"></a><h3>8.3.3.19.&nbsp;
service-unavailable</h3>

<p>The server or recipient does not currently provide the requested service; the associated error type SHOULD be "cancel".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message from='romeo@example.net/foo'
            to='juliet@im.example.com'&gt;
     &lt;body&gt;Hello?&lt;/body&gt;
   &lt;/message&gt;

S: &lt;message from='juliet@im.example.com/foo'
            to='romeo@example.net'&gt;
     &lt;error type='cancel'&gt;
       &lt;service-unavailable
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/message&gt;
</pre></div>
<p></p>
<blockquote class="text">
<p>Security Warning: An application MUST return a &lt;service-unavailable/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-service-unavailable'>Section&nbsp;8.3.3.19<span> (</span><span class='info'>service-unavailable</span><span>)</span></a>) instead of &lt;item-not-found/&gt; (<a class='info' href='#stanzas-error-conditions-item-not-found'>Section&nbsp;8.3.3.7<span> (</span><span class='info'>item-not-found</span><span>)</span></a>) or &lt;recipient-unavailable/&gt; (<a class='info' href='#stanzas-error-conditions-recipient-unavailable'>Section&nbsp;8.3.3.13<span> (</span><span class='info'>recipient-unavailable</span><span>)</span></a>) if sending one of the latter errors would provide information about the intended recipient's network availability to an entity that is not authorized to know such information (for a more detailed discussion of presence authorization, refer to <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</p>
</blockquote>

<a name="stanzas-error-conditions-subscription-required"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.20"></a><h3>8.3.3.20.&nbsp;
subscription-required</h3>

<p>The requesting entity is not authorized to access the requested service because a prior subscription is necessary (examples of prior subscription include authorization to receive presence information as defined in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a> and opt-in data feeds for XMPP publish-subscribe as defined in <a class='info' href='#XEP-0060'>[XEP&#8209;0060]<span> (</span><span class='info'>Millard, P., Saint-Andre, P., and R. Meijer, &ldquo;Publish-Subscribe,&rdquo; July&nbsp;2010.</span><span>)</span></a>); the associated error type SHOULD be "auth".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message
       from='romeo@example.net/orchard'
       id='pa73b4n7'
       to='playwright@shakespeare.example.com'
       type='chat'&gt;
     &lt;subject&gt;ACT II, SCENE II&lt;/subject&gt;
     &lt;body&gt;help, I forgot my lines!&lt;/body&gt;
   &lt;/message&gt;

E: &lt;message
       from='playwright@shakespeare.example.com'
       id='pa73b4n7'
       to='romeo@example.net/orchard'
       type='error'&gt;
     &lt;error type='auth'&gt;
       &lt;subscription-required
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/message&gt;
</pre></div>
<a name="stanzas-error-conditions-undefined-condition"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.21"></a><h3>8.3.3.21.&nbsp;
undefined-condition</h3>

<p>The error condition is not one of those defined by the
          other conditions in this list; any error type can be
          associated with this condition, and it SHOULD NOT be used except in conjunction with an application-specific condition.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message
       from='northumberland@shakespeare.example'
       id='richard2-4.1.247'
       to='kingrichard@royalty.england.example'&gt;
     &lt;body&gt;My lord, dispatch; read o'er these articles.&lt;/body&gt;
     &lt;amp xmlns='http://jabber.org/protocol/amp'&gt;
       &lt;rule action='notify'
             condition='deliver'
             value='stored'/&gt;
     &lt;/amp&gt;
   &lt;/message&gt;

S: &lt;message from='example.org'
            id='amp1'
            to='northumberland@example.net/field'
            type='error'&gt;
     &lt;amp xmlns='http://jabber.org/protocol/amp'
          from='kingrichard@example.org'
          status='error'
          to='northumberland@example.net/field'&gt;
       &lt;rule action='error'
             condition='deliver'
             value='stored'/&gt;
     &lt;/amp&gt;
     &lt;error type='modify'&gt;
       &lt;undefined-condition
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
       &lt;failed-rules xmlns='http://jabber.org/protocol/amp#errors'&gt;
         &lt;rule action='error'
               condition='deliver'
               value='stored'/&gt;
       &lt;/failed-rules&gt;
     &lt;/error&gt;
   &lt;/message&gt;
</pre></div>
<a name="stanzas-error-conditions-unexpected-request"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.3.22"></a><h3>8.3.3.22.&nbsp;
unexpected-request</h3>

<p>The recipient or server understood the request but was not expecting it at this time (e.g., the request was out of order); the associated error type SHOULD be "wait" or "modify".
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq from='romeo@example.net/foo'
       id='o6hsv25z'
       to='pubsub.example.com'
       type='set'&gt;
     &lt;pubsub xmlns='http://jabber.org/protocol/pubsub'&gt;
        &lt;unsubscribe
            node='my_musings'
            jid='romeo@example.net'/&gt;
     &lt;/pubsub&gt;
   &lt;/iq&gt;

E: &lt;iq from='pubsub.example.com'
       id='o6hsv25z'
       to='romeo@example.net/foo'
       type='error'&gt;
     &lt;error type='modify'&gt;
       &lt;unexpected-request
           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
       &lt;not-subscribed
           xmlns='http://jabber.org/protocol/pubsub#errors'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<a name="stanzas-error-app"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.3.4"></a><h3>8.3.4.&nbsp;
Application-Specific Conditions</h3>

<p>As noted, an application MAY provide application-specific stanza error information by including a properly namespaced child within the error element.  Typically, the application-specific element supplements or further qualifies a defined element.  Thus, the &lt;error/&gt; element will contain two or three child elements.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;iq id='ixc3v1b9' type='error'&gt;
  &lt;error type='modify'&gt;
    &lt;bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
    &lt;too-many-parameters xmlns='http://example.org/ns'/&gt;
  &lt;/error&gt;
&lt;/iq&gt;
</pre></div><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message type='error' id='7h3baci9'&gt;
  &lt;error type='modify'&gt;
    &lt;undefined-condition
          xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
    &lt;text xml:lang='en'
          xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'&gt;
      [ ... application-specific information ... ]
    &lt;/text&gt;
    &lt;too-many-parameters xmlns='http://example.org/ns'/&gt;
  &lt;/error&gt;
&lt;/message&gt;
</pre></div>
<p>An entity that receives an application-specific error condition it does not understand MUST ignore that condition but appropriately process the rest of the error stanza.
</p>
<a name="stanzas-extended"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.8.4"></a><h3>8.4.&nbsp;
Extended Content</h3>

<p>Although the message, presence, and IQ stanzas provide basic semantics for messaging, availability, and request-response interactions, XMPP uses XML namespaces (see <a class='info' href='#XML-NAMES'>[XML&#8209;NAMES]<span> (</span><span class='info'>Thompson, H., Hollander, D., Layman, A., Bray, T., and R. Tobin, &ldquo;Namespaces in XML 1.0 (Third Edition),&rdquo; December&nbsp;2009.</span><span>)</span></a>) to extend the basic stanza syntax for the purpose of providing additional functionality.
</p>
<p>A message or presence stanza MAY contain one or more optional child elements specifying content that extends the meaning of the message (e.g., an XHTML-formatted version of the message body as described in <a class='info' href='#XEP-0071'>[XEP&#8209;0071]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;XHTML-IM,&rdquo; September&nbsp;2008.</span><span>)</span></a>), and an IQ stanza of type "get" or "set" MUST contain one such child element.  Such a child element MAY have any name and MUST possess a namespace declaration (other than "jabber:client", "jabber:server", or "http://etherx.jabber.org/streams") that defines the data contained within the child element.  Such a child element is called an "extension element".  An extension element can be included either at the direct child level of the stanza or in any mix of levels.
</p>
<p>Similarly, "extension attributes" are allowed.  That is: a stanza itself (i.e., an &lt;iq/&gt;, &lt;message/&gt;, or &lt;presence/&gt; element qualified by the "jabber:client" or "jabber:server" content namespace) or any child element of such a stanza (whether an extension element or a child element qualified by the content namespace) MAY also include one or more attributes qualified by XML namespaces other than the content namespace or the reserved "http://www.w3.org/XML/1998/namespace" namespace (including the so-called "empty namespace" if the attribute is not prefixed as described under <a class='info' href='#XML-NAMES'>[XML&#8209;NAMES]<span> (</span><span class='info'>Thompson, H., Hollander, D., Layman, A., Bray, T., and R. Tobin, &ldquo;Namespaces in XML 1.0 (Third Edition),&rdquo; December&nbsp;2009.</span><span>)</span></a>).
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: For the sake of backward compatibility and maximum interoperability, an entity that generates a stanza SHOULD NOT include such attributes in the stanza itself or in child elements of the stanza that are qualified by the content namespaces "jabber:client" or "jabber:server" (e.g., the &lt;body/&gt; child of the &lt;message/&gt; stanza).
</p>
</blockquote>

<p>An extension element or extension attribute is said to be "extended content" and the qualifying namespace for such an element or attribute is said to be an "extended namespace".
</p>
<p></p>
<blockquote class="text">
<p>Informational Note: Although extended namespaces for XMPP are commonly defined by the XMPP Standards Foundation (XSF) and by the IETF, no specification or IETF standards action is necessary to define extended namespaces, and any individual or organization is free to define XMPP extensions.
</p>
</blockquote>

<p>To illustrate these concepts, several examples follow.
</p>
<p>The following stanza contains one direct child element whose extended namespace is 'jabber:iq:roster':
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;iq from='juliet@capulet.com/balcony'
    id='h83vxa4c'
    type='get'&gt;
 &lt;query xmlns='jabber:iq:roster'/&gt;
&lt;/iq&gt;
</pre></div>
<p>The following stanza contains two direct child elements with two different extended namespaces.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;presence from='juliet@capulet.com/balcony'&gt;
  &lt;c xmlns='http://jabber.org/protocol/caps'
     hash='sha-1'
     node='http://code.google.com/p/exodus'
     ver='QgayPKawpkPSDYmwT/WM94uAlu0='/&gt;
  &lt;x xmlns='vcard-temp:x:update'&gt;
    &lt;photo&gt;sha1-hash-of-image&lt;/photo&gt;
  &lt;/x&gt;
&lt;/presence&gt;
</pre></div>
<p>The following stanza contains two child elements, one of which is qualified by the "jabber:client" or "jabber:server" content namespace and one of which is qualified by an extended namespace; the extension element in turn contains a child element that is qualified by a different extended namespace.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;message to='juliet@capulet.com'&gt;
  &lt;body&gt;Hello?&lt;/body&gt;
  &lt;html xmlns='http://jabber.org/protocol/xhtml-im'&gt;
    &lt;body xmlns='http://www.w3.org/1999/xhtml'&gt;
      &lt;p style='font-weight:bold'&gt;Hello?&lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;
&lt;/message&gt;
</pre></div>
<p>It is conventional in the XMPP community for implementations to not generate namespace prefixes for elements that are qualified by extended namespaces (in the XML community, this convention is sometimes called "prefix-free canonicalization").  However, if an implementation generates such namespace prefixes then it MUST include the namespace declaration in the stanza itself or a child element of the stanza, not in the stream header (see <a class='info' href='#streams-ns-other'>Section&nbsp;4.8.4<span> (</span><span class='info'>Other Namespaces</span><span>)</span></a>).
</p>
<p>Routing entities (typically servers) SHOULD try to maintain prefixes when serializing XML stanzas for processing, but receiving entities MUST NOT depend on the prefix strings to have any particular value (the allowance for the 'stream' prefix, described under <a class='info' href='#streams-ns-declarations'>Section&nbsp;4.8.5<span> (</span><span class='info'>Namespace Declarations and Prefixes</span><span>)</span></a>, is an exception to this rule, albeit for streams rather than stanzas).
</p>
<p>Support for any given extended namespace is OPTIONAL on the part of any implementation.  If an entity does not understand such a namespace, the entity's expected behavior depends on whether the entity is (1) the recipient or (2) a server that is routing or delivering the stanza to the recipient.
</p>
<p>If a recipient receives a stanza that contains an element or attribute it does not understand, it MUST NOT attempt to process that XML data and instead MUST proceed as follows.
</p>
<p>
        </p>
<ul class="text">
<li>If an intended recipient receives a message stanza whose only child element is qualified by a namespace it does not understand, then depending on the XMPP application it MUST either ignore the entire stanza or return a stanza error, which SHOULD be &lt;service-unavailable/&gt; (<a class='info' href='#stanzas-error-conditions-service-unavailable'>Section&nbsp;8.3.3.19<span> (</span><span class='info'>service-unavailable</span><span>)</span></a>).
</li>
<li>If an intended recipient receives a presence stanza whose only child element is qualified by a namespace it does not understand, then it MUST ignore the child element by treating the presence stanza as if it contained no child element.
</li>
<li>If an intended recipient receives a message or presence stanza that contains XML data qualified by a namespace it does not understand, then it MUST ignore the portion of the stanza qualified by the unknown namespace.
</li>
<li>If an intended recipient receives an IQ stanza of type "get" or "set" containing a child element qualified by a namespace it does not understand, then the entity MUST return an IQ stanza of type "error" with an error condition of &lt;service-unavailable/&gt;.
</li>
</ul><p>
      
</p>
<p>If a server handles a stanza that is intended for delivery to another entity and that contains a child element it does not understand, it MUST route the stanza unmodified to a remote server or deliver the stanza unmodified to a connected client associated with a local account.
</p>
<a name="examples"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9"></a><h3>9.&nbsp;
Detailed Examples</h3>

<p>The detailed examples in this section further illustrate the protocols defined in this specification.
</p>
<a name="examples-c2s"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.1"></a><h3>9.1.&nbsp;
Client-to-Server Examples</h3>

<p>The following examples show the XMPP data flow for a client
negotiating an XML stream with a server, exchanging XML stanzas, and closing
the negotiated stream.  The server is "im.example.com", the server requires use
of TLS, the client authenticates via the SASL SCRAM-SHA-1 mechanism as
&lt;juliet@im.example.com&gt; with a password of
  "r0m30myr0m30", and the client binds a client-submitted resource to the stream.  It is assumed that before sending the initial stream header, the client has already resolved an SRV record of _xmpp&#8209;client._tcp.im.example.com and has opened a TCP connection to the advertised port at the resolved IP address.
</p>
<a name="examples-c2s-tls"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.1.1"></a><h3>9.1.1.&nbsp;
TLS</h3>

<p>Step 1: Client initiates stream to server:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;stream:stream
     from='juliet@im.example.com'
     to='im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>Step 2: Server responds by sending a response stream header to client:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;stream:stream
     from='im.example.com'
     id='t7AMCin9zjMNwQKDnplntZPIDEI='
     to='juliet@im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>Step 3: Server sends stream features to client (only the STARTTLS extension at this point, which is mandatory-to-negotiate):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;stream:features&gt;
     &lt;starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'&gt;
       &lt;required/&gt;
     &lt;/starttls&gt;
   &lt;/stream:features&gt;
</pre></div>
<p>Step 4: Client sends STARTTLS command to server:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/&gt;
</pre></div>
<p>Step 5: Server informs client that it is allowed to proceed:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/&gt;
</pre></div>
<p>Step 5 (alt): Server informs client that STARTTLS negotiation has failed, closes the XML stream, and terminates the TCP connection (thus, the stream negotiation process ends unsuccessfully and the parties do not move on to the next step):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-tls'/&gt;
   &lt;/stream:stream&gt;
</pre></div>
<p>Step 6: Client and server attempt to complete TLS negotiation over the existing TCP connection (see <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a> for details).
</p>
<p>Step 7: If TLS negotiation is successful, client initiates a new stream to server over the TLS-protected TCP connection:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;stream:stream
     from='juliet@im.example.com'
     to='im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>Step 7 (alt): If TLS negotiation is unsuccessful, server closes TCP connection (thus, the stream negotiation process ends unsuccessfully and the parties do not move on to the next step):
</p>
<a name="examples-c2s-sasl"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.1.2"></a><h3>9.1.2.&nbsp;
SASL</h3>

<p>Step 8: Server responds by sending a stream header to client along with any available stream features:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;stream:stream
     from='im.example.com'
     id='vgKi/bkYME8OAj4rlXMkpucAqe4='
     to='juliet@im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;stream:features&gt;
     &lt;mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
       &lt;mechanism&gt;SCRAM-SHA-1-PLUS&lt;/mechanism&gt;
       &lt;mechanism&gt;SCRAM-SHA-1&lt;/mechanism&gt;
       &lt;mechanism&gt;PLAIN&lt;/mechanism&gt;
     &lt;/mechanisms&gt;
   &lt;/stream:features&gt;
</pre></div>
<p>Step 9: Client selects an authentication mechanism
          (in this case, SCRAM-SHA-1), including initial response data:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl"
         mechanism="SCRAM-SHA-1"&gt;
     biwsbj1qdWxpZXQscj1vTXNUQUF3QUFBQU1BQUFBTlAwVEFBQUFBQUJQVTBBQQ==
   &lt;/auth&gt;
</pre></div>
<p>The decoded base 64 data is "n,,n=juliet,r=oMsTAAwAAAAMAAAANP0TAAAAAABPU0AA".
</p>
<p>Step 10: Server sends a challenge:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl"&gt;
     cj1vTXNUQUF3QUFBQU1BQUFBTlAwVEFBQUFBQUJQVTBBQWUxMjQ2OTViLTY5Y
     TktNGRlNi05YzMwLWI1MWIzODA4YzU5ZSxzPU5qaGtZVE0wTURndE5HWTBaaT
     AwTmpkbUxUa3hNbVV0TkRsbU5UTm1ORE5rTURNeixpPTQwOTY=
   &lt;/challenge&gt;
</pre></div>
<p>The decoded base 64 data is "r=oMsTAAwAAAAMAAAANP0TAAAAAABPU0AAe124695b-69a9-4de6-9c30-b51b3808c59e,s=NjhkYTM0MDgtNGY0Zi00NjdmLTkxMmUtNDlmNTNmNDNkMDMz,i=4096" (line breaks not included in actual data).
</p>
<p>Step 11: Client sends a response:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"&gt;
     Yz1iaXdzLHI9b01zVEFBd0FBQUFNQUFBQU5QMFRBQUFBQUFCUFUwQUFlMTI0N
     jk1Yi02OWE5LTRkZTYtOWMzMC1iNTFiMzgwOGM1OWUscD1VQTU3dE0vU3ZwQV
     RCa0gyRlhzMFdEWHZKWXc9
   &lt;/response&gt;
</pre></div>
<p>
  The decoded base 64 data is "c=biws,r=oMsTAAwAAAAMAAAANP0TAAAAAABPU0
  AAe124695b-69a9-4de6-9c30-b51b3808c59e,p=UA57tM/
  SvpATBkH2FXs0WDXvJYw=" (line breaks not included in actual data).

</p>
<p>Step 12: Server informs client of success, including additional data with success:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     dj1wTk5ERlZFUXh1WHhDb1NFaVc4R0VaKzFSU289
   &lt;/success&gt;
</pre></div>
<p>The decoded base 64 data is "v=pNNDFVEQxuXxCoSEiW8GEZ+1RSo=".
</p>
<p>Step 12 (alt): Server returns a SASL error to client (thus, the stream negotiation process ends unsuccessfully and the parties do not move on to the next step):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
     &lt;not-authorized/&gt;
   &lt;/failure&gt;
   &lt;/stream&gt;
</pre></div>
<p>Step 13: Client initiates a new stream to server:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;stream:stream
     from='juliet@im.example.com'
     to='im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<a name="examples-c2s-bind"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.1.3"></a><h3>9.1.3.&nbsp;
Resource Binding</h3>

<p>Step 14: Server responds by sending a stream header to client along with supported features (in this case, resource binding):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;stream:stream
     from='im.example.com'
     id='gPybzaOzBmaADgxKXu9UClbprp0='
     to='juliet@im.example.com'
     version='1.0'
     xml:lang='en'
     xmlns='jabber:client'
     xmlns:stream='http://etherx.jabber.org/streams'&gt;

S: &lt;stream:features&gt;
     &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/&gt;
   &lt;/stream:features&gt;
</pre></div>
<p>Upon being informed that resource binding is mandatory-to-negotiate, the client needs to bind a resource to the stream; here we assume that the client submits a human-readable text string.
</p>
<p>Step 15: Client binds a resource:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;iq id='yhc13a95' type='set'&gt;
     &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'&gt;
       &lt;resource&gt;balcony&lt;/resource&gt;
     &lt;/bind&gt;
   &lt;/iq&gt;
</pre></div>
<p>Step 16: Server accepts submitted resourcepart and informs client of successful resource binding:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='yhc13a95' type='result'&gt;
     &lt;bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'&gt;
       &lt;jid&gt;
         juliet@im.example.com/balcony
       &lt;/jid&gt;
     &lt;/bind&gt;
   &lt;/iq&gt;
</pre></div>
<p>Step 16 (alt): Server returns error to client (thus, the stream negotiation process ends unsuccessfully and the parties do not move on to the next step):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;iq id='yhc13a95' type='error'&gt;
     &lt;error type='cancel'&gt;
       &lt;conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
     &lt;/error&gt;
   &lt;/iq&gt;
</pre></div>
<a name="examples-c2s-stanzas"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.1.4"></a><h3>9.1.4.&nbsp;
Stanza Exchange</h3>

<p>Now the client is allowed to send XML stanzas over the negotiated stream.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;message from='juliet@im.example.com/balcony'
            id='ju2ba41c'
            to='romeo@example.net'
            type='chat'
            xml:lang='en'&gt;
     &lt;body&gt;Art thou not Romeo, and a Montague?&lt;/body&gt;
   &lt;/message&gt;
</pre></div>
<p>If necessary, sender's server negotiates XML streams with intended recipient's server (see <a class='info' href='#examples-s2s'>Section&nbsp;9.2<span> (</span><span class='info'>Server-to-Server Examples</span><span>)</span></a>).
</p>
<p>The intended recipient replies, and the message is delivered to the client.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
E: &lt;message from='romeo@example.net/orchard'
            id='ju2ba41c'
            to='juliet@im.example.com/balcony'
            type='chat'
            xml:lang='en'&gt;
     &lt;body&gt;Neither, fair saint, if either thee dislike.&lt;/body&gt;
   &lt;/message&gt;
</pre></div>
<p>The client can subsequently send and receive an unbounded number of subsequent XML stanzas over the stream.
</p>
<a name="examples-c2s-close"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.1.5"></a><h3>9.1.5.&nbsp;
Close</h3>

<p>Desiring to send no further messages, the client closes its stream to the server but waits for incoming data from the server.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
C: &lt;/stream:stream&gt;
</pre></div>
<p>Consistent with <a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a>, the server might send additional data to the client and then closes its stream to the client.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S: &lt;/stream:stream&gt;
</pre></div>
<p>The client now sends a TLS close_notify alert, receives a responding close_notify alert from the server, and then terminates the underlying TCP connection.
</p>
<a name="examples-s2s"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.2"></a><h3>9.2.&nbsp;
Server-to-Server Examples</h3>

<p>The following examples show the data flow for a server negotiating an XML stream with a peer server, exchanging XML stanzas, and closing the negotiated stream.  The initiating server ("Server1") is im.example.com; the receiving server ("Server2") is example.net and it requires use of TLS; im.example.com presents a certificate and authenticates via the SASL EXTERNAL mechanism.  It is assumed that before sending the initial stream header, Server1 has already resolved an SRV record of _xmpp-server._tcp.example.net and has opened a TCP connection to the advertised port at the resolved IP address.  Note how Server1 declares the content namespace "jabber:server" as the default namespace and uses prefixes for stream-related elements, whereas Server2 uses prefix-free canonicalization.
</p>
<a name="examples-s2s-tls"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.2.1"></a><h3>9.2.1.&nbsp;
TLS</h3>

<p>Step 1: Server1 initiates stream to Server2:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S1: &lt;stream:stream
      from='im.example.com'
      to='example.net'
      version='1.0'
      xmlns='jabber:server'
      xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>Step 2: Server2 responds by sending a response stream header to Server1:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S2: &lt;stream
      from='example.net'
      id='hTiXkW+ih9k2SqdGkk/AZi0OJ/Q='
      to='im.example.com'
      version='1.0'
      xmlns='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>Step 3: Server2 sends stream features to Server1 (only the STARTTLS extension at this point, which is mandatory-to-negotiate):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S2: &lt;features xmlns='http://etherx.jabber.org/streams'&gt;
      &lt;starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'&gt;
        &lt;required/&gt;
      &lt;/starttls&gt;
    &lt;/features&gt;
</pre></div>
<p>Step 4: Server1 sends the STARTTLS command to Server2:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S1: &lt;starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/&gt;
</pre></div>
<p>Step 5: Server2 informs Server1 that it is allowed to proceed:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S2: &lt;proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/&gt;
</pre></div>
<p>Step 5 (alt): Server2 informs Server1 that STARTTLS negotiation has failed, closes the stream, and terminates the TCP connection (thus, the stream negotiation process ends unsuccessfully and the parties do not move on to the next step):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S2: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-tls'/&gt;
    &lt;/stream&gt;
</pre></div>
<p>Step 6: Server1 and Server2 attempt to complete TLS negotiation via TCP (see <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a> for details).
</p>
<p>Step 7: If TLS negotiation is successful, Server1 initiates a new stream to Server2 over the TLS-protected TCP connection:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S1: &lt;stream:stream
      from='im.example.com'
      to='example.net'
      version='1.0'
      xmlns='jabber:server'
      xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>Step 7 (alt): If TLS negotiation is unsuccessful, Server2
        closes the TCP connection (thus, the stream negotiation process ends unsuccessfully and the parties do not move on to the next step).
</p>
<a name="examples-s2s-sasl"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.2.2"></a><h3>9.2.2.&nbsp;
SASL</h3>

<p>Step 8: Server2 sends a response stream header to Server1 along with available stream features (including a preference for the SASL EXTERNAL mechanism):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S2: &lt;stream
      from='example.net'
      id='RChdjlgj/TIBcbT9Keu31zDihH4='
      to='im.example.com'
      version='1.0'
      xmlns='http://etherx.jabber.org/streams'&gt;

S2: &lt;features xmlns='http://etherx.jabber.org/streams'&gt;
      &lt;mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
        &lt;mechanism&gt;EXTERNAL&lt;/mechanism&gt;
      &lt;/mechanisms&gt;
    &lt;/features&gt;
</pre></div>
<p>Step 9: Server1 selects the EXTERNAL mechanism (including an empty response of "="):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S1: &lt;auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
          mechanism='EXTERNAL'&gt;=&lt;/auth&gt;
</pre></div>
<p>Step 10: Server2 returns success:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S2: &lt;success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/&gt;
</pre></div>
<p>Step 10 (alt): Server2 informs Server1 of failed authentication (thus, the stream negotiation process ends unsuccessfully and the parties do not move on to the next step):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S2: &lt;failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'&gt;
      &lt;not-authorized/&gt;
    &lt;/failure&gt;
    &lt;/stream&gt;
</pre></div>
<p>Step 11: Server1 initiates a new stream to Server2:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S1: &lt;stream:stream
      from='im.example.com'
      to='example.net'
      version='1.0'
      xmlns='jabber:server'
      xmlns:stream='http://etherx.jabber.org/streams'&gt;
</pre></div>
<p>Step 12: Server2 responds by sending a stream header to Server1 along with any additional features (or, in this case, an empty features element):
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S2: &lt;stream
      from='example.net'
      id='MbbV2FeojySpUIP6J91qaa+TWHM='
      to='im.example.com'
      version='1.0'
      xmlns='http://etherx.jabber.org/streams'&gt;

S2: &lt;features xmlns='http://etherx.jabber.org/streams'/&gt;
</pre></div>
<a name="examples-s2s-stanzas"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.2.3"></a><h3>9.2.3.&nbsp;
Stanza Exchange</h3>

<p>Now Server1 is allowed to send XML stanzas to Server2 over the negotiated stream from im.example.com to example.net; here we assume that the transferred stanzas are those shown earlier for client-to-server communication, albeit over a server-to-server stream qualified by the 'jabber:server' namespace.
</p>
<p>Server1 sends XML stanza to Server2:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S1: &lt;message from='juliet@im.example.com/balcony'
             id='ju2ba41c'
             to='romeo@example.net'
             type='chat'
             xml:lang='en'&gt;
    &lt;body&gt;Art thou not Romeo, and a Montague?&lt;/body&gt;
   &lt;/message&gt;
</pre></div>
<a name="examples-s2s-close"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.9.2.4"></a><h3>9.2.4.&nbsp;
Close</h3>

<p>Desiring to send no further messages, Server1 closes its stream to Server2 but waits for incoming data from Server2.  (In practice, the stream would most likely remain open for some time, since Server1 and Server2 do not immediately know if the stream will be needed for further communication.)
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S1: &lt;/stream:stream&gt;
</pre></div>
<p>Consistent with the recommended stream closing handshake, Server2 closes the stream as well:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
S2: &lt;/stream&gt;
</pre></div>
<p>Server1 now sends a TLS close_notify alert, receives a responding close_notify alert from Server2, and then terminates the underlying TCP connection.
</p>
<a name="rules"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10"></a><h3>10.&nbsp;
Server Rules for Processing XML Stanzas</h3>

<p>Each server implementation will contain its own logic for processing stanzas it receives.  Such logic determines whether the server needs to route a given stanza to another domain, deliver it to a local entity (typically a connected client associated with a local account), or handle it directly within the server itself.  This section provides general rules for processing XML stanzas.  However, particular XMPP applications MAY specify delivery rules that modify or supplement the following rules (e.g., a set of delivery rules for instant messaging and presence applications is defined in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</p>
<a name="rules-order"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.1"></a><h3>10.1.&nbsp;
In-Order Processing</h3>

<p>An XMPP server MUST ensure in-order processing of the stanzas and other XML elements it receives over a given input stream from a connected client or remote server.
</p>
<p>In-order processing applies (a) to any XML elements used to negotiate and manage XML streams, and (b) to all uses of XML stanzas, including but not limited to the following:
</p>
<p>
        </p>
<ol class="text">
<li>Stanzas sent by a client to its server or to its own bare JID for direct processing by the server (e.g., in-order processing of a roster get and initial presence as described in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</li>
<li>Stanzas sent by a connected client and intended for delivery to another entity associated with the server (e.g., stanzas addressed from &lt;juliet@im.example.com&gt; to &lt;nurse@im.example.com&gt;).  The server MUST ensure that it delivers stanzas addressed to the intended recipient in the order it receives them over the input stream from the sending client, treating stanzas addressed to the bare JID and the full JID of the intended recipient as equivalent for delivery purposes.
</li>
<li>Stanzas sent by a connected client and intended for delivery to an entity located at a remote domain (e.g., stanzas addressed from &lt;juliet@im.example.com&gt; to &lt;romeo@example.net&gt;).  The routing server MUST ensure that it routes stanzas addressed to the intended recipient in the order it receives them over the input stream from the sending client, treating stanzas addressed to the bare JID and the full JID of the intended recipient as equivalent for routing purposes.  To help ensure in-order processing, the routing server MUST route such stanzas over a single output stream to the remote domain, rather than sending some stanzas over one server-to-server stream and other stanzas over another server-to-server stream.
</li>
<li>Stanzas routed from one server to another server for delivery to an entity associated with the remote domain (e.g., stanzas addressed from &lt;juliet@im.example.com&gt; to &lt;romeo@example.net&gt; and routed by &lt;im.example.com&gt; over a server-to-server stream to &lt;example.net&gt;).  The delivering server MUST ensure that it delivers stanzas to the intended recipient in the order it receives them over the input stream from the routing server, treating stanzas addressed to the bare JID and the full JID of the intended recipient as equivalent for delivery purposes.
</li>
<li>Stanzas sent by one server to another server for direct processing by the server that is hosting the remote domain (e.g., stanzas addressed from &lt;im.example.com&gt; to &lt;example.net&gt;).
</li>
</ol><p>
      
</p>
<p>If the server's processing of a particular request could have an effect on its processing of subsequent data it might receive over that input stream (e.g., enforcement of communication policies), it MUST suspend processing of subsequent data until it has processed the request.
</p>
<p>In-order processing applies only to a single input stream.  Therefore, a server is not responsible for ensuring the coherence of data it receives across multiple input streams associated with the same local account (e.g., stanzas received over two different input streams from &lt;juliet@im.example.com/balcony&gt; and &lt;juliet@im.example.com/chamber&gt;) or the same remote domain (e.g., two different input streams negotiated by a remote domain; however, a server MAY close the stream with a &lt;conflict/&gt; stream error (<a class='info' href='#streams-error-conditions-conflict'>Section&nbsp;4.9.3.3<span> (</span><span class='info'>conflict</span><span>)</span></a>) if a remote server attempts to negotiate more than one stream, as described under <a class='info' href='#streams-error-conditions-conflict'>Section&nbsp;4.9.3.3<span> (</span><span class='info'>conflict</span><span>)</span></a>).
</p>
<a name="rules-gen"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.2"></a><h3>10.2.&nbsp;
General Considerations</h3>

<p>At high level, there are three primary considerations at play in server processing of XML stanzas, which sometimes are at odds but need to be managed in a consistent way:
</p>
<p>
        </p>
<ol class="text">
<li>It is good to deliver a stanza to the intended recipient if possible.
</li>
<li>If a stanza cannot be delivered, it is helpful to inform the sender.
</li>
<li>It is bad to facilitate directory harvesting attacks (<a class='info' href='#security-harvesting'>Section&nbsp;13.11<span> (</span><span class='info'>Directory Harvesting</span><span>)</span></a>) and presence leaks (<a class='info' href='#security-leaks-presence'>Section&nbsp;13.10.2<span> (</span><span class='info'>Presence Information</span><span>)</span></a>).
</li>
</ol><p>
      
</p>
<p>With regard to possible delivery-related attacks, the following points need to be kept in mind:
</p>
<p>
        </p>
<ol class="text">
<li>From the perspective of an attacker, there is little if any effective difference between the server's (i) delivering the stanza or storing it offline for later delivery (see <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>) and (ii) silently ignoring it (because an error is not returned immediately in any of those cases); therefore, in scenarios where a server delivers a stanza or places the stanza into offline storage for later delivery, it needs to silently ignore the stanza if that account does not exist.
</li>
<li>How a server processes stanzas sent to the bare JID &lt;localpart@domainpart&gt; has implications for directory harvesting, because an attacker could determine whether an account exists if the server responds differently depending on whether there is an account for a given bare JID.
</li>
<li>How a server processes stanzas sent to a full JID has implications for presence leaks, because an attacker could send requests to multiple full JIDs and receive different replies depending on whether the user has a device currently online at that full JID.  The use of randomized resourceparts (whether generated by the client or the server as described under <a class='info' href='#bind'>Section&nbsp;7<span> (</span><span class='info'>Resource Binding</span><span>)</span></a>) significantly helps to mitigate this attack, so it is of somewhat lesser concern than the directory harvesting attack.
</li>
</ol><p>
      
</p>
<p>Naturally, presence is not leaked if the entity to which a user's server returns an error already knows the user's presence or is authorized to do so (e.g., by means of a presence subscription or directed presence), and a server does not enable a directory harvesting attack if it returns an error to an entity that already knows if a user exists (e.g., because the entity is in the user's contact list); these matters are discussed more fully in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<a name="rules-noto"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.3"></a><h3>10.3.&nbsp;
No 'to' Address</h3>

<p>If the stanza possesses no 'to' attribute, the server MUST handle it directly on behalf of the entity that sent it, where the meaning of "handle it directly" depends on whether the stanza is message, presence, or IQ.  Because all stanzas received from other servers MUST possess a 'to' attribute, this rule applies only to stanzas received from a local entity (typically a client) that is connected to the server.
</p>
<a name="rules-noto-message"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.3.1"></a><h3>10.3.1.&nbsp;
Message</h3>

<p>If the server receives a message stanza with no 'to' attribute, it MUST treat the message as if the 'to' address were the bare JID &lt;localpart@domainpart&gt; of the sending entity.
</p>
<a name="rules-noto-presence"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.3.2"></a><h3>10.3.2.&nbsp;
Presence</h3>

<p>If the server receives a presence stanza with no 'to' attribute, it MUST broadcast it to the entities that are subscribed to the sending entity's presence, if applicable (<a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a> defines the semantics of such broadcasting for presence applications).
</p>
<a name="rules-noto-IQ"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.3.3"></a><h3>10.3.3.&nbsp;
IQ</h3>

<p>If the server receives an IQ stanza with no 'to' attribute, it MUST process the stanza on behalf of the account from which received the stanza, as follows:
</p>
<p>
          </p>
<ol class="text">
<li>If the IQ stanza is of type "get" or "set" and the server understands the namespace that qualifies the payload, the server MUST handle the stanza on behalf of the sending entity or return an appropriate error to the sending entity.  Although the meaning of "handle" is determined by the semantics of the qualifying namespace, in general the server will respond to the IQ stanza of type "get" or "set" by returning an appropriate IQ stanza of type "result" or "error", responding as if the server were the bare JID of the sending entity.  As an example, if the sending entity sends an IQ stanza of type "get" where the payload is qualified by the 'jabber:iq:roster' namespace (as described in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>), then the server will return the roster associated with the sending entity's bare JID to the particular resource of the sending entity that requested the roster.
</li>
<li>If the IQ stanza is of type "get" or "set" and the server does not understand the namespace that qualifies the payload, the server MUST return an error to the sending entity, which MUST be &lt;service-unavailable/&gt;.
</li>
<li>If the IQ stanza is of type "error" or "result", the server MUST handle the error or result in accordance with the payload of the associated IQ stanza or type "get" or "set" (if there is no such associated stanza, the server MUST ignore the error or result stanza).
</li>
</ol><p>
        
</p>
<a name="rules-remote"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.4"></a><h3>10.4.&nbsp;
Remote Domain</h3>

<p>If the domainpart of the JID contained in the 'to' attribute does not match one of the configured FQDNs of the server, the server SHOULD attempt to route the stanza to the remote domain (subject to local service provisioning and security policies regarding inter-domain communication, since such communication is OPTIONAL for any given deployment).  As described in the following sections, there are two possible cases.
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: These rules apply only client-to-server streams.  As described under <a class='info' href='#stanzas-attributes-to-s2s'>Section&nbsp;8.1.1.2<span> (</span><span class='info'>Server-to-Server Streams</span><span>)</span></a>, a server MUST NOT accept a stanza over a server-to-server stream if the domainpart of the JID in the 'to' attribute does not match an FQDN serviced by the receiving server.
</p>
</blockquote>

<a name="rules-remote-existing"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.4.1"></a><h3>10.4.1.&nbsp;
Existing Stream</h3>

<p>If a server-to-server stream already exists between the two domains, the sender's server SHOULD attempt to route the stanza to the authoritative server for the remote domain over the existing stream.
</p>
<a name="rules-remote-nostream"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.4.2"></a><h3>10.4.2.&nbsp;
No Existing Stream</h3>

<p>If there exists no server-to-server stream between the two domains, the sender's server will proceed as follows:
</p>
<p>
          </p>
<ol class="text">
<li>Resolve the FQDN of the remote domain (as described under <a class='info' href='#security-reuse-dns'>Section&nbsp;13.9.2<span> (</span><span class='info'>Use of DNS</span><span>)</span></a>).
</li>
<li>Negotiate a server-to-server stream between the two domains (as defined under <a class='info' href='#tls'>Section&nbsp;5<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a> and <a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>).
</li>
<li>Route the stanza to the authoritative server for the remote domain over the newly established stream.
</li>
</ol><p>
        
</p>
<a name="rules-remote-error"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.4.3"></a><h3>10.4.3.&nbsp;
Error Handling</h3>

<p>If routing of a stanza to the intended recipient's server is unsuccessful, the sender's server MUST return an error to the sender.  If resolution of the remote domain is unsuccessful, the stanza error MUST be &lt;remote-server-not-found/&gt; (<a class='info' href='#stanzas-error-conditions-remote-server-not-found'>Section&nbsp;8.3.3.16<span> (</span><span class='info'>remote-server-not-found</span><span>)</span></a>).  If resolution succeeds but streams cannot be negotiated, the stanza error MUST be &lt;remote-server-timeout/&gt; (<a class='info' href='#stanzas-error-conditions-remote-server-timeout'>Section&nbsp;8.3.3.17<span> (</span><span class='info'>remote-server-timeout</span><span>)</span></a>).
</p>
<p>If stream negotiation with the intended recipient's server is successful but the remote server cannot deliver the stanza to the recipient, the remote server MUST return an appropriate error to the sender by way of the sender's server.
</p>
<a name="rules-local"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.5"></a><h3>10.5.&nbsp;
Local Domain</h3>

<p>If the domainpart of the JID contained in the 'to' attribute matches one of the configured FQDNs of the server, the server MUST first determine if the FQDN is serviced by the server itself or by a specialized local service.  If the latter, the server MUST route the stanza to that service.  If the former, the server MUST proceed as follows.  However, the server MUST NOT route or "forward" the stanza to another domain, because it is the server's responsibility to process all stanzas for which the domainpart of the 'to' address matches one of the configured FQDNs of the server (among other things, this helps to prevent looping).
</p>
<a name="rules-local-domain"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.5.1"></a><h3>10.5.1.&nbsp;
domainpart</h3>

<p>If the JID contained in the 'to' attribute is of the form &lt;domainpart&gt;, then the server MUST either (a) handle the stanza as appropriate for the stanza kind or (b) return an error stanza to the sender.
</p>
<a name="rules-local-domainresource"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.5.2"></a><h3>10.5.2.&nbsp;
domainpart/resourcepart</h3>

<p>If the JID contained in the 'to' attribute is of the form &lt;domainpart/resourcepart&gt;, then the server MUST either (a) handle the stanza as appropriate for the stanza kind or (b) return an error stanza to the sender.
</p>
<a name="rules-local-barejid"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.5.3"></a><h3>10.5.3.&nbsp;
localpart@domainpart</h3>

<p>An address of this type is normally associated with an account on the server.  The following rules provide some general guidelines; more detailed rules in the context of instant messaging and presence applications are provided in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<a name="rules-local-barejid-nosuchuser"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.5.3.1"></a><h3>10.5.3.1.&nbsp;
No Such User</h3>

<p>If there is no local account associated with the &lt;localpart@domainpart&gt;, how the stanza is processed depends on the stanza type.
</p>
<p>
            </p>
<ul class="text">
<li>For a message stanza, the server MUST either (a) silently ignore the stanza or (b) return a &lt;service-unavailable/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-service-unavailable'>Section&nbsp;8.3.3.19<span> (</span><span class='info'>service-unavailable</span><span>)</span></a>) to the sender.
</li>
<li>For a presence stanza, the server SHOULD ignore the stanza (or behave as described in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</li>
<li>For an IQ stanza, the server MUST return a &lt;service-unavailable/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-service-unavailable'>Section&nbsp;8.3.3.19<span> (</span><span class='info'>service-unavailable</span><span>)</span></a>) to the sender.
</li>
</ul><p>
          
</p>
<a name="rules-local-barejid-userexists"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.5.3.2"></a><h3>10.5.3.2.&nbsp;
User Exists</h3>

<p>If the JID contained in the 'to' attribute is of the form &lt;localpart@domainpart&gt;, how the stanza is processed depends on the stanza type.
</p>
<p>
            </p>
<ul class="text">
<li>For a message stanza, if there exists at least one connected resource for the account then the server SHOULD deliver it to at least one of the connected resources.  If there exists no connected resource then the server MUST either (a) store the message offline for delivery when the account next has a connected resource or (b) return a &lt;service-unavailable/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-service-unavailable'>Section&nbsp;8.3.3.19<span> (</span><span class='info'>service-unavailable</span><span>)</span></a>).
</li>
<li>For a presence stanza, if there exists at least one connected resource that has sent initial presence (i.e., has a "presence session" as defined in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>) then the server SHOULD deliver it to such resources.  If there exists no connected resource then the server SHOULD ignore the stanza (or behave as described in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>).
</li>
<li>For an IQ stanza, the server MUST handle it directly on behalf of the intended recipient.
</li>
</ul><p>
          
</p>
<a name="rules-local-fulljid"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.10.5.4"></a><h3>10.5.4.&nbsp;
localpart@domainpart/resourcepart</h3>

<p>If the JID contained in the 'to' attribute is of the form &lt;localpart@domainpart/resourcepart&gt; and the user exists but there is no connected resource that exactly matches the full JID, the stanza SHOULD be processed as if the JID were of the form &lt;localpart@domainpart&gt; as described under <a class='info' href='#rules-local-barejid-userexists'>Section&nbsp;10.5.3.2<span> (</span><span class='info'>User Exists</span><span>)</span></a>.
</p>
<p>If the JID contained in the 'to' attribute is of the form &lt;localpart@domainpart/resourcepart&gt;, the user exists, and there is a connected resource that exactly matches the full JID, the server MUST deliver the stanza to that connected resource.
</p>
<a name="xml"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.11"></a><h3>11.&nbsp;
XML Usage</h3>

<a name="xml-restrictions"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.11.1"></a><h3>11.1.&nbsp;
XML Restrictions</h3>

<p>XMPP defines a class of data objects called XML streams as well as the behavior of computer programs that process XML streams.  XMPP is an application profile or restricted form of the Extensible Markup Language <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>, and a complete XML stream (including start and end stream tags) is a conforming XML document.
</p>
<p>However, XMPP does not deal with XML documents but with XML streams.  Because XMPP does not require the parsing of arbitrary and complete XML documents, there is no requirement that XMPP needs to support the full feature set of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>.  Furthermore, XMPP uses XML to define protocol data structures and extensions for the purpose of structured interactions between network entities and therefore adheres to the recommendations provided in <a class='info' href='#XML-GUIDE'>[XML&#8209;GUIDE]<span> (</span><span class='info'>Hollenbeck, S., Rose, M., and L. Masinter, &ldquo;Guidelines for the Use of Extensible Markup Language (XML) within IETF Protocols,&rdquo; January&nbsp;2003.</span><span>)</span></a> regarding restrictions on the use of XML in IETF protocols.  As a result, the following features of XML are prohibited in XMPP:
</p>
<p>
        </p>
<ul class="text">
<li>comments (as defined in Section 2.5 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>)
</li>
<li>processing instructions (Section 2.6 therein)
</li>
<li>internal or external DTD subsets (Section 2.8 therein)
</li>
<li>internal or external entity references (Section 4.2 therein) with the exception of the predefined entities (Section 4.6 therein)
</li>
</ul><p>
      
</p>
<p>An XMPP implementation MUST behave as follows with regard to these features:
</p>
<p>
        </p>
<ol class="text">
<li>An XMPP implementation MUST NOT inject characters matching such features into an XML stream.
</li>
<li>If an XMPP implementation receives characters matching such features over an XML stream, it MUST close the stream with a stream error, which SHOULD be &lt;restricted-xml/&gt; (<a class='info' href='#streams-error-conditions-restricted-xml'>Section&nbsp;4.9.3.18<span> (</span><span class='info'>restricted-xml</span><span>)</span></a>), although some existing implementations send &lt;bad-format/&gt; (<a class='info' href='#streams-error-conditions-bad-format'>Section&nbsp;4.9.3.1<span> (</span><span class='info'>bad-format</span><span>)</span></a>) instead.
</li>
</ol><p>
      
</p>
<a name="xml-ns"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.11.2"></a><h3>11.2.&nbsp;
XML Namespace Names and Prefixes</h3>

<p>XML namespaces (see <a class='info' href='#XML-NAMES'>[XML&#8209;NAMES]<span> (</span><span class='info'>Thompson, H., Hollander, D., Layman, A., Bray, T., and R. Tobin, &ldquo;Namespaces in XML 1.0 (Third Edition),&rdquo; December&nbsp;2009.</span><span>)</span></a>) are used within XMPP streams to create strict boundaries of data ownership.  The basic function of namespaces is to separate different vocabularies of XML elements that are structurally mixed together.  Ensuring that XMPP streams are namespace-aware enables any allowable XML to be structurally mixed with any data element within XMPP.  XMPP-specific rules for XML namespace names and prefixes are defined under <a class='info' href='#streams-ns'>Section&nbsp;4.8<span> (</span><span class='info'>XML Namespaces</span><span>)</span></a> for XML streams and <a class='info' href='#stanzas-extended'>Section&nbsp;8.4<span> (</span><span class='info'>Extended Content</span><span>)</span></a> for XML stanzas.
</p>
<a name="xml-wellformed"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.11.3"></a><h3>11.3.&nbsp;
Well-Formedness</h3>

<p>In XML, there are two varieties of well-formedness:
</p>
<p>
        </p>
<ul class="text">
<li>"XML-well-formedness" in accordance with the definition of "well-formed" from Section 2.1 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>.
</li>
<li>"Namespace-well-formedness" in accordance with the definition of "namespace-well-formed" from Section 7 of <a class='info' href='#XML-NAMES'>[XML&#8209;NAMES]<span> (</span><span class='info'>Thompson, H., Hollander, D., Layman, A., Bray, T., and R. Tobin, &ldquo;Namespaces in XML 1.0 (Third Edition),&rdquo; December&nbsp;2009.</span><span>)</span></a>.
</li>
</ul><p>
      
</p>
<p>The following rules apply:
</p>
<p>
        </p>
<ol class="text">
<li>An XMPP entity MUST NOT generate data that is not XML-well-formed.
</li>
<li>An XMPP entity MUST NOT accept data that is not XML-well-formed; instead it MUST close the stream over which the data was received with a &lt;not-well-formed/&gt; stream error (<a class='info' href='#streams-error-conditions-not-well-formed'>Section&nbsp;4.9.3.13<span> (</span><span class='info'>not-well-formed</span><span>)</span></a>).
</li>
<li>An XMPP entity MUST NOT generate data that is not namespace-well-formed.
</li>
<li>An XMPP entity MUST NOT accept data that is not namespace-well-formed (in particular, an XMPP server MUST NOT route or deliver data that is not namespace-well-formed); instead it MUST return either a &lt;not-acceptable/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-not-acceptable'>Section&nbsp;8.3.3.9<span> (</span><span class='info'>not-acceptable</span><span>)</span></a>) or close the stream with a &lt;not-well-formed/&gt; stream error (<a class='info' href='#streams-error-conditions-not-well-formed'>Section&nbsp;4.9.3.13<span> (</span><span class='info'>not-well-formed</span><span>)</span></a>), where it is preferable to close the stream with a stream error because accepting such data can open an entity to certain denial-of-service attacks.
</li>
</ol><p>
      
</p>
<p></p>
<blockquote class="text">
<p>Interoperability Note: Because these restrictions were underspecified in <a class='info' href='#RFC3920'>[RFC3920]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; October&nbsp;2004.</span><span>)</span></a>, it is possible that implementations based on that specification will send data that does not comply with these restrictions.
</p>
</blockquote>

<a name="xml-validation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.11.4"></a><h3>11.4.&nbsp;
Validation</h3>

<p>A server is not responsible for ensuring that XML data delivered to a connected client or routed to a peer server is valid, in accordance with the definition of "valid" provided in Section 2.8 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>.  An implementation MAY choose to accept or send only data that has been explicitly validated against the schemas provided in this document, but such behavior is OPTIONAL.  Clients are advised not to rely on the ability to send data that does not conform to the schemas, and SHOULD ignore any non-conformant elements or attributes on the incoming XML stream.
</p>
<p></p>
<blockquote class="text">
<p>Informational Note: The terms "valid" and "well-formed" are distinct in XML.
</p>
</blockquote>

<a name="xml-declaration"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.11.5"></a><h3>11.5.&nbsp;
Inclusion of XML Declaration</h3>

<p>Before sending a stream header, an implementation SHOULD send an XML declaration (matching the "XMLDecl" production from <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>).  Applications MUST follow the rules provided in <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a> regarding the format of the XML declaration and the circumstances under which the XML declaration is included.
</p>
<p>Because external markup declarations are prohibited in XMPP (as described under <a class='info' href='#xml-restrictions'>Section&nbsp;11.1<span> (</span><span class='info'>XML Restrictions</span><span>)</span></a>), the standalone document declaration (matching the "SDDecl" production from <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>) would have no meaning and therefore MUST NOT be included in an XML declaration sent over an XML stream.  If an XMPP entity receives an XML declaration containing a standalone document declaration set to a value of "no", the entity MUST either ignore the standalone document declaration or close the stream with a stream error, which SHOULD be &lt;restricted-xml/&gt; (<a class='info' href='#streams-error-conditions-restricted-xml'>Section&nbsp;4.9.3.18<span> (</span><span class='info'>restricted-xml</span><span>)</span></a>).
</p>
<a name="xml-encoding"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.11.6"></a><h3>11.6.&nbsp;
Character Encoding</h3>

<p>Implementations MUST support the UTF-8 transformation of Universal Character Set <a class='info' href='#UCS2'>[UCS2]<span> (</span><span class='info'>International Organization for Standardization, &ldquo;Information Technology - Universal Multiple-octet coded Character Set (UCS) - Amendment 2: UCS Transformation Format 8 (UTF-8),&rdquo; October&nbsp;1996.</span><span>)</span></a> characters, as needed for conformance with <a class='info' href='#CHARSETS'>[CHARSETS]<span> (</span><span class='info'>Alvestrand, H., &ldquo;IETF Policy on Character Sets and Languages,&rdquo; January&nbsp;1998.</span><span>)</span></a> and as defined in <a class='info' href='#UTF-8'>[UTF&#8209;8]<span> (</span><span class='info'>Yergeau, F., &ldquo;UTF-8, a transformation format of ISO 10646,&rdquo; November&nbsp;2003.</span><span>)</span></a>.  Implementations MUST NOT attempt to use any other encoding.  If one party to an XML stream detects that the other party has attempted to send XML data with an encoding other than UTF-8, it MUST close the stream with a stream error, which SHOULD be &lt;unsupported-encoding/&gt; (<a class='info' href='#streams-error-conditions-unsupported-encoding'>Section&nbsp;4.9.3.22<span> (</span><span class='info'>unsupported-encoding</span><span>)</span></a>), although some existing implementations send &lt;bad-format/&gt; (<a class='info' href='#streams-error-conditions-bad-format'>Section&nbsp;4.9.3.1<span> (</span><span class='info'>bad-format</span><span>)</span></a>) instead.
</p>
<p>Because it is mandatory for an XMPP implementation to support all and only the UTF-8 encoding and because UTF-8 always has the same byte order, an implementation MUST NOT send a byte order mark ("BOM") at the beginning of the data stream.  If an entity receives the <a class='info' href='#UNICODE'>[UNICODE]<span> (</span><span class='info'>The Unicode Consortium, &ldquo;The Unicode Standard, Version 6.0,&rdquo; 2010.</span><span>)</span></a> character U+FEFF anywhere in an XML stream (including as the first character of the stream), it MUST interpret that character as a zero width no-break space, not as a byte order mark.
</p>
<a name="xml-whitespace"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.11.7"></a><h3>11.7.&nbsp;
Whitespace</h3>

<p>Except where explicitly disallowed (e.g., during <a class='info' href='#tls'>TLS negotiation<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a> and <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>), either entity MAY send whitespace as separators between XML stanzas or between any other first-level elements sent over the stream.  One common use for sending such whitespace is explained under <a class='info' href='#streams-close'>Section&nbsp;4.4<span> (</span><span class='info'>Closing a Stream</span><span>)</span></a>.
</p>
<a name="xml-versions"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.11.8"></a><h3>11.8.&nbsp;
XML Versions</h3>

<p>XMPP is an application profile of XML 1.0.  A future version of XMPP might be defined in terms of higher versions of XML, but this specification defines XMPP only in terms of XML 1.0.
</p>
<a name="i18n"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.12"></a><h3>12.&nbsp;
Internationalization Considerations</h3>

<p>As specified under <a class='info' href='#xml-encoding'>Section&nbsp;11.6<span> (</span><span class='info'>Character Encoding</span><span>)</span></a>, XML streams MUST be encoded in UTF-8.
</p>
<p>As specified under <a class='info' href='#streams-attr'>Section&nbsp;4.7<span> (</span><span class='info'>Stream Attributes</span><span>)</span></a>, an XML stream SHOULD include an 'xml:lang' attribute specifying the default language for any XML character data that is intended to be presented to a human user.  As specified under <a class='info' href='#stanzas-attributes-lang'>Section&nbsp;8.1.5<span> (</span><span class='info'>xml:lang</span><span>)</span></a>, an XML stanza SHOULD include an 'xml:lang' attribute if the stanza contains XML character data that is intended to be presented to a human user.  A server SHOULD apply the default 'xml:lang' attribute to stanzas it routes or delivers on behalf of connected entities, and MUST NOT modify or delete 'xml:lang' attributes on stanzas it receives from other entities.
</p>
<p>Internationalization of XMPP addresses is specified in <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<a name="security"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13"></a><h3>13.&nbsp;
Security Considerations</h3>

<a name="security-fundamentals"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.1"></a><h3>13.1.&nbsp;
Fundamentals</h3>

<p>XMPP technologies are typically deployed using a decentralized client-server architecture.  As a result, several paths are possible when two XMPP entities need to communicate:
</p>
<p>
        </p>
<ol class="text">
<li>Both entities are servers.  In this case, the entities can establish a direct server-to-server stream between themselves.
</li>
<li>One entity is a server and the other entity is a client whose account is hosted on that server.  In this case, the entities can establish a direct client-to-server stream between themselves.
</li>
<li>Both entities are clients whose accounts are hosted on the same server.  In this case, the entities cannot establish a direct stream between themselves, but there is only one intermediate entity between them, whose policies they might understand and in which they might have some level of trust (e.g., the server might require the use of Transport Layer Security for all client connections).
</li>
<li>Both entities are clients but their accounts are hosted on different servers.  In this case, the entities cannot establish a direct stream between themselves and there are two intermediate entities between them; each client might have some trust in the server that hosts its account but might know nothing about the policies of the server to which the other client connects.
</li>
</ol><p>
      
</p>
<p>This specification covers only the security of a direct XML stream between two servers or between a client and a server (cases #1 and #2), where each stream can be considered a single "hop" along a communication path.  The goal of security for a multi-hop path (cases #3 and #4), although very desirable, is out of scope for this specification.
</p>
<p>In accordance with <a class='info' href='#SEC-GUIDE'>[SEC&#8209;GUIDE]<span> (</span><span class='info'>Rescorla, E. and B. Korver, &ldquo;Guidelines for Writing RFC Text on Security Considerations,&rdquo; July&nbsp;2003.</span><span>)</span></a>, this specification covers communication security (confidentiality, data integrity, and peer entity authentication), non-repudiation, and systems security (unauthorized usage, inappropriate usage, and denial of service).  We also discuss common security issues such as information leaks, firewalls, and directory harvesting, as well as best practices related to the reuse of technologies such as base 64, DNS, cryptographic hash functions, SASL, TLS, UTF-8, and XML.
</p>
<a name="security-threats"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.2"></a><h3>13.2.&nbsp;
Threat Model</h3>

<p>The threat model for XMPP is in essence the standard "Internet Threat Model" described in <a class='info' href='#SEC-GUIDE'>[SEC&#8209;GUIDE]<span> (</span><span class='info'>Rescorla, E. and B. Korver, &ldquo;Guidelines for Writing RFC Text on Security Considerations,&rdquo; July&nbsp;2003.</span><span>)</span></a>.  Attackers are assumed to be interested in and capable of launching the following attacks against unprotected XMPP systems:
</p>
<p>
        </p>
<ul class="text">
<li>Eavesdropping
</li>
<li>Sniffing passwords
</li>
<li>Breaking passwords through dictionary attacks
</li>
<li>Discovering usernames through directory harvesting attacks
</li>
<li>Replaying, inserting, deleting, or modifying stanzas
</li>
<li>Spoofing users
</li>
<li>Gaining unauthorized entry to a server or account
</li>
<li>Using a server or account inappropriately
</li>
<li>Denying service to other entities
</li>
<li>Subverting communication streams through man-in-the-middle attacks
</li>
<li>Gaining control over on-path servers
</li>
</ul><p>
      
</p>
<p>Where appropriate, the following sections describe methods for protecting against these threats.
</p>
<a name="security-layers"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.3"></a><h3>13.3.&nbsp;
Order of Layers</h3>

<p>The order of layers in which protocols MUST be stacked is as follows:
</p>
<p>
        </p>
<ol class="text">
<li>TCP
</li>
<li>TLS
</li>
<li>SASL
</li>
<li>XMPP
</li>
</ol><p>
      
</p>
<p>This order has important security implications, as described throughout these security considerations.
</p>
<p>Within XMPP, XML stanzas are further ordered on top of XML streams, as described under <a class='info' href='#streams'>Section&nbsp;4<span> (</span><span class='info'>XML Streams</span><span>)</span></a>.
</p>
<a name="security-confidentiality"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.4"></a><h3>13.4.&nbsp;
Confidentiality and Integrity</h3>

<p>The use of Transport Layer Security (TLS) with appropriate ciphersuites provides a reliable mechanism to ensure the confidentiality and integrity of data exchanged between a client and a server or between two servers.  Therefore, TLS can help to protect against eavesdropping, password sniffing, man-in-the-middle attacks, and stanza replays, insertion, deletion, and modification over an XML stream.  XMPP clients and servers MUST support TLS as defined under <a class='info' href='#tls'>Section&nbsp;5<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a>.
</p>
<p></p>
<blockquote class="text">
<p>Informational Note: The confidentiality and integrity of a stream can be protected by methods other than TLS, e.g., by means of a SASL mechanism that involves negotiation of a security layer.
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>Security Warning: The use of TLS in XMPP applies to a single stream.  Because XMPP is typically deployed using a distributed client-server architecture (as explained under <a class='info' href='#arch-network'>Section&nbsp;2.5<span> (</span><span class='info'>Distributed Network of Clients and Servers</span><span>)</span></a>), a stanza might traverse multiple streams, and not all of those streams might be TLS-protected.  For example, a stanza sent from a client with a session at one server (e.g., &lt;romeo@example.net/orchard&gt;) and intended for delivery to a client with a session at another server (e.g., &lt;juliet@example.com/balcony&gt;) will traverse three streams: (1) the stream from the sender's client to its server, (2) the stream from the sender's server to the recipient's server, and (3) the stream from the recipient's server to the recipient's client.  Furthermore, the stanza will be processed as cleartext within the sender's server and the recipient's server.  Therefore, even if the stream from the sender's client to its server is protected, the confidentiality and integrity of a stanza sent over that protected stream cannot be guaranteed when the stanza is processed by the sender's server, sent from the sender's server to the recipient's server, processed by the recipient's server, or sent from the recipient's server to the recipient's client.  Only a robust technology for end-to-end encryption could ensure the confidentiality and integrity of a stanza as it traverses all of the "hops" along a communication path (e.g., a technology that meets the requirements defined in <a class='info' href='#E2E-REQS'>[E2E&#8209;REQS]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Requirements for End-to-End Encryption in the Extensible Messaging and Presence Protocol (XMPP),&rdquo; March&nbsp;2010.</span><span>)</span></a>).  Unfortunately, the XMPP community has so far failed to produce an end-to-end encryption technology that might be suitable for widespread implementation and deployment, and definition of such a technology is out of scope for this document.
</p>
</blockquote>

<a name="security-authentication"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.5"></a><h3>13.5.&nbsp;
Peer Entity Authentication</h3>

<p>The use of the Simple Authentication and Security Layer (SASL) for authentication provides a reliable mechanism for peer entity authentication.  Therefore, SASL helps to protect against user spoofing, unauthorized usage, and man-in-the middle attacks.  XMPP clients and servers MUST support SASL as defined under <a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>.
</p>
<a name="security-strong"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.6"></a><h3>13.6.&nbsp;
Strong Security</h3>

<p><a class='info' href='#STRONGSEC'>[STRONGSEC]<span> (</span><span class='info'>Schiller, J., &ldquo;Strong Security Requirements for Internet Engineering Task Force Standard Protocols,&rdquo; August&nbsp;2002.</span><span>)</span></a> defines "strong security" and its importance to communication over the Internet.  For the purpose of XMPP communication over client-to-server and server-to-server streams, the term "strong security" refers to the use of security technologies that provide both mutual authentication and integrity checking (e.g., a combination of TLS encryption and SASL authentication using appropriate SASL mechanisms).
</p>
<p>Implementations MUST support strong security.  Service provisioning SHOULD use strong security.
</p>
<p>An implementation SHOULD make it possible for an end user or service administrator to provision a deployment with specific trust anchors for the certificate presented by a connecting entity (either client or server); when an application is thus provisioned, it MUST NOT use a generic PKI trust store to authenticate the connecting entity.  More detailed rules and guidelines regarding certificate validation are provided in the next section.
</p>
<p>The initial stream and the response stream MUST be secured separately, although security in both directions MAY be established via mechanisms that provide mutual authentication.
</p>
<a name="security-certificates"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7"></a><h3>13.7.&nbsp;
Certificates</h3>

<p>Channel encryption of an XML stream using Transport Layer Security as described under <a class='info' href='#tls'>Section&nbsp;5<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a>, and in some cases also authentication as described under <a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>, is commonly based on a PKIX certificate presented by the receiving entity (or, in the case of mutual certificate authentication, both the receiving entity and the initiating entity).  This section describes best practices regarding the generation of PKIX certificates to be presented by XMPP entities and the verification of PKIX certificates presented by XMPP entities.
</p>
<p>In general, the following sections rely on and extend the rules and guidelines provided in the <a class='info' href='#PKIX'>[PKIX]<span> (</span><span class='info'>Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, &ldquo;Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile,&rdquo; May&nbsp;2008.</span><span>)</span></a> profile of <a class='info' href='#X509'>[X509]<span> (</span><span class='info'>International Telecommunications Union, &ldquo;Information technology - Open Systems Interconnection - The Directory: Public-key and attribute certificate frameworks,&rdquo; March&nbsp;2000.</span><span>)</span></a>, and in <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a>.  The reader is referred to those specifications for a detailed understanding of PKIX certificates and their use in TLS.
</p>
<a name="security-certificates-generation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.1"></a><h3>13.7.1.&nbsp;
Certificate Generation</h3>

<a name="security-certificates-generation-general"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.1.1"></a><h3>13.7.1.1.&nbsp;
General Considerations</h3>

<p>The following rules apply to end entity public key certificates that are issued to XMPP servers or clients:
</p>
<p>
            </p>
<ol class="text">
<li>The certificate MUST conform to <a class='info' href='#PKIX'>[PKIX]<span> (</span><span class='info'>Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, &ldquo;Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile,&rdquo; May&nbsp;2008.</span><span>)</span></a>.
</li>
<li>The certificate MUST NOT contain a basicConstraints extension with the cA boolean set to TRUE.
</li>
<li>The subject field MUST NOT be null.
</li>
<li>The signatureAlgorithm SHOULD be the PKCS #1 version 1.5 signature algorithm with SHA-256 as defined by <a class='info' href='#PKIX-ALGO'>[PKIX&#8209;ALGO]<span> (</span><span class='info'>Jonsson, J. and B. Kaliski, &ldquo;Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography Specifications Version 2.1,&rdquo; February&nbsp;2003.</span><span>)</span></a>, or a stronger algorithm if available.
</li>
<li>The certificate SHOULD include an Authority Information Access (AIA) extension that specifies the address of an Online Certificate Status Protocol <a class='info' href='#OCSP'>[OCSP]<span> (</span><span class='info'>Myers, M., Ankney, R., Malpani, A., Galperin, S., and C. Adams, &ldquo;X.509 Internet Public Key Infrastructure Online Certificate Status Protocol - OCSP,&rdquo; June&nbsp;1999.</span><span>)</span></a> responder (if not, a relying party would need to fall back on the use of Certificate Revocation Lists (CRLs) as described in <a class='info' href='#PKIX'>[PKIX]<span> (</span><span class='info'>Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, &ldquo;Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile,&rdquo; May&nbsp;2008.</span><span>)</span></a>).
</li>
</ol><p>
          
</p>
<p>The following rules apply to certification authority (CA) certificates that are used by issuers of XMPP end entity certificates:
</p>
<p>
            </p>
<ol class="text">
<li>The certificate MUST conform to <a class='info' href='#PKIX'>[PKIX]<span> (</span><span class='info'>Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, &ldquo;Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile,&rdquo; May&nbsp;2008.</span><span>)</span></a>.
</li>
<li>The certificate MUST contain a keyUsage extension with the digitalSignature bit set.
</li>
<li>The subject field MUST NOT be null.
</li>
<li>The signatureAlgorithm SHOULD be the PKCS #1 version 1.5
signature algorithm with SHA-256 as defined by <a class='info' href='#PKIX-ALGO'>[PKIX&#8209;ALGO]<span> (</span><span class='info'>Jonsson, J. and B. Kaliski, &ldquo;Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography Specifications Version 2.1,&rdquo; February&nbsp;2003.</span><span>)</span></a>, or a
stronger algorithm if available.
</li>
<li>For issuers of public key certificates, the issuer's certificate MUST contain a basicConstraints extension with the cA boolean set to TRUE.
</li>
</ol><p>
          
</p>
<a name="security-certificates-generation-server"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.1.2"></a><h3>13.7.1.2.&nbsp;
Server Certificates</h3>

<a name="security-certificates-generation-server-rules"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.1.2.1"></a><h3>13.7.1.2.1.&nbsp;
Rules</h3>

<p>In a PKIX certificate to be presented by an XMPP server (i.e., a "server certificate"), the certificate SHOULD include one or more XMPP addresses (i.e., domainparts) associated with XMPP services hosted at the server.  The rules and guidelines defined in <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a> apply to XMPP server certificates, with the following XMPP-specific considerations:
</p>
<p>
              </p>
<ul class="text">
<li>Support for the DNS-ID identifier type <a class='info' href='#PKIX'>[PKIX]<span> (</span><span class='info'>Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, &ldquo;Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile,&rdquo; May&nbsp;2008.</span><span>)</span></a> is REQUIRED in XMPP client and server software implementations.  Certification authorities that issue XMPP-specific certificates MUST support the DNS-ID identifier type.  XMPP service providers SHOULD include the DNS-ID identifier type in certificate requests.
</li>
<li>Support for the SRV-ID identifier type <a class='info' href='#PKIX-SRV'>[PKIX&#8209;SRV]<span> (</span><span class='info'>Santesson, S., &ldquo;Internet X.509 Public Key Infrastructure Subject Alternative Name for Expression of Service Name,&rdquo; August&nbsp;2007.</span><span>)</span></a> is REQUIRED for XMPP client and server software implementations (for verification purposes XMPP client implementations need to support only the "_xmpp-client" service type, whereas XMPP server implementations need to support both the "_xmpp-client" and "_xmpp-server" service types).  Certification authorities that issue XMPP-specific certificates SHOULD support the SRV-ID identifier type.  XMPP service providers SHOULD include the SRV-ID identifier type in certificate requests.
</li>
<li>Support for the XmppAddr identifier type (specified under <a class='info' href='#security-certificates-generation-xmppaddr'>Section&nbsp;13.7.1.4<span> (</span><span class='info'>XmppAddr Identifier Type</span><span>)</span></a>) is encouraged in XMPP client and server software implementations for the sake of backward-compatibility, but is no longer encouraged in certificates issued by certification authorities or requested by XMPP service providers.
</li>
<li>DNS domain names in server certificates MAY contain the wildcard character '*' as the complete left-most label within the identifier.
</li>
</ul><p>
            
</p>
<a name="security-certificates-generation-server-examples"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.1.2.2"></a><h3>13.7.1.2.2.&nbsp;
Examples</h3>

<p>For our first (relatively simple) example, consider a company called "Example Products, Inc."  It hosts an XMPP service at "im.example.com" (i.e., user addresses at the service are of the form "user@im.example.com"), and SRV lookups for the xmpp-client and xmpp-server services at "im.example.com" yield one machine, called "x.example.com", as follows:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
_xmpp-client._tcp.im.example.com. 400 IN SRV 20 0 5222 x.example.com
_xmpp-server._tcp.im.example.com. 400 IN SRV 20 0 5269 x.example.com
</pre></div>
<p>The certificate presented by x.example.com contains the following representations:
</p>
<p>
              </p>
<ul class="text">
<li>An otherName type of SRVName (id-on-dnsSRV) containing an IA5String (ASCII) string of "_xmpp-client.im.example.com"
</li>
<li>An otherName type of SRVName (id-on-dnsSRV) containing an IA5String (ASCII) string of "_xmpp-server.im.example.com"
</li>
<li>A dNSName containing an ASCII string of "im.example.com"
</li>
<li>An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 string of "im.example.com"
</li>
<li>A CN containing an ASCII string of "Example Products, Inc."
</li>
</ul><p>
            
</p>
<p>For our second (more complex) example, consider an ISP called "Example Internet Services".  It hosts an XMPP service at "example.net" (i.e., user addresses at the service are of the form "user@example.net"), but SRV lookups for the xmpp-client and xmpp-server services at "example.net" yield two machines ("x1.example.net" and "x2.example.net"), as follows:
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
_xmpp-client._tcp.example.net. 68400 IN SRV 20 0 5222 x1.example.net.
_xmpp-client._tcp.example.net. 68400 IN SRV 20 0 5222 x2.example.net.
_xmpp-server._tcp.example.net. 68400 IN SRV 20 0 5269 x1.example.net.
_xmpp-server._tcp.example.net. 68400 IN SRV 20 0 5269 x2.example.net.
</pre></div>
<p>Example Internet Services also hosts chatrooms at chat.example.net, and provides an xmpp-server SRV record for that service as well (thus enabling entities from remote domains to access that service).  It also might provide other such services in the future, so it wishes to represent a wildcard in its certificate to handle such growth.
</p>
<p>The certificate presented by either x1.example.net or x2.example.net contains the following representations:
</p>
<p>
              </p>
<ul class="text">
<li>An otherName type of SRVName (id-on-dnsSRV) containing an IA5String (ASCII) string of "_xmpp-client.example.net"
</li>
<li>An otherName type of SRVName (id-on-dnsSRV) containing an IA5String (ASCII) string of "_xmpp-server.example.net"
</li>
<li>An otherName type of SRVName (id-on-dnsSRV) containing an IA5String (ASCII) string of "_xmpp-server.chat.example.net"
</li>
<li>A dNSName containing an ASCII string of "example.net"
</li>
<li>A dNSName containing an ASCII string of "*.example.net"
</li>
<li>An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 string of "example.net"
</li>
<li>An otherName type of XmppAddr (id-on-xmppAddr) containing a UTF-8 string of "chat.example.net"
</li>
<li>A CN containing an ASCII string of "Example Internet Services"
</li>
</ul><p>
            
</p>
<a name="security-certificates-generation-client"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.1.3"></a><h3>13.7.1.3.&nbsp;
Client Certificates</h3>

<p>In a PKIX certificate to be presented by an XMPP client controlled by a human user (i.e., a "client certificate"), it is RECOMMENDED for the certificate to include one or more JIDs associated with an XMPP user.  If included, a JID MUST be represented as an XmppAddr as specified under <a class='info' href='#security-certificates-generation-xmppaddr'>Section&nbsp;13.7.1.4<span> (</span><span class='info'>XmppAddr Identifier Type</span><span>)</span></a>.
</p>
<a name="security-certificates-generation-xmppaddr"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.1.4"></a><h3>13.7.1.4.&nbsp;
XmppAddr Identifier Type</h3>

<p>The XmppAddr identifier type is a UTF8String within an otherName entity inside the subjectAltName, using the <a class='info' href='#ASN.1'>[ASN.1]<span> (</span><span class='info'>CCITT, &ldquo;Recommendation X.208: Specification of Abstract Syntax Notation One (ASN.1),&rdquo; 1988.</span><span>)</span></a> Object Identifier "id-on-xmppAddr" specified below.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
id-pkix OBJECT IDENTIFIER ::= { iso(1) identified-organization(3)
        dod(6) internet(1) security(5) mechanisms(5) pkix(7) }

id-on  OBJECT IDENTIFIER ::= { id-pkix 8 }  -- other name forms

id-on-xmppAddr  OBJECT IDENTIFIER ::= { id-on 5 }

XmppAddr ::= UTF8String
</pre></div>
<p>As an alternative to the "id-on-xmppAddr" notation, this Object Identifier MAY be represented in dotted display format (i.e., "1.3.6.1.5.5.7.8.5") or in the Uniform Resource Name notation specified in <a class='info' href='#URN-OID'>[URN&#8209;OID]<span> (</span><span class='info'>Mealling, M., &ldquo;A URN Namespace of Object Identifiers,&rdquo; February&nbsp;2001.</span><span>)</span></a> (i.e., "urn:oid:1.3.6.1.5.5.7.8.5").
</p>
<p>Thus for example the JID &lt;juliet@im.example.com&gt; as included in a certificate could be formatted in any of the following three ways:
</p>
<p>
            </p>
<blockquote class="text"><dl>
<dt>id-on-xmppAddr:</dt>
<dd>subjectAltName=otherName:id-on-xmppAddr;UTF8:juliet@im.example.com
</dd>
<dt>dotted display format:</dt>
<dd>subjectAltName=otherName:1.3.6.1.5.5.7.8.5;UTF8:juliet@im.example.com
</dd>
<dt>URN notation:</dt>
<dd>subjectAltName=otherName:urn:oid:1.3.6.1.5.5.7.8.5;UTF8:juliet@im.example.com
</dd>
</dl></blockquote><p>
          
</p>
<p>Use of the "id-on-xmppAddr" format is RECOMMENDED in the generation of certificates, but all three formats MUST be supported for the purpose of certificate validation.
</p>
<p>The "id-on-xmppAddr" object identifier MAY be used in conjunction with the extended key usage extension specified in Section 4.2.1.12 of <a class='info' href='#PKIX'>[PKIX]<span> (</span><span class='info'>Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, &ldquo;Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile,&rdquo; May&nbsp;2008.</span><span>)</span></a> in order to explicitly define and limit the intended use of a certificate to the XMPP network.
</p>
<a name="security-certificates-validation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.2"></a><h3>13.7.2.&nbsp;
Certificate Validation</h3>

<p>When an XMPP entity is presented with a server certificate or client certificate by a peer for the purpose of encryption or authentication of XML streams as described under <a class='info' href='#tls'>Section&nbsp;5<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a> and <a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>, the entity MUST attempt to validate the certificate to determine if the certificate will be considered a "trusted certificate", i.e., a certificate that is acceptable for encryption and/or authentication in accordance with the XMPP entity's local service policies or configured settings.
</p>
<p>For both server certificates and client certificates, the validating entity MUST do the following:
</p>
<p>
          </p>
<ol class="text">
<li>Attempt to verify the integrity of the certificate.
</li>
<li>Attempt to verify that the certificate has been properly signed by the issuing Certificate Authority.
</li>
<li>Attempt to validate the full certification path.
</li>
<li>Check the rules for end entity public key certificates and certification authority certificates specified under <a class='info' href='#security-certificates-generation-general'>Section&nbsp;13.7.1.1<span> (</span><span class='info'>General Considerations</span><span>)</span></a> for the general case and under either <a class='info' href='#security-certificates-generation-server'>Section&nbsp;13.7.1.2<span> (</span><span class='info'>Server Certificates</span><span>)</span></a> or <a class='info' href='#security-certificates-generation-client'>Section&nbsp;13.7.1.3<span> (</span><span class='info'>Client Certificates</span><span>)</span></a> for XMPP server or client certificates, respectively.
</li>
<li>Check certificate revocation messages via Certificate Revocation Lists (CRLs), the Online Certificate Status Protocol <a class='info' href='#OCSP'>[OCSP]<span> (</span><span class='info'>Myers, M., Ankney, R., Malpani, A., Galperin, S., and C. Adams, &ldquo;X.509 Internet Public Key Infrastructure Online Certificate Status Protocol - OCSP,&rdquo; June&nbsp;1999.</span><span>)</span></a>, or both.
</li>
</ol><p>
        
</p>
<p>If any of those validation attempts fail, the validating entity MUST unilaterally terminate the session.
</p>
<p>The following sections describe the additional identity verification rules that apply to server-to-server and client-to-server streams.
</p>
<p>Once the identity of the stream peer has been validated, the validating entity SHOULD also correlate the validated identity with the 'from' address (if any) of the stream header it received from the peer.  If the two identities do not match, the validating entity SHOULD terminate the connection attempt (however, there might be good reasons why the identities do not match, as described under <a class='info' href='#streams-attr-from'>Section&nbsp;4.7.1<span> (</span><span class='info'>from</span><span>)</span></a>).
</p>
<a name="security-certificates-validation-server"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.2.1"></a><h3>13.7.2.1.&nbsp;
Server Certificates</h3>

<p>For server certificates, the rules and guidelines defined in <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a> apply, with the proviso that the XmppAddr identifier specified under <a class='info' href='#security-certificates-generation-xmppaddr'>Section&nbsp;13.7.1.4<span> (</span><span class='info'>XmppAddr Identifier Type</span><span>)</span></a> is allowed as a reference identifier.
</p>
<p>The identities to be checked are set as follows:
</p>
<p>
            </p>
<ul class="text">
<li>The initiating entity sets the source domain of its reference
     identifiers to the 'to' address it communicates in the initial stream
     header; i.e., this is the identity it expects the receiving entity to
     provide in a PKIX certificate.
</li>
<li>The receiving entity sets the source domain of its reference
     identifiers to the 'from' address communicated by the initiating
     entity in the initial stream header; i.e., this is the identity that
     the initiating entity is trying to assert.
</li>
</ul><p>
          
</p>
<p>
  In the case of server-to-server communication, the matching procedure
  described in <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a> can be performed by an application server
  (receiving entity) when verifying an incoming server-to-server
  connection from a peer server (initiating entity).  In this case, the
  receiving entity verifies the identity of the initiating entity and
  uses as the source domain of its reference identifiers the DNS domain
  name asserted by the initiating entity in the 'from' attribute of the
  initial stream header.  However, the matching procedure described in
  <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a> remains unchanged and is applied in the same way.

</p>
<a name="security-certificates-validation-client"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.2.2"></a><h3>13.7.2.2.&nbsp;
Client Certificates</h3>

<p>When an XMPP server validates a certificate presented by a client, there are three possible cases, as discussed in the following sections.
</p>
<p>The identities to be checked are set as follows:
</p>
<p>
            </p>
<ul class="text">
<li>
     The client sets the source domain of its reference identifiers to
     the 'to' address it communicates in the initial stream header;
     i.e., this is the identity it expects the server to provide in a
     PKIX certificate.

</li>
<li>
     The server sets the bare JID of its reference identifiers to the
     'from' address communicated by the initiating entity in the
     initial stream header; i.e., this is the identity that the client
     is trying to assert.

</li>
</ul><p>
          
</p>
<a name="security-certificates-validation-client-case1"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.2.2.1"></a><h3>13.7.2.2.1.&nbsp;
Case #1</h3>

<p>If the client certificate appears to be certified by a certification path terminating in a trust anchor (as described in Section 6.1 of <a class='info' href='#PKIX'>[PKIX]<span> (</span><span class='info'>Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, &ldquo;Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile,&rdquo; May&nbsp;2008.</span><span>)</span></a>), the server MUST check the certificate for any instances of the XmppAddr as described under <a class='info' href='#security-certificates-generation-xmppaddr'>Section&nbsp;13.7.1.4<span> (</span><span class='info'>XmppAddr Identifier Type</span><span>)</span></a>.  There are three possible sub-cases:
</p>
<p>
              </p>
<blockquote class="text"><dl>
<dt>Sub-Case #1:</dt>
<dd>The server finds one XmppAddr for which the domainpart of the represented JID matches one of the configured FQDNs of the server; the server SHOULD use this represented JID as the validated identity of the client.
</dd>
<dt>Sub-Case #2:</dt>
<dd>The server finds more than one XmppAddr for which the domainpart of the represented JID matches one of the configured FQDNs of the server; the server SHOULD use one of these represented JIDs as the validated identity of the client, choosing among them based on the bare JID contained in the 'from' address of the initial stream header (if any), based on the domainpart contained in the 'to' address of the initial stream header, or in accordance with local service policies (such as a lookup in a user database based on other information contained in the client certificate).
</dd>
<dt>Sub-Case #3:</dt>
<dd>The server finds no XmppAddrs, or finds at least one XmppAddr but the domainpart of the represented JID does not match one of the configured FQDNs of the server; the server MUST NOT use the represented JID (if any) as the validated identity of the client but instead MUST validate the identity of the client using other means in accordance with local service policies (such as a lookup in a user database based on other information contained in the client certificate).  If the identity cannot be so validated, the server MAY abort the validation process and terminate the TLS negotiation.
</dd>
</dl></blockquote><p>
            
</p>
<a name="security-certificates-validation-client-case2"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.2.2.2"></a><h3>13.7.2.2.2.&nbsp;
Case #2</h3>

<p>If the client certificate is certified by a Certificate Authority not known to the server, the server MUST proceed as under Case #1, Sub-Case #3.
</p>
<a name="security-certificates-validation-client-case3"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.2.2.3"></a><h3>13.7.2.2.3.&nbsp;
Case #3</h3>

<p>If the client certificate is self-signed, the server MUST proceed as under Case #1, Sub-Case #3.
</p>
<a name="security-certificates-validation-streams"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.2.3"></a><h3>13.7.2.3.&nbsp;
Checking of Certificates in Long-Lived Streams</h3>

<p>Because XMPP uses long-lived XML streams, it is possible that a certificate presented during stream negotiation might expire or be revoked while the stream is still live (this is especially relevant in the context of server-to-server streams).  Therefore, each party to a long-lived stream SHOULD:
</p>
<p>
            </p>
<ol class="text">
<li>Cache the expiration date of the certificate presented by the other party and any certificates on which that certificate depends (such as a root or intermediate certificate for a certification authority), and close the stream when any such certificate expires, with a stream error of &lt;reset/&gt; (<a class='info' href='#streams-error-conditions-reset'>Section&nbsp;4.9.3.16<span> (</span><span class='info'>reset</span><span>)</span></a>).
</li>
<li>Periodically query the Online Certificate Status Protocol <a class='info' href='#OCSP'>[OCSP]<span> (</span><span class='info'>Myers, M., Ankney, R., Malpani, A., Galperin, S., and C. Adams, &ldquo;X.509 Internet Public Key Infrastructure Online Certificate Status Protocol - OCSP,&rdquo; June&nbsp;1999.</span><span>)</span></a> responder listed in the Authority Information Access (AIA) extension of the certificate presented by the other party and any certificates on which that certificate depends (such as a root or intermediate certificate for a certification authority), and close the stream if any such certificate has been revoked, with a stream error of &lt;reset/&gt; (<a class='info' href='#streams-error-conditions-reset'>Section&nbsp;4.9.3.16<span> (</span><span class='info'>reset</span><span>)</span></a>).  It is RECOMMENDED to query the OSCP responder at or near the time communicated via the nextUpdate field received in the OCSP response or, if the nextUpdate field is not set, to query every 24 hours.
</li>
</ol><p>
          
</p>
<p>After the stream is closed, the initiating entity from the closed stream will need to reconnect and the receiving entity will need to authenticate the initiating entity based on whatever certificate it presents during negotiation of the new stream.
</p>
<a name="security-certificates-validation-extensions"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.7.2.4"></a><h3>13.7.2.4.&nbsp;
Use of Certificates in XMPP Extensions</h3>

<p>Certificates MAY be used in extensions to XMPP for the purpose of application-layer encryption or authentication above the level of XML streams (e.g., for end-to-end encryption).  Such extensions will define their own certificate handling rules.  At a minimum, such extensions are encouraged to remain consistent with the rules defined in this specification, specifying additional rules only when necessary.
</p>
<a name="security-mti"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.8"></a><h3>13.8.&nbsp;
Mandatory-to-Implement TLS and SASL Technologies</h3>

<p>The following TLS ciphersuites and SASL mechanisms are mandatory-to-implement (naturally, implementations MAY support other ciphersuites and mechanisms as well).  For security considerations related to TLS ciphersuites, see <a class='info' href='#security-reuse-sasl'>Section&nbsp;13.9.4<span> (</span><span class='info'>Use of SASL</span><span>)</span></a> and <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a>.  For security considerations related to SASL mechanisms, see <a class='info' href='#security-reuse-sasl'>Section&nbsp;13.9.4<span> (</span><span class='info'>Use of SASL</span><span>)</span></a>, <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a>, and specifications for particular SASL mechanisms such as <a class='info' href='#SCRAM'>[SCRAM]<span> (</span><span class='info'>Newman, C., Menon-Sen, A., Melnikov, A., and N. Williams, &ldquo;Salted Challenge Response Authentication Mechanism (SCRAM) SASL and GSS-API Mechanisms,&rdquo; July&nbsp;2010.</span><span>)</span></a>, <a class='info' href='#DIGEST-MD5'>[DIGEST&#8209;MD5]<span> (</span><span class='info'>Leach, P. and C. Newman, &ldquo;Using Digest Authentication as a SASL Mechanism,&rdquo; May&nbsp;2000.</span><span>)</span></a>, and <a class='info' href='#PLAIN'>[PLAIN]<span> (</span><span class='info'>Zeilenga, K., &ldquo;The PLAIN Simple Authentication and Security Layer (SASL) Mechanism,&rdquo; August&nbsp;2006.</span><span>)</span></a>.
</p>
<a name="security-mti-auth"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.8.1"></a><h3>13.8.1.&nbsp;
For Authentication Only</h3>

<p>For authentication only, servers and clients MUST support
        the SASL Salted Challenge Response Authentication Mechanism
        <a class='info' href='#SCRAM'>[SCRAM]<span> (</span><span class='info'>Newman, C., Menon-Sen, A., Melnikov, A., and N. Williams, &ldquo;Salted Challenge Response Authentication Mechanism (SCRAM) SASL and GSS-API Mechanisms,&rdquo; July&nbsp;2010.</span><span>)</span></a> -- in particular, the SCRAM-SHA-1 and SCRAM-SHA-1-PLUS variants.
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: Even though it is possible to complete authentication only without confidentiality, it is RECOMMENDED for servers and clients to protect the stream with TLS before attempting authentication with SASL, both to help protect the information exchanged during SASL negotiation and to help prevent certain downgrade attacks as described under <a class='info' href='#security-reuse-sasl'>Section&nbsp;13.9.4<span> (</span><span class='info'>Use of SASL</span><span>)</span></a> and <a class='info' href='#security-reuse-tls'>Section&nbsp;13.9.5<span> (</span><span class='info'>Use of TLS</span><span>)</span></a>.  Even if TLS is used, implementations SHOULD also enforce channel binding as described under <a class='info' href='#security-reuse-sasl'>Section&nbsp;13.9.4<span> (</span><span class='info'>Use of SASL</span><span>)</span></a>.
</p>
</blockquote>

<p></p>
<blockquote class="text">
<p>Interoperability Note: The SCRAM-SHA-1 or SASL-SCRAM-SHA-1-PLUS variants of the SCRAM mechanism replace the SASL DIGEST-MD5 mechanism as XMPP's mandatory-to-implement password-based method for authentication only.  For backward-compatibility with existing deployed infrastructure, implementations are encouraged to continue supporting the DIGEST-MD5 mechanism as specified in <a class='info' href='#DIGEST-MD5'>[DIGEST&#8209;MD5]<span> (</span><span class='info'>Leach, P. and C. Newman, &ldquo;Using Digest Authentication as a SASL Mechanism,&rdquo; May&nbsp;2000.</span><span>)</span></a>; however, there are known interoperability issues with DIGEST-MD5 that make it impractical in the long term.
</p>
</blockquote>

<a name="security-mti-conf"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.8.2"></a><h3>13.8.2.&nbsp;
For Confidentiality Only</h3>

<p>For confidentiality only, servers MUST support TLS with the TLS_RSA_WITH_AES_128_CBC_SHA ciphersuite.
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: Because a connection with confidentiality only has weaker security properties than a connection with both confidentiality and authentication, it is RECOMMENDED for servers and clients to prefer connections with both qualities (e.g., by protecting the stream with TLS before attempting authentication with SASL).  In practice, confidentiality only is employed merely for server-to-server connections when the peer server does not present a trusted certificate and the servers use Server Dialback <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a> for weak identity verification, but TLS with confidentiality only is still desirable to protect the connection against casual eavesdropping.
</p>
</blockquote>

<a name="security-mti-bothpass"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.8.3"></a><h3>13.8.3.&nbsp;
For Confidentiality and Authentication with Passwords</h3>

<p>For both confidentiality and authentication with passwords, servers and clients MUST implement TLS with the TLS_RSA_WITH_AES_128_CBC_SHA ciphersuite plus SASL SCRAM, in particular the SCRAM&#8209;SHA&#8209;1 and SCRAM&#8209;SHA&#8209;1&#8209;PLUS variants (with SCRAM&#8209;SHA1&#8209;PLUS being preferred, as described under <a class='info' href='#security-reuse-sasl'>Section&nbsp;13.9.4<span> (</span><span class='info'>Use of SASL</span><span>)</span></a>).
</p>
<p>As further explained in the following Security Warning, in certain circumstances a server MAY offer TLS with the TLS_RSA_WITH_AES_128_CBC_SHA ciphersuite plus SASL PLAIN when it is not possible to offer more secure alternatives; in addition, clients SHOULD implement PLAIN over TLS in order to maximize interoperability with servers that are not able to deploy more secure alternatives.
</p>
<p></p>
<blockquote class="text">
<p>Security Warning: In practice, many
        servers offer, and many clients use, TLS plus SASL PLAIN.  The
        SCRAM-SHA-1 and especially SCRAM-SHA-1-PLUS variants of the
        SCRAM mechanism are strongly preferred over the PLAIN
        mechanism because of their superior security properties
        (including for SCRAM-SHA-1-PLUS the ability to enforce channel
        binding as described under
        <a class='info' href='#security-reuse-sasl'>Section&nbsp;13.9.4<span> (</span><span class='info'>Use of SASL</span><span>)</span></a>).  A client SHOULD treat
        TLS plus SASL PLAIN as a technology of last resort to be used
        only when interacting with a server that does not offer SCRAM
        (or other alternatives that are more secure than TLS plus SASL
        PLAIN), MUST prefer more secure mechanisms (e.g., EXTERNAL,
        SCRAM-SHA-1-PLUS, SCRAM-SHA-1, or the older DIGEST-MD5
        mechanism) to the PLAIN mechanism, and MUST NOT use the PLAIN
        mechanism if the stream does not at a minimum have
        confidentiality and integrity protection via TLS with full
        certificate validation as described under
        <a class='info' href='#security-certificates-validation-server'>Section&nbsp;13.7.2.1<span> (</span><span class='info'>Server Certificates</span><span>)</span></a>.  A
        server MUST NOT offer SASL PLAIN if the confidentiality and
        integrity of the stream are not protected via TLS or an
        equivalent security layer.  A server SHOULD NOT offer TLS plus
        SASL PLAIN unless it is unable to offer some variant of SASL
        SCRAM (or other alternatives that are more secure than TLS
        plus SASL PLAIN), e.g., because the XMPP service depends for
        authentication purposes on a database or directory that is not
        under the control of the XMPP administrators, such as
        Pluggable Authentication Modules (PAM), an Lightweight
        Directory Access Protocol (LDAP) directory <a class='info' href='#LDAP'>[LDAP]<span> (</span><span class='info'>Zeilenga, K., &ldquo;Lightweight Directory Access Protocol (LDAP): Technical Specification Road Map,&rdquo; June&nbsp;2006.</span><span>)</span></a>, or an Authentication, Authorization, and Accounting (AAA) key management protocol (for guidance, refer to <a class='info' href='#AAA'>[AAA]<span> (</span><span class='info'>Housley, R. and B. Aboba, &ldquo;Guidance for Authentication, Authorization, and Accounting (AAA) Key Management,&rdquo; July&nbsp;2007.</span><span>)</span></a>). However, offering TLS plus SASL PLAIN even when the server supports more secure alternatives might be appropriate if the server needs to enable interoperability with an installed base of clients that do not yet support SCRAM or other alternatives that are more secure than TLS plus SASL PLAIN.
</p>
</blockquote>

<a name="security-mti-bothnopass"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.8.4"></a><h3>13.8.4.&nbsp;
For Confidentiality and Authentication without Passwords</h3>

<p>For both confidentiality and authentication without passwords, servers MUST and clients SHOULD implement TLS with the TLS_RSA_WITH_AES_128_CBC_SHA ciphersuite plus the SASL EXTERNAL mechanism (see Appendix A of <a class='info' href='#SASL'>[SASL]<span> (</span><span class='info'>Melnikov, A. and K. Zeilenga, &ldquo;Simple Authentication and Security Layer (SASL),&rdquo; June&nbsp;2006.</span><span>)</span></a>) with PKIX certificates.
</p>
<a name="security-reuse"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.9"></a><h3>13.9.&nbsp;
Technology Reuse</h3>

<a name="security-reuse-base64"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.9.1"></a><h3>13.9.1.&nbsp;
Use of Base 64 in SASL</h3>

<p>Both the client and the server MUST verify any base 64 data received during <a class='info' href='#sasl'>SASL negotiation<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>.  An implementation MUST reject (not ignore) any characters that are not explicitly allowed by the base 64 alphabet; this helps to guard against creation of a covert channel that could be used to "leak" information.
</p>
<p>An implementation MUST NOT break on invalid input and MUST reject any sequence of base 64 characters containing the pad ('=') character if that character is included as something other than the last character of the data (e.g., "=AAA" or "BBBB=CCC"); this helps to guard against buffer overflow attacks and other attacks on the implementation.
</p>
<p>While base 64 encoding visually hides otherwise easily recognized information (such as passwords), it does not provide any computational confidentiality.
</p>
<p>All uses of base 64 encoding MUST follow the definition in Section 4 of <a class='info' href='#BASE64'>[BASE64]<span> (</span><span class='info'>Josefsson, S., &ldquo;The Base16, Base32, and Base64 Data Encodings,&rdquo; October&nbsp;2006.</span><span>)</span></a> and padding bits MUST be set to zero.
</p>
<a name="security-reuse-dns"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.9.2"></a><h3>13.9.2.&nbsp;
Use of DNS</h3>

<p>XMPP typically relies on the Domain Name System
        (specifically <a class='info' href='#DNS-SRV'>[DNS&#8209;SRV]<span> (</span><span class='info'>Gulbrandsen, A., Vixie, P., and L. Esibov, &ldquo;A DNS RR for specifying the location of services (DNS SRV),&rdquo; February&nbsp;2000.</span><span>)</span></a> records) to resolve a
        fully qualified domain name to an IP address before a client connects to a server or before a peer server connects to another server.  Before attempting to negotiate an XML stream, the initiating entity MUST NOT proceed until it has resolved the DNS domain name of the receiving entity as specified under <a class='info' href='#tcp'>Section&nbsp;3<span> (</span><span class='info'>TCP Binding</span><span>)</span></a> (although it is not necessary to resolve the DNS domain name before each connection attempt, because DNS resolution results can be temporarily cached in accordance with time-to-live values). However, in the absence of a secure DNS option (e.g., as provided by <a class='info' href='#DNSSEC'>[DNSSEC]<span> (</span><span class='info'>Arends, R., Austein, R., Larson, M., Massey, D., and S. Rose, &ldquo;DNS Security Introduction and Requirements,&rdquo; March&nbsp;2005.</span><span>)</span></a>), a malicious attacker with access to the DNS server data, or able to cause spoofed answers to be cached in a recursive resolver, can potentially cause the initiating entity to connect to any XMPP server chosen by the attacker.  Deployment and validation of server certificates help to prevent such attacks.
</p>
<a name="security-reuse-hash"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.9.3"></a><h3>13.9.3.&nbsp;
Use of Hash Functions</h3>

<p>XMPP itself does not directly mandate the use of any particular cryptographic hash function.  However, technologies on which XMPP depends (e.g., TLS and particular SASL mechanisms), as well as various XMPP extensions, might make use of cryptographic hash functions.  Those who implement XMPP technologies or who develop XMPP extensions are advised to closely monitor the state of the art regarding attacks against cryptographic hash functions in Internet protocols as they relate to XMPP.  For helpful guidance, refer to <a class='info' href='#HASHES'>[HASHES]<span> (</span><span class='info'>Hoffman, P. and B. Schneier, &ldquo;Attacks on Cryptographic Hashes in Internet Protocols,&rdquo; November&nbsp;2005.</span><span>)</span></a>.
</p>
<a name="security-reuse-sasl"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.9.4"></a><h3>13.9.4.&nbsp;
Use of SASL</h3>

<p>Because the initiating entity chooses an acceptable SASL mechanism from the list presented by the receiving entity, the initiating entity depends on the receiving entity's list for authentication.  This dependency introduces the possibility of a downgrade attack if an attacker can gain control of the channel and therefore present a weak list of mechanisms.  To mitigate this attack, the parties SHOULD protect the channel using TLS before attempting SASL negotiation and either perform full certificate validation as described under <a class='info' href='#security-certificates-validation-server'>Section&nbsp;13.7.2.1<span> (</span><span class='info'>Server Certificates</span><span>)</span></a> or use a SASL mechanism that provides channel bindings, such as SCRAM-SHA-1-PLUS.  (Protecting the channel via TLS with full certificate validation can help to ensure the confidentiality and integrity of the information exchanged during SASL negotiation.)
</p>
<p>The SASL framework itself does not provide a method for binding SASL authentication to a security layer providing confidentiality and integrity protection that was negotiated at a lower layer (e.g., TLS).  Such a binding is known as a "channel binding" (see <a class='info' href='#CHANNEL'>[CHANNEL]<span> (</span><span class='info'>Williams, N., &ldquo;On the Use of Channel Bindings to Secure Channels,&rdquo; November&nbsp;2007.</span><span>)</span></a>).  Some SASL mechanisms provide channel bindings, which in the case of XMPP would typically be a binding to TLS (see <a class='info' href='#CHANNEL-TLS'>[CHANNEL&#8209;TLS]<span> (</span><span class='info'>Altman, J., Williams, N., and L. Zhu, &ldquo;Channel Bindings for TLS,&rdquo; July&nbsp;2010.</span><span>)</span></a>).  If a SASL mechanism provides a channel binding (e.g., this is true of <a class='info' href='#SCRAM'>[SCRAM]<span> (</span><span class='info'>Newman, C., Menon-Sen, A., Melnikov, A., and N. Williams, &ldquo;Salted Challenge Response Authentication Mechanism (SCRAM) SASL and GSS-API Mechanisms,&rdquo; July&nbsp;2010.</span><span>)</span></a>), then XMPP entities using that mechanism SHOULD prefer the channel binding variant (e.g., preferring "SCRAM-SHA-1-PLUS" over "SCRAM-SHA-1").  If a SASL mechanism does not provide a channel binding, then the mechanism cannot provide a way to verify that the source and destination end points to which the lower layer's security is bound are equivalent to the end points that SASL is authenticating; furthermore, if the end points are not identical, then the lower layer's security cannot be trusted to protect data transmitted between the SASL-authenticated entities.  In such a situation, a SASL security layer SHOULD be negotiated that effectively ignores the presence of the lower-layer security.
</p>
<p>Many deployed XMPP services authenticate client connections by means of passwords.  It is well known that most human users choose relatively weak passwords.  Although service provisioning is out of scope for this document, XMPP servers that allow password-based authentication SHOULD enforce minimal criteria for password strength to help prevent dictionary attacks.  Because all password-based authentication mechanisms are susceptible to password guessing attacks, XMPP servers MUST limit the number of retries allowed during SASL authentication, as described under <a class='info' href='#sasl-process-neg-failure'>Section&nbsp;6.4.5<span> (</span><span class='info'>SASL Failure</span><span>)</span></a>.
</p>
<p>Some SASL mechanisms (e.g., <a class='info' href='#ANONYMOUS'>[ANONYMOUS]<span> (</span><span class='info'>Zeilenga, K., &ldquo;Anonymous Simple Authentication and Security Layer (SASL) Mechanism,&rdquo; June&nbsp;2006.</span><span>)</span></a>) do not provide strong peer entity authentication of the client to the server.  Service administrators are advised to enable such mechanisms with caution.  Best practices for the use of the SASL ANONYMOUS mechanism in XMPP are described in <a class='info' href='#XEP-0175'>[XEP&#8209;0175]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Best Practices for Use of SASL ANONYMOUS,&rdquo; September&nbsp;2009.</span><span>)</span></a>.
</p>
<a name="security-reuse-tls"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.9.5"></a><h3>13.9.5.&nbsp;
Use of TLS</h3>

<p>Implementations of TLS typically support multiple versions of the Transport Layer Security protocol as well as the older Secure Sockets Layer (SSL) protocol.  Because of known security vulnerabilities, XMPP servers and clients MUST NOT request, offer, or use SSL 2.0.  For further details, see Appendix E.2 of <a class='info' href='#TLS'>[TLS]<span> (</span><span class='info'>Dierks, T. and E. Rescorla, &ldquo;The Transport Layer Security (TLS) Protocol Version 1.2,&rdquo; August&nbsp;2008.</span><span>)</span></a> along with <a class='info' href='#TLS-SSL2'>[TLS&#8209;SSL2]<span> (</span><span class='info'>Turner, S. and T. Polk, &ldquo;Prohibiting Secure Sockets Layer (SSL) Version 2.0,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<p>To prevent man-in-the-middle attacks, the TLS client (which might be an XMPP client or an XMPP server) MUST verify the certificate of the TLS server and MUST check its understanding of the server FQDN against the server's identity as presented in the TLS Certificate message as described under <a class='info' href='#security-certificates-validation-server'>Section&nbsp;13.7.2.1<span> (</span><span class='info'>Server Certificates</span><span>)</span></a> (for further details, see <a class='info' href='#TLS-CERTS'>[TLS&#8209;CERTS]<span> (</span><span class='info'>Saint-Andre, P. and J. Hodges, &ldquo;Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS),&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<p>Support for TLS renegotiation is strictly OPTIONAL.  However, implementations that support TLS renegotiation MUST implement and use the TLS Renegotiation Extension <a class='info' href='#TLS-NEG'>[TLS&#8209;NEG]<span> (</span><span class='info'>Rescorla, E., Ray, M., Dispensa, S., and N. Oskov, &ldquo;Transport Layer Security (TLS) Renegotiation Indication Extension,&rdquo; February&nbsp;2010.</span><span>)</span></a>.  Further details are provided under <a class='info' href='#tls-rules-renegotiation'>Section&nbsp;5.3.5<span> (</span><span class='info'>TLS Renegotiation</span><span>)</span></a>.
</p>
<a name="security-reuse-utf8"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.9.6"></a><h3>13.9.6.&nbsp;
Use of UTF-8</h3>

<p>The use of UTF-8 makes it possible to transport non-ASCII characters, and thus enables character "spoofing" scenarios, in which a displayed value appears to be something other than it is.  Furthermore, there are known attack scenarios related to the decoding of UTF-8 data.  On both of these points, refer to <a class='info' href='#UTF-8'>[UTF&#8209;8]<span> (</span><span class='info'>Yergeau, F., &ldquo;UTF-8, a transformation format of ISO 10646,&rdquo; November&nbsp;2003.</span><span>)</span></a> for more information.
</p>
<a name="security-reuse-xml"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.9.7"></a><h3>13.9.7.&nbsp;
Use of XML</h3>

<p>Because XMPP is an application profile of the Extensible Markup Language <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>, many of the security considerations described in <a class='info' href='#XML-MEDIA'>[XML&#8209;MEDIA]<span> (</span><span class='info'>Murata, M., St. Laurent, S., and D. Kohn, &ldquo;XML Media Types,&rdquo; January&nbsp;2001.</span><span>)</span></a> and <a class='info' href='#XML-GUIDE'>[XML&#8209;GUIDE]<span> (</span><span class='info'>Hollenbeck, S., Rose, M., and L. Masinter, &ldquo;Guidelines for the Use of Extensible Markup Language (XML) within IETF Protocols,&rdquo; January&nbsp;2003.</span><span>)</span></a> also apply to XMPP.  Several aspects of XMPP mitigate the risks described there, such as the prohibitions specified under <a class='info' href='#xml-restrictions'>Section&nbsp;11.1<span> (</span><span class='info'>XML Restrictions</span><span>)</span></a> and the lack of external references to style sheets or transformations, but these mitigating factors are by no means comprehensive.
</p>
<a name="security-leaks"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.10"></a><h3>13.10.&nbsp;
Information Leaks</h3>

<a name="security-leaks-ipaddress"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.10.1"></a><h3>13.10.1.&nbsp;
IP Addresses</h3>

<p>A client's IP address and method of access MUST NOT be made public by a server (e.g., as typically occurs in <a class='info' href='#IRC'>[IRC]<span> (</span><span class='info'>Kalt, C., &ldquo;Internet Relay Chat: Architecture,&rdquo; April&nbsp;2000.</span><span>)</span></a>).
</p>
<a name="security-leaks-presence"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.10.2"></a><h3>13.10.2.&nbsp;
Presence Information</h3>

<p>One of the core aspects of XMPP is presence: information about the network availability of an XMPP entity (i.e., whether the entity is currently online or offline).  A "presence leak" occurs when an entity's network availability is inadvertently and involuntarily revealed to a second entity that is not authorized to know the first entity's network availability.
</p>
<p>Although presence is discussed more fully in <a class='info' href='#XMPP-IM'>[XMPP&#8209;IM]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,&rdquo; March&nbsp;2011.</span><span>)</span></a>, it is important to note that an XMPP server MUST NOT leak presence.  In particular at the core XMPP level, real-time addressing and network availability is associated with a specific connected resource; therefore, any disclosure of a connected resource's full JID comprises a presence leak.  To help prevent such a presence leak, a server MUST NOT return different stanza errors depending on whether a potential attacker sends XML stanzas to the entity's bare JID (&lt;localpart@domainpart&gt;) or full JID (&lt;localpart@domainpart/resourcepart&gt;).
</p>
<a name="security-harvesting"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.11"></a><h3>13.11.&nbsp;
Directory Harvesting</h3>

<p>If a server generates an error stanza in response to receiving a stanza for a user account that does not exist, using the &lt;service-unavailable/&gt; stanza error condition (<a class='info' href='#stanzas-error-conditions-service-unavailable'>Section&nbsp;8.3.3.19<span> (</span><span class='info'>service-unavailable</span><span>)</span></a>) can help protect against directory harvesting attacks, since this is the same error condition that is returned if, for instance, the namespace of an IQ child element is not understood, or if "offline message storage" (<a class='info' href='#XEP-0160'>[XEP&#8209;0160]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Best Practices for Handling Offline Messages,&rdquo; January&nbsp;2006.</span><span>)</span></a>) or message forwarding is not enabled for a domain.  However, subtle differences in the exact XML of error stanzas, as well as in the timing with which such errors are returned, can enable an attacker to determine the network presence of a user when more advanced blocking technologies are not used (see for instance <a class='info' href='#XEP-0016'>[XEP&#8209;0016]<span> (</span><span class='info'>Millard, P. and P. Saint-Andre, &ldquo;Privacy Lists,&rdquo; February&nbsp;2007.</span><span>)</span></a> and <a class='info' href='#XEP-0191'>[XEP&#8209;0191]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Simple Communications Blocking,&rdquo; February&nbsp;2007.</span><span>)</span></a>).  Therefore, a server that exercises a higher level of caution might not return any error at all in response to certain kinds of received stanzas, so that a non-existent user appears to behave like a user that has no interest in conversing with the sender.
</p>
<a name="security-dos"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.12"></a><h3>13.12.&nbsp;
Denial of Service</h3>

<p><a class='info' href='#DOS'>[DOS]<span> (</span><span class='info'>Handley, M., Rescorla, E., and IAB, &ldquo;Internet Denial-of-Service Considerations,&rdquo; December&nbsp;2006.</span><span>)</span></a> defines denial of service as follows:
</p>
<p>
        </p>
<blockquote class="text"><dl>
<dt></dt>
<dd>A denial-of-service (DoS) attack is an attack in which one or more machines target a victim and attempt to prevent the victim from doing useful work. The victim can be a network server, client or router, a network link or an entire network, an individual Internet user or a company doing business using the Internet, an Internet Service Provider (ISP), country, or any combination of or variant on these.
</dd>
</dl></blockquote><p>
      
</p>
<p>Some considerations discussed in this document help to prevent denial-of-service attacks (e.g., the mandate that a server MUST NOT process XML stanzas from clients that have not yet provided appropriate authentication credentials and MUST NOT process XML stanzas from peer servers whose identity it has not either authenticated via SASL or weakly verified via Server Dialback).
</p>
<p>In addition, <a class='info' href='#XEP-0205'>[XEP&#8209;0205]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Best Practices to Discourage Denial of Service Attacks,&rdquo; January&nbsp;2009.</span><span>)</span></a> provides a detailed discussion of potential denial-of-service attacks against XMPP systems along with best practices for preventing such attacks.  The recommendations include:
</p>
<p>
        </p>
<ol class="text">
<li>A server implementation SHOULD enable a server administrator to limit the number of TCP connections that it will accept from a given IP address at any one time.  If an entity attempts to connect but the maximum number of TCP connections has been reached, the receiving server MUST NOT allow the new connection to proceed.
</li>
<li>A server implementation SHOULD enable a server administrator to limit the number of TCP connection attempts that it will accept from a given IP address in a given time period.  If an entity attempts to connect but the maximum number of connection attempts has been reached, the receiving server MUST NOT allow the new connection to proceed.
</li>
<li>A server implementation SHOULD enable a server administrator to limit the number of connected resources it will allow an account to bind at any one time.  If a client attempts to bind a resource but it has already reached the configured number of allowable resources, the receiving server MUST return a &lt;resource-constraint/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-resource-constraint'>Section&nbsp;8.3.3.18<span> (</span><span class='info'>resource-constraint</span><span>)</span></a>).
</li>
<li>A server implementation SHOULD enable a server administrator to limit the size of stanzas it will accept from a connected client or peer server (where "size" is inclusive of all XML markup as defined in Section 2.4 of <a class='info' href='#XML'>[XML]<span> (</span><span class='info'>Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;Extensible Markup Language (XML) 1.0 (Fifth Edition),&rdquo; November&nbsp;2008.</span><span>)</span></a>, from the opening "&lt;" character of the stanza to the closing "&gt;" character).  A deployed server's maximum stanza size MUST NOT be smaller than 10000 bytes, which reflects a reasonable compromise between the benefits of expressiveness for originating entities and the costs of stanza processing for servers.  A server implementation SHOULD NOT blindly set 10000 bytes as the value for all deployments but instead SHOULD enable server administrators to set their own limits.  If a connected resource or peer server sends a stanza that violates the upper limit, the receiving server MUST either return a &lt;policy-violation/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-policy-violation'>Section&nbsp;8.3.3.12<span> (</span><span class='info'>policy-violation</span><span>)</span></a>), thus allowing the sender to recover, or close the stream with a &lt;policy-violation/&gt; stream error (<a class='info' href='#streams-error-conditions-policy-violation'>Section&nbsp;4.9.3.14<span> (</span><span class='info'>policy-violation</span><span>)</span></a>).
</li>
<li>A server implementation SHOULD enable a server administrator to limit the number of XML stanzas that a connected client is allowed to send to distinct recipients within a given time period.  If a connected client sends too many stanzas to distinct recipients in a given time period, the receiving server SHOULD NOT process the stanza and instead SHOULD return a &lt;policy-violation/&gt; stanza error (<a class='info' href='#stanzas-error-conditions-policy-violation'>Section&nbsp;8.3.3.12<span> (</span><span class='info'>policy-violation</span><span>)</span></a>).
</li>
<li>A server implementation SHOULD enable a server administrator to limit the amount of bandwidth it will allow a connected client or peer server to use in a given time period.
</li>
<li>A server implementation MAY enable a server administrator to limit the types of stanzas (based on the extended content "payload") that it will allow a connected resource or peer server send over an active connection.  Such limits and restrictions are a matter of deployment policy.
</li>
<li>A server implementation MAY refuse to route or deliver any stanza that it considers to be abusive, with or without returning an error to the sender.
</li>
</ol><p>
      
</p>
<p>For more detailed recommendations regarding denial-of-service attacks in XMPP systems, refer to <a class='info' href='#XEP-0205'>[XEP&#8209;0205]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Best Practices to Discourage Denial of Service Attacks,&rdquo; January&nbsp;2009.</span><span>)</span></a>.
</p>
<a name="security-firewalls"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.13"></a><h3>13.13.&nbsp;
Firewalls</h3>

<p>Although DNS SRV records can instruct connecting entities to use TCP ports other than 5222 (client-to-server) and 5269 (server-to-server), communication using XMPP typically occurs over those ports, which are registered with the IANA (see <a class='info' href='#iana'>Section&nbsp;14<span> (</span><span class='info'>IANA Considerations</span><span>)</span></a>).  Use of these well-known ports allows administrators to easily enable or disable XMPP activity through existing and commonly deployed firewalls.
</p>
<a name="security-federation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.14"></a><h3>13.14.&nbsp;
Interdomain Federation</h3>

<p>The term "federation" is commonly used to describe communication between two servers.
</p>
<p>Because service provisioning is a matter of policy, it is OPTIONAL for any given server to support federation.  If a particular server enables federation, it SHOULD enable strong security as previously described to ensure both authentication and confidentiality; compliant implementations SHOULD support TLS and SASL for this purpose.
</p>
<p>Before RFC 3920 defined TLS plus SASL EXTERNAL with certificates for encryption and authentication of server-to-server streams, the only method for weak identity verification of a peer server was Server Dialback as defined in <a class='info' href='#XEP-0220'>[XEP&#8209;0220]<span> (</span><span class='info'>Miller, J., Saint-Andre, P., and P. Hancke, &ldquo;Server Dialback,&rdquo; March&nbsp;2010.</span><span>)</span></a>.  Even when <a class='info' href='#DNSSEC'>[DNSSEC]<span> (</span><span class='info'>Arends, R., Austein, R., Larson, M., Massey, D., and S. Rose, &ldquo;DNS Security Introduction and Requirements,&rdquo; March&nbsp;2005.</span><span>)</span></a> is used, Server Dialback provides only weak identity verification and provides no confidentiality or integrity.  At the time of writing, Server Dialback is still the most widely used technique for some level of assurance over server-to-server streams.  This reality introduces the possibility of a downgrade attack from TLS + SASL EXTERNAL to Server Dialback if an attacker can gain control of the channel and therefore convince the initiating server that the receiving server does not support TLS or does not have an appropriate certificate.  To help prevent this attack, the parties SHOULD protect the channel using TLS before proceeding, even if the presented certificates are self-signed or otherwise untrusted.
</p>
<a name="security-nonrepudiation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.13.15"></a><h3>13.15.&nbsp;
Non-Repudiation</h3>

<p>Systems that provide both peer entity authentication and data integrity have the potential to enable an entity to prove to a third party that another entity intended to send particular data.  Although XMPP systems can provide both peer entity authentication and data integrity, XMPP was never designed to provide non-repudiation.
</p>
<a name="iana"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.14"></a><h3>14.&nbsp;
IANA Considerations</h3>

<p>The following subsections update the registrations provided in <a class='info' href='#RFC3920'>[RFC3920]<span> (</span><span class='info'>Saint-Andre, P., Ed., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Core,&rdquo; October&nbsp;2004.</span><span>)</span></a>.  This section is to be interpreted according to <a class='info' href='#IANA-GUIDE'>[IANA&#8209;GUIDE]<span> (</span><span class='info'>Narten, T. and H. Alvestrand, &ldquo;Guidelines for Writing an IANA Considerations Section in RFCs,&rdquo; May&nbsp;2008.</span><span>)</span></a>.
</p>
<a name="iana-ns-tls"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.14.1"></a><h3>14.1.&nbsp;
XML Namespace Name for TLS Data</h3>

<p>A URN sub-namespace for STARTTLS negotiation data in the Extensible Messaging and Presence Protocol (XMPP) is defined as follows.  (This namespace name adheres to the format defined in <a class='info' href='#XML-REG'>[XML&#8209;REG]<span> (</span><span class='info'>Mealling, M., &ldquo;The IETF XML Registry,&rdquo; January&nbsp;2004.</span><span>)</span></a>.)
</p>
<p></p>
<blockquote class="text"><dl>
<dt>URI:</dt>
<dd>urn:ietf:params:xml:ns:xmpp-tls
</dd>
<dt>Specification:</dt>
<dd>RFC 6120
</dd>
<dt>Description:</dt>
<dd>This is the XML namespace name for STARTTLS negotiation data in the Extensible Messaging and Presence Protocol (XMPP) as defined by RFC 6120.
</dd>
<dt>Registrant Contact:</dt>
<dd>IESG &lt;iesg@ietf.org&gt;
</dd>
</dl></blockquote>

<a name="iana-ns-sasl"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.14.2"></a><h3>14.2.&nbsp;
XML Namespace Name for SASL Data</h3>

<p>A URN sub-namespace for SASL negotiation data in the Extensible Messaging and Presence Protocol (XMPP) is defined as follows.  (This namespace name adheres to the format defined in <a class='info' href='#XML-REG'>[XML&#8209;REG]<span> (</span><span class='info'>Mealling, M., &ldquo;The IETF XML Registry,&rdquo; January&nbsp;2004.</span><span>)</span></a>.)
</p>
<p></p>
<blockquote class="text"><dl>
<dt>URI:</dt>
<dd>urn:ietf:params:xml:ns:xmpp-sasl
</dd>
<dt>Specification:</dt>
<dd>RFC 6120
</dd>
<dt>Description:</dt>
<dd>This is the XML namespace name for SASL negotiation data in the Extensible Messaging and Presence Protocol (XMPP) as defined by RFC 6120.
</dd>
<dt>Registrant Contact:</dt>
<dd>IESG &lt;iesg@ietf.org&gt;
</dd>
</dl></blockquote>

<a name="iana-ns-streams"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.14.3"></a><h3>14.3.&nbsp;
XML Namespace Name for Stream Errors</h3>

<p>A URN sub-namespace for stream error data in the Extensible Messaging and Presence Protocol (XMPP) is defined as follows.  (This namespace name adheres to the format defined in <a class='info' href='#XML-REG'>[XML&#8209;REG]<span> (</span><span class='info'>Mealling, M., &ldquo;The IETF XML Registry,&rdquo; January&nbsp;2004.</span><span>)</span></a>.)
</p>
<p></p>
<blockquote class="text"><dl>
<dt>URI:</dt>
<dd>urn:ietf:params:xml:ns:xmpp-streams
</dd>
<dt>Specification:</dt>
<dd>RFC 6120
</dd>
<dt>Description:</dt>
<dd>This is the XML namespace name for stream error data in the Extensible Messaging and Presence Protocol (XMPP) as defined by RFC 6120.
</dd>
<dt>Registrant Contact:</dt>
<dd>IESG &lt;iesg@ietf.org&gt;
</dd>
</dl></blockquote>

<a name="iana-ns-bind"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.14.4"></a><h3>14.4.&nbsp;
XML Namespace Name for Resource Binding</h3>

<p>A URN sub-namespace for resource binding in the Extensible Messaging and Presence Protocol (XMPP) is defined as follows.  (This namespace name adheres to the format defined in <a class='info' href='#XML-REG'>[XML&#8209;REG]<span> (</span><span class='info'>Mealling, M., &ldquo;The IETF XML Registry,&rdquo; January&nbsp;2004.</span><span>)</span></a>.)
</p>
<p></p>
<blockquote class="text"><dl>
<dt>URI:</dt>
<dd>urn:ietf:params:xml:ns:xmpp-bind
</dd>
<dt>Specification:</dt>
<dd>RFC 6120
</dd>
<dt>Description:</dt>
<dd>This is the XML namespace name for resource binding in the Extensible Messaging and Presence Protocol (XMPP) as defined by RFC 6120.
</dd>
<dt>Registrant Contact:</dt>
<dd>IESG &lt;iesg@ietf.org&gt;
</dd>
</dl></blockquote>

<a name="iana-ns-stanzas"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.14.5"></a><h3>14.5.&nbsp;
XML Namespace Name for Stanza Errors</h3>

<p>A URN sub-namespace for stanza error data in the Extensible Messaging and Presence Protocol (XMPP) is defined as follows.  (This namespace name adheres to the format defined in <a class='info' href='#XML-REG'>[XML&#8209;REG]<span> (</span><span class='info'>Mealling, M., &ldquo;The IETF XML Registry,&rdquo; January&nbsp;2004.</span><span>)</span></a>.)
</p>
<p></p>
<blockquote class="text"><dl>
<dt>URI:</dt>
<dd>urn:ietf:params:xml:ns:xmpp-stanzas
</dd>
<dt>Specification:</dt>
<dd>RFC 6120
</dd>
<dt>Description:</dt>
<dd>This is the XML namespace name for stanza error data in the Extensible Messaging and Presence Protocol (XMPP) as defined by RFC 6120.
</dd>
<dt>Registrant Contact:</dt>
<dd>IESG &lt;iesg@ietf.org&gt;
</dd>
</dl></blockquote>

<a name="iana-gssapi"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.14.6"></a><h3>14.6.&nbsp;
GSSAPI Service Name</h3>

<p>The IANA has registered "xmpp" as a <a class='info' href='#GSS-API'>[GSS&#8209;API]<span> (</span><span class='info'>Linn, J., &ldquo;Generic Security Service Application Program Interface Version 2, Update 1,&rdquo; January&nbsp;2000.</span><span>)</span></a> service name, as defined under <a class='info' href='#sasl-def'>Section&nbsp;6.6<span> (</span><span class='info'>SASL Definition</span><span>)</span></a>.
</p>
<a name="iana-ports"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.14.7"></a><h3>14.7.&nbsp;
Port Numbers and Service Names</h3>

<p>The IANA has registered "xmpp-client" and "xmpp-server" as keywords for <a class='info' href='#TCP'>[TCP]<span> (</span><span class='info'>Postel, J., &ldquo;Transmission Control Protocol,&rdquo; September&nbsp;1981.</span><span>)</span></a> ports 5222 and 5269, respectively.  In accordance with <a class='info' href='#IANA-PORTS'>[IANA&#8209;PORTS]<span> (</span><span class='info'>Cotton, M., Eggert, L., Touch, J., Westerlund, M., and S. Cheshire, &ldquo;Internet Assigned Numbers Authority (IANA) Procedures for the Management of the Transport Protocol Port Number and Service Name Registry,&rdquo; February&nbsp;2011.</span><span>)</span></a>, this document updates the existing registration, as follows.
</p>
<p>
        </p>
<blockquote class="text"><dl>
<dt>Service Name:</dt>
<dd>xmpp-client
</dd>
<dt>Transport Protocol:</dt>
<dd>TCP
</dd>
<dt>Description:</dt>
<dd>A service offering support for connections by XMPP client applications
</dd>
<dt>Registrant:</dt>
<dd>IETF XMPP Working Group
</dd>
<dt>Contact:</dt>
<dd>IESG &lt;iesg@ietf.org&gt;
</dd>
<dt>Reference:</dt>
<dd>RFC 6120
</dd>
<dt>Port Number:</dt>
<dd>5222
</dd>
</dl></blockquote><p>
      
</p>
<p>
        </p>
<blockquote class="text"><dl>
<dt>Service Name:</dt>
<dd>xmpp-server
</dd>
<dt>Transport Protocol:</dt>
<dd>TCP
</dd>
<dt>Description:</dt>
<dd>A service offering support for connections by XMPP server applications
</dd>
<dt>Registrant:</dt>
<dd>IETF XMPP Working Group
</dd>
<dt>Contact:</dt>
<dd>IESG &lt;iesg@ietf.org&gt;
</dd>
<dt>Reference:</dt>
<dd>RFC 6120
</dd>
<dt>Port Number:</dt>
<dd>5269
</dd>
</dl></blockquote><p>
      
</p>
<a name="conformance"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.15"></a><h3>15.&nbsp;
Conformance Requirements</h3>

<p>This section describes a protocol feature set that summarizes the conformance requirements of this specification.  This feature set is appropriate for use in software certification, interoperability testing, and implementation reports.  For each feature, this section provides the following information:
</p>
<p>
      </p>
<ul class="text">
<li>A human-readable name
</li>
<li>An informational description
</li>
<li>A reference to the particular section of this document that normatively defines the feature
</li>
<li>Whether the feature applies to the Client role, the Server
        role, or both (where "N/A" signifies that the feature is not
        applicable to the specified role)
</li>
<li>Whether the feature MUST or SHOULD be implemented, where the capitalized terms are to be understood as described in <a class='info' href='#KEYWORDS'>[KEYWORDS]<span> (</span><span class='info'>Bradner, S., &ldquo;Key words for use in RFCs to Indicate Requirement Levels,&rdquo; March&nbsp;1997.</span><span>)</span></a>
</li>
</ul><p>
    
</p>
<p>The feature set specified here attempts to adhere to the concepts and formats proposed by Larry Masinter within the IETF's NEWTRK Working Group in 2005, as captured in <a class='info' href='#INTEROP'>[INTEROP]<span> (</span><span class='info'>Masinter, L., &ldquo;Formalizing IETF Interoperability Reporting,&rdquo; October&nbsp;2005.</span><span>)</span></a>.  Although this feature set is more detailed than called for by <a class='info' href='#REPORTS'>[REPORTS]<span> (</span><span class='info'>Dusseault, L. and R. Sparks, &ldquo;Guidance on Interoperation and Implementation Reports for Advancement to Draft Standard,&rdquo; September&nbsp;2009.</span><span>)</span></a>, it provides a suitable basis for the generation of implementation reports to be submitted in support of advancing this specification from Proposed Standard to Draft Standard in accordance with <a class='info' href='#PROCESS'>[PROCESS]<span> (</span><span class='info'>Bradner, S., &ldquo;The Internet Standards Process -- Revision 3,&rdquo; October&nbsp;1996.</span><span>)</span></a>.
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>bind-gen
</dd>
<dt>Description:</dt>
<dd>Generate a random resource on demand.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#bind-servergen'>Section&nbsp;7.6<span> (</span><span class='info'>Server-Generated Resource Identifier</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>bind-mtn
</dd>
<dt>Description:</dt>
<dd>Consider resource binding as mandatory-to-negotiate.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#bind-rules-mtn'>Section&nbsp;7.3.1<span> (</span><span class='info'>Mandatory-to-Negotiate</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>bind-restart
</dd>
<dt>Description:</dt>
<dd>Do not restart the stream after negotiation of resource binding.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#bind-rules-restart'>Section&nbsp;7.3.2<span> (</span><span class='info'>Restart</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>bind-support
</dd>
<dt>Description:</dt>
<dd>Support binding of client resources to an authenticated stream.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#bind'>Section&nbsp;7<span> (</span><span class='info'>Resource Binding</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>sasl-correlate
</dd>
<dt>Description:</dt>
<dd>When authenticating a stream peer using SASL, correlate the authentication identifier resulting from SASL negotiation with the 'from' address (if any) of the stream header it received from the peer.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#sasl-process-neg-success'>Section&nbsp;6.4.6<span> (</span><span class='info'>SASL Success</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client SHOULD, Server SHOULD.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>sasl-errors
</dd>
<dt>Description:</dt>
<dd>Support SASL errors during the negotiation process.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#sasl-errors'>Section&nbsp;6.5<span> (</span><span class='info'>SASL Errors</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>sasl-mtn
</dd>
<dt>Description:</dt>
<dd>Consider SASL as mandatory-to-negotiate.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#sasl-rules-mtn'>Section&nbsp;6.3.1<span> (</span><span class='info'>Mandatory-to-Negotiate</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>sasl-restart
</dd>
<dt>Description:</dt>
<dd>Initiate or handle a stream restart after SASL negotiation.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#sasl-rules-restart'>Section&nbsp;6.3.2<span> (</span><span class='info'>Restart</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>sasl-support
</dd>
<dt>Description:</dt>
<dd>Support the Simple Authentication and Security Layer for stream authentication.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#sasl'>Section&nbsp;6<span> (</span><span class='info'>SASL Negotiation</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>security-mti-auth-scram
</dd>
<dt>Description:</dt>
<dd>Support the SASL SCRAM mechanism for authentication only (this implies support for both the SCRAM&#8209;SHA&#8209;1 and SCRAM&#8209;SHA&#8209;1&#8209;PLUS variants).
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#security-mti'>Section&nbsp;13.8<span> (</span><span class='info'>Mandatory-to-Implement TLS and SASL Technologies</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>security-mti-both-external
</dd>
<dt>Description:</dt>
<dd>Support TLS with SASL EXTERNAL for confidentiality and authentication.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#security-mti'>Section&nbsp;13.8<span> (</span><span class='info'>Mandatory-to-Implement TLS and SASL Technologies</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client SHOULD, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>security-mti-both-plain
</dd>
<dt>Description:</dt>
<dd>Support TLS using the TLS_RSA_WITH_AES_128_CBC_SHA ciphersuite plus the SASL PLAIN mechanism for confidentiality and authentication.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#security-mti'>Section&nbsp;13.8<span> (</span><span class='info'>Mandatory-to-Implement TLS and SASL Technologies</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client SHOULD, Server MAY.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>security-mti-both-scram
</dd>
<dt>Description:</dt>
<dd>Support TLS using the TLS_RSA_WITH_AES_128_CBC_SHA ciphersuite plus the SCRAM-SHA-1 and SCRAM-SHA-1-PLUS variants of the SASL SCRAM mechanism for confidentiality and authentication.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#security-mti'>Section&nbsp;13.8<span> (</span><span class='info'>Mandatory-to-Implement TLS and SASL Technologies</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>security-mti-confidentiality
</dd>
<dt>Description:</dt>
<dd>Support TLS using the TLS_RSA_WITH_AES_128_CBC_SHA ciphersuite for confidentiality only.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#security-mti'>Section&nbsp;13.8<span> (</span><span class='info'>Mandatory-to-Implement TLS and SASL Technologies</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server SHOULD.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-attribute-from
</dd>
<dt>Description:</dt>
<dd>Support the common 'from' attribute for all stanza kinds.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-attributes-from'>Section&nbsp;8.1.2<span> (</span><span class='info'>from</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-attribute-from-stamp
</dd>
<dt>Description:</dt>
<dd>Stamp or rewrite the 'from' address of all stanzas received from connected clients.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-attributes-from-c2s'>Section&nbsp;8.1.2.1<span> (</span><span class='info'>Client-to-Server Streams</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-attribute-from-validate
</dd>
<dt>Description:</dt>
<dd>Validate the 'from' address of all stanzas received from peer servers.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-attributes-from-s2s'>Section&nbsp;8.1.2.2<span> (</span><span class='info'>Server-to-Server Streams</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-attribute-id
</dd>
<dt>Description:</dt>
<dd>Support the common 'id' attribute for all stanza kinds.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-attributes-id'>Section&nbsp;8.1.3<span> (</span><span class='info'>id</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-attribute-to
</dd>
<dt>Description:</dt>
<dd>Support the common 'to' attribute for all stanza kinds.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-attributes-to'>Section&nbsp;8.1.1<span> (</span><span class='info'>to</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-attribute-to-validate
</dd>
<dt>Description:</dt>
<dd>Ensure that all stanzas received from peer servers include a 'to' address.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-attributes-to'>Section&nbsp;8.1.1<span> (</span><span class='info'>to</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-attribute-type
</dd>
<dt>Description:</dt>
<dd>Support the common 'type' attribute for all stanza kinds.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-attributes-type'>Section&nbsp;8.1.4<span> (</span><span class='info'>type</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-attribute-xmllang
</dd>
<dt>Description:</dt>
<dd>Support the common 'xml:lang' attribute for all stanza kinds.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-attributes-lang'>Section&nbsp;8.1.5<span> (</span><span class='info'>xml:lang</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-error
</dd>
<dt>Description:</dt>
<dd>Generate and handle stanzas of type "error" for all stanza kinds.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-error'>Section&nbsp;8.3<span> (</span><span class='info'>Stanza Errors</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-error-child
</dd>
<dt>Description:</dt>
<dd>Ensure that stanzas of type "error" include an &lt;error/&gt; child element.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-error'>Section&nbsp;8.3<span> (</span><span class='info'>Stanza Errors</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-error-id
</dd>
<dt>Description:</dt>
<dd>Ensure that stanzas of type "error" preserve the 'id' provided in the triggering stanza.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-error'>Section&nbsp;8.3<span> (</span><span class='info'>Stanza Errors</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-error-reply
</dd>
<dt>Description:</dt>
<dd>Do not reply to a stanza of type "error" with another stanza of type "error".
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-error'>Section&nbsp;8.3<span> (</span><span class='info'>Stanza Errors</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-extension
</dd>
<dt>Description:</dt>
<dd>Correctly process XML data qualified by an unsupported XML namespace, where "correctly process" means to ignore that portion of the stanza in the case of a message or presence stanza and return an error in the case of an IQ stanza (for the intended recipient), and to route or deliver the stanza (for a routing entity such as a server).
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-extended'>Section&nbsp;8.4<span> (</span><span class='info'>Extended Content</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-iq-child
</dd>
<dt>Description:</dt>
<dd>Include exactly one child element in an &lt;iq/&gt; stanza of type "get" or "set", zero or one child elements in an &lt;iq/&gt; stanza of type "result", and one or two child elements in an &lt;iq/&gt; stanza of type "error".
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-semantics-iq'>Section&nbsp;8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-iq-id
</dd>
<dt>Description:</dt>
<dd>Ensure that all &lt;iq/&gt; stanzas include an 'id' attribute.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-semantics-iq'>Section&nbsp;8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-iq-reply
</dd>
<dt>Description:</dt>
<dd>Reply to an &lt;iq/&gt; stanza of type "get" or "set" with an &lt;iq/&gt; stanza of type "result" or "error".
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-semantics-iq'>Section&nbsp;8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-iq-type
</dd>
<dt>Description:</dt>
<dd>Ensure that all &lt;iq/&gt; stanzas include a 'type' attribute whose value is "get", "set", "result", or "error".
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-semantics-iq'>Section&nbsp;8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-kind-iq
</dd>
<dt>Description:</dt>
<dd>Support the &lt;iq/&gt; stanza.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-semantics-iq'>Section&nbsp;8.2.3<span> (</span><span class='info'>IQ Semantics</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-kind-message
</dd>
<dt>Description:</dt>
<dd>Support the &lt;message/&gt; stanza.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-semantics-message'>Section&nbsp;8.2.1<span> (</span><span class='info'>Message Semantics</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stanza-kind-presence
</dd>
<dt>Description:</dt>
<dd>Support the &lt;presence/&gt; stanza.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#stanzas-semantics-presence'>Section&nbsp;8.2.2<span> (</span><span class='info'>Presence Semantics</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-attribute-initial-from
</dd>
<dt>Description:</dt>
<dd>Include a 'from' attribute in the initial stream header.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-attr-from'>Section&nbsp;4.7.1<span> (</span><span class='info'>from</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client SHOULD, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-attribute-initial-lang
</dd>
<dt>Description:</dt>
<dd>Include an 'xml:lang' attribute in the initial stream header.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-attr-xmllang'>Section&nbsp;4.7.4<span> (</span><span class='info'>xml:lang</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client SHOULD, Server SHOULD.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-attribute-initial-to
</dd>
<dt>Description:</dt>
<dd>Include a 'to' attribute in the initial stream header.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-attr-to'>Section&nbsp;4.7.2<span> (</span><span class='info'>to</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-attribute-response-from
</dd>
<dt>Description:</dt>
<dd>Include a 'from' attribute in the response stream header.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-attr-from'>Section&nbsp;4.7.1<span> (</span><span class='info'>from</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-attribute-response-id
</dd>
<dt>Description:</dt>
<dd>Include an 'id' attribute in the response stream header.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-attr-id'>Section&nbsp;4.7.3<span> (</span><span class='info'>id</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-attribute-response-id-unique
</dd>
<dt>Description:</dt>
<dd>Ensure that the 'id' attribute in the response stream header is unique within the context of the receiving entity.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-attr-id'>Section&nbsp;4.7.3<span> (</span><span class='info'>id</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-attribute-response-to
</dd>
<dt>Description:</dt>
<dd>Include a 'to' attribute in the response stream header.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-attr-to'>Section&nbsp;4.7.2<span> (</span><span class='info'>to</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server SHOULD.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-error-generate
</dd>
<dt>Description:</dt>
<dd>Generate a stream error (followed by a closing stream tag and termination of the TCP connection) upon detecting a stream-related error condition.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-error'>Section&nbsp;4.9<span> (</span><span class='info'>Stream Errors</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-fqdn-resolution
</dd>
<dt>Description:</dt>
<dd>Resolve FQDNs before opening a TCP connection to the receiving entity.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#tcp-resolution'>Section&nbsp;3.2<span> (</span><span class='info'>Resolution of Fully Qualified Domain Names</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-negotiation-complete
</dd>
<dt>Description:</dt>
<dd>Do not consider the stream negotiation process to be complete until the receiving entity sends a stream features advertisement that is empty or that contains only voluntary-to-negotiate features.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-negotiation-complete'>Section&nbsp;4.3.5<span> (</span><span class='info'>Completion of Stream Negotiation</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-negotiation-features
</dd>
<dt>Description:</dt>
<dd>Send stream features after sending a response stream header.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-negotiation-features'>Section&nbsp;4.3.2<span> (</span><span class='info'>Stream Features Format</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-negotiation-restart
</dd>
<dt>Description:</dt>
<dd>Consider the previous stream to be replaced upon negotiation of a stream feature that necessitates a stream restart, and send or receive a new initial stream header after negotiation of such a stream feature.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-negotiation-restart'>Section&nbsp;4.3.3<span> (</span><span class='info'>Restarts</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-reconnect
</dd>
<dt>Description:</dt>
<dd>Reconnect with exponential backoff if a TCP connection is terminated unexpectedly.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#tcp-reconnect'>Section&nbsp;3.3<span> (</span><span class='info'>Reconnection</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>stream-tcp-binding
</dd>
<dt>Description:</dt>
<dd>Bind an XML stream to a TCP connection.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#tcp'>Section&nbsp;3<span> (</span><span class='info'>TCP Binding</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>tls-certs
</dd>
<dt>Description:</dt>
<dd>Check the identity specified in a certificate that is presented during TLS negotiation.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#security-certificates-validation'>Section&nbsp;13.7.2<span> (</span><span class='info'>Certificate Validation</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>tls-mtn
</dd>
<dt>Description:</dt>
<dd>Consider TLS as mandatory-to-negotiate if STARTTLS is the only feature advertised or if the STARTTLS feature advertisement includes an empty &lt;required/&gt; element.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#tls-rules-mtn'>Section&nbsp;5.3.1<span> (</span><span class='info'>Mandatory-to-Negotiate</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>tls-restart
</dd>
<dt>Description:</dt>
<dd>Initiate or handle a stream restart after TLS negotiation.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#tls-rules-restart'>Section&nbsp;5.3.2<span> (</span><span class='info'>Restart</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>tls-support
</dd>
<dt>Description:</dt>
<dd>Support Transport Layer Security for stream encryption.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#tls'>Section&nbsp;5<span> (</span><span class='info'>STARTTLS Negotiation</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>tls-correlate
</dd>
<dt>Description:</dt>
<dd>When validating a certificate presented by a stream peer during TLS negotiation, correlate the validated identity with the 'from' address (if any) of the stream header it received from the peer.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#security-certificates-validation'>Section&nbsp;13.7.2<span> (</span><span class='info'>Certificate Validation</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client SHOULD, Server SHOULD.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>xml-namespace-content-client
</dd>
<dt>Description:</dt>
<dd>Support 'jabber:client' as a content namespace.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-ns-content'>Section&nbsp;4.8.2<span> (</span><span class='info'>Content Namespace</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>xml-namespace-content-server
</dd>
<dt>Description:</dt>
<dd>Support 'jabber:server' as a content namespace.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-ns-content'>Section&nbsp;4.8.2<span> (</span><span class='info'>Content Namespace</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client N/A, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>xml-namespace-streams-declaration
</dd>
<dt>Description:</dt>
<dd>Ensure that there is a namespace declaration for the 'http://etherx.jabber.org/streams' namespace.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-ns-stream'>Section&nbsp;4.8.1<span> (</span><span class='info'>Stream Namespace</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>xml-namespace-streams-prefix
</dd>
<dt>Description:</dt>
<dd>Ensure that all elements qualified by the 'http://etherx.jabber.org/streams' namespace are prefixed by the prefix (if any) defined in the namespace declaration.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#streams-ns-stream'>Section&nbsp;4.8.1<span> (</span><span class='info'>Stream Namespace</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>xml-restriction-comment
</dd>
<dt>Description:</dt>
<dd>Do not generate or accept XML comments.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#xml-restrictions'>Section&nbsp;11.1<span> (</span><span class='info'>XML Restrictions</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>xml-restriction-dtd
</dd>
<dt>Description:</dt>
<dd>Do not generate or accept internal or external DTD subsets.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#xml-restrictions'>Section&nbsp;11.1<span> (</span><span class='info'>XML Restrictions</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>xml-restriction-pi
</dd>
<dt>Description:</dt>
<dd>Do not generate or accept XML processing instructions.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#xml-restrictions'>Section&nbsp;11.1<span> (</span><span class='info'>XML Restrictions</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>xml-restriction-ref
</dd>
<dt>Description:</dt>
<dd>Do not generate or accept internal or external entity references with the exception of the predefined entities.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#xml-restrictions'>Section&nbsp;11.1<span> (</span><span class='info'>XML Restrictions</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>xml-wellformed-xml
</dd>
<dt>Description:</dt>
<dd>Do not generate or accept data that is not XML-well-formed.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#xml-wellformed'>Section&nbsp;11.3<span> (</span><span class='info'>Well-Formedness</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<p>
      </p>
<blockquote class="text"><dl>
<dt>Feature:</dt>
<dd>xml-wellformed-ns
</dd>
<dt>Description:</dt>
<dd>Do not generate or accept data that is not namespace-well-formed.
</dd>
<dt>Section:</dt>
<dd><a class='info' href='#xml-wellformed'>Section&nbsp;11.3<span> (</span><span class='info'>Well-Formedness</span><span>)</span></a>
</dd>
<dt>Roles:</dt>
<dd>Client MUST, Server MUST.
</dd>
</dl></blockquote><p>
    
</p>
<a name="rfc.references"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.16"></a><h3>16.&nbsp;
References</h3>

<a name="rfc.references1"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<h3>16.1.&nbsp;Normative References</h3>
<table width="99%" border="0">
<tr><td class="author-text" valign="top"><a name="BASE64">[BASE64]</a></td>
<td class="author-text">Josefsson, S., &ldquo;<a href="http://tools.ietf.org/html/rfc4648">The Base16, Base32, and Base64 Data Encodings</a>,&rdquo; RFC&nbsp;4648, October&nbsp;2006 (<a href="http://www.rfc-editor.org/rfc/rfc4648.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="CHANNEL">[CHANNEL]</a></td>
<td class="author-text">Williams, N., &ldquo;<a href="http://tools.ietf.org/html/rfc5056">On the Use of Channel Bindings to Secure Channels</a>,&rdquo; RFC&nbsp;5056, November&nbsp;2007 (<a href="http://www.rfc-editor.org/rfc/rfc5056.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="CHANNEL-TLS">[CHANNEL-TLS]</a></td>
<td class="author-text">Altman, J., Williams, N., and L. Zhu, &ldquo;<a href="http://tools.ietf.org/html/rfc5929">Channel Bindings for TLS</a>,&rdquo; RFC&nbsp;5929, July&nbsp;2010 (<a href="http://www.rfc-editor.org/rfc/rfc5929.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="CHARSETS">[CHARSETS]</a></td>
<td class="author-text"><a href="mailto:Harald.T.Alvestrand@uninett.no">Alvestrand, H.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2277">IETF Policy on Character Sets and Languages</a>,&rdquo; BCP&nbsp;18, RFC&nbsp;2277, January&nbsp;1998 (<a href="http://www.rfc-editor.org/rfc/rfc2277.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc2277.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc2277.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="DNS-CONCEPTS">[DNS-CONCEPTS]</a></td>
<td class="author-text">Mockapetris, P., &ldquo;<a href="http://tools.ietf.org/html/rfc1034">Domain names - concepts and facilities</a>,&rdquo; STD&nbsp;13, RFC&nbsp;1034, November&nbsp;1987 (<a href="http://www.rfc-editor.org/rfc/rfc1034.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="DNS-SRV">[DNS-SRV]</a></td>
<td class="author-text"><a href="mailto:arnt@troll.no">Gulbrandsen, A.</a>, Vixie, P., and <a href="mailto:levone@microsoft.com">L. Esibov</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2782">A DNS RR for specifying the location of services (DNS SRV)</a>,&rdquo; RFC&nbsp;2782, February&nbsp;2000 (<a href="http://www.rfc-editor.org/rfc/rfc2782.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="IPv6-ADDR">[IPv6-ADDR]</a></td>
<td class="author-text">Kawamura, S. and M. Kawashima, &ldquo;<a href="http://tools.ietf.org/html/rfc5952">A Recommendation for IPv6 Address Text Representation</a>,&rdquo; RFC&nbsp;5952, August&nbsp;2010 (<a href="http://www.rfc-editor.org/rfc/rfc5952.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="KEYWORDS">[KEYWORDS]</a></td>
<td class="author-text"><a href="mailto:sob@harvard.edu">Bradner, S.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2119">Key words for use in RFCs to Indicate Requirement Levels</a>,&rdquo; BCP&nbsp;14, RFC&nbsp;2119, March&nbsp;1997 (<a href="http://www.rfc-editor.org/rfc/rfc2119.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc2119.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc2119.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="LANGMATCH">[LANGMATCH]</a></td>
<td class="author-text">Phillips, A. and M. Davis, &ldquo;<a href="http://tools.ietf.org/html/rfc4647">Matching of Language Tags</a>,&rdquo; BCP&nbsp;47, RFC&nbsp;4647, September&nbsp;2006 (<a href="http://www.rfc-editor.org/rfc/rfc4647.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="LANGTAGS">[LANGTAGS]</a></td>
<td class="author-text">Phillips, A. and M. Davis, &ldquo;<a href="http://tools.ietf.org/html/rfc5646">Tags for Identifying Languages</a>,&rdquo; BCP&nbsp;47, RFC&nbsp;5646, September&nbsp;2009 (<a href="http://www.rfc-editor.org/rfc/rfc5646.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="OCSP">[OCSP]</a></td>
<td class="author-text"><a href="mailto:mmyers@verisign.com">Myers, M.</a>, <a href="mailto:rankney@erols.com">Ankney, R.</a>, <a href="mailto:ambarish@valicert.com">Malpani, A.</a>, <a href="mailto:galperin@mycfo.com">Galperin, S.</a>, and <a href="mailto:cadams@entrust.com">C. Adams</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2560">X.509 Internet Public Key Infrastructure Online Certificate Status Protocol - OCSP</a>,&rdquo; RFC&nbsp;2560, June&nbsp;1999 (<a href="http://www.rfc-editor.org/rfc/rfc2560.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="PKIX">[PKIX]</a></td>
<td class="author-text">Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, &ldquo;<a href="http://tools.ietf.org/html/rfc5280">Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile</a>,&rdquo; RFC&nbsp;5280, May&nbsp;2008 (<a href="http://www.rfc-editor.org/rfc/rfc5280.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="PKIX-ALGO">[PKIX-ALGO]</a></td>
<td class="author-text">Jonsson, J. and B. Kaliski, &ldquo;<a href="http://tools.ietf.org/html/rfc3447">Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography Specifications Version 2.1</a>,&rdquo; RFC&nbsp;3447, February&nbsp;2003 (<a href="http://www.rfc-editor.org/rfc/rfc3447.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="PKIX-SRV">[PKIX-SRV]</a></td>
<td class="author-text">Santesson, S., &ldquo;<a href="http://tools.ietf.org/html/rfc4985">Internet X.509 Public Key Infrastructure Subject Alternative Name for Expression of Service Name</a>,&rdquo; RFC&nbsp;4985, August&nbsp;2007 (<a href="http://www.rfc-editor.org/rfc/rfc4985.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="PLAIN">[PLAIN]</a></td>
<td class="author-text">Zeilenga, K., &ldquo;<a href="http://tools.ietf.org/html/rfc4616">The PLAIN Simple Authentication and Security Layer (SASL) Mechanism</a>,&rdquo; RFC&nbsp;4616, August&nbsp;2006 (<a href="http://www.rfc-editor.org/rfc/rfc4616.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="RANDOM">[RANDOM]</a></td>
<td class="author-text">Eastlake, D., Schiller, J., and S. Crocker, &ldquo;<a href="http://tools.ietf.org/html/rfc4086">Randomness Requirements for Security</a>,&rdquo; BCP&nbsp;106, RFC&nbsp;4086, June&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc4086.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="SASL">[SASL]</a></td>
<td class="author-text">Melnikov, A. and K. Zeilenga, &ldquo;<a href="http://tools.ietf.org/html/rfc4422">Simple Authentication and Security Layer (SASL)</a>,&rdquo; RFC&nbsp;4422, June&nbsp;2006 (<a href="http://www.rfc-editor.org/rfc/rfc4422.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="SCRAM">[SCRAM]</a></td>
<td class="author-text">Newman, C., Menon-Sen, A., Melnikov, A., and N. Williams, &ldquo;<a href="http://tools.ietf.org/html/rfc5802">Salted Challenge Response Authentication Mechanism (SCRAM) SASL and GSS-API Mechanisms</a>,&rdquo; RFC&nbsp;5802, July&nbsp;2010 (<a href="http://www.rfc-editor.org/rfc/rfc5802.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="STRONGSEC">[STRONGSEC]</a></td>
<td class="author-text">Schiller, J., &ldquo;<a href="http://tools.ietf.org/html/rfc3365">Strong Security Requirements for Internet Engineering Task Force Standard Protocols</a>,&rdquo; BCP&nbsp;61, RFC&nbsp;3365, August&nbsp;2002 (<a href="http://www.rfc-editor.org/rfc/rfc3365.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="TCP">[TCP]</a></td>
<td class="author-text">Postel, J., &ldquo;<a href="http://tools.ietf.org/html/rfc793">Transmission Control Protocol</a>,&rdquo; STD&nbsp;7, RFC&nbsp;793, September&nbsp;1981 (<a href="http://www.rfc-editor.org/rfc/rfc793.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="TLS">[TLS]</a></td>
<td class="author-text">Dierks, T. and E. Rescorla, &ldquo;<a href="http://tools.ietf.org/html/rfc5246">The Transport Layer Security (TLS) Protocol Version 1.2</a>,&rdquo; RFC&nbsp;5246, August&nbsp;2008 (<a href="http://www.rfc-editor.org/rfc/rfc5246.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="TLS-CERTS">[TLS-CERTS]</a></td>
<td class="author-text">Saint-Andre, P. and J. Hodges, &ldquo;<a href="http://tools.ietf.org/html/rfc6125">Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS)</a>,&rdquo; RFC&nbsp;6125, March&nbsp;2011.</td></tr>
<tr><td class="author-text" valign="top"><a name="TLS-NEG">[TLS-NEG]</a></td>
<td class="author-text">Rescorla, E., Ray, M., Dispensa, S., and N. Oskov, &ldquo;<a href="http://tools.ietf.org/html/rfc5746">Transport Layer Security (TLS) Renegotiation Indication Extension</a>,&rdquo; RFC&nbsp;5746, February&nbsp;2010 (<a href="http://www.rfc-editor.org/rfc/rfc5746.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="TLS-SSL2">[TLS-SSL2]</a></td>
<td class="author-text">Turner, S. and T. Polk, &ldquo;<a href="http://tools.ietf.org/html/rfc6176">Prohibiting Secure Sockets Layer (SSL) Version 2.0</a>,&rdquo; RFC&nbsp;6176, March&nbsp;2011.</td></tr>
<tr><td class="author-text" valign="top"><a name="UCS2">[UCS2]</a></td>
<td class="author-text">International Organization for Standardization, &ldquo;Information Technology - Universal Multiple-octet coded Character Set (UCS) - Amendment 2: UCS Transformation Format 8 (UTF-8),&rdquo; ISO&nbsp;Standard 10646-1 Addendum 2, October&nbsp;1996.</td></tr>
<tr><td class="author-text" valign="top"><a name="UNICODE">[UNICODE]</a></td>
<td class="author-text">The Unicode Consortium, &ldquo;<a href="http://www.unicode.org/versions/Unicode6.0.0/">The Unicode Standard, Version 6.0</a>,&rdquo; 2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="UTF-8">[UTF-8]</a></td>
<td class="author-text">Yergeau, F., &ldquo;<a href="http://tools.ietf.org/html/rfc3629">UTF-8, a transformation format of ISO 10646</a>,&rdquo; STD&nbsp;63, RFC&nbsp;3629, November&nbsp;2003 (<a href="http://www.rfc-editor.org/rfc/rfc3629.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="URI">[URI]</a></td>
<td class="author-text"><a href="mailto:timbl@w3.org">Berners-Lee, T.</a>, <a href="mailto:fielding@gbiv.com">Fielding, R.</a>, and <a href="mailto:LMM@acm.org">L. Masinter</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc3986">Uniform Resource Identifier (URI): Generic Syntax</a>,&rdquo; STD&nbsp;66, RFC&nbsp;3986, January&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc3986.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc3986.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc3986.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="X509">[X509]</a></td>
<td class="author-text">International Telecommunications Union, &ldquo;Information technology - Open Systems Interconnection - The Directory:
Public-key and attribute certificate frameworks,&rdquo; ITU-T&nbsp;Recommendation X.509, ISO&nbsp;Standard 9594-8, March&nbsp;2000.</td></tr>
<tr><td class="author-text" valign="top"><a name="XML">[XML]</a></td>
<td class="author-text">Maler, E., Yergeau, F., Sperberg-McQueen, C., Paoli, J., and T. Bray, &ldquo;<a href="http://www.w3.org/TR/2008/REC-xml-20081126">Extensible Markup Language (XML) 1.0 (Fifth Edition)</a>,&rdquo; World Wide Web Consortium Recommendation&nbsp;REC-xml-20081126, November&nbsp;2008 (<a href="http://www.w3.org/TR/2008/REC-xml-20081126">HTML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XML-GUIDE">[XML-GUIDE]</a></td>
<td class="author-text"><a href="mailto:shollenbeck@verisign.com">Hollenbeck, S.</a>, <a href="mailto:mrose@dbc.mtview.ca.us">Rose, M.</a>, and <a href="mailto:LMM@acm.org">L. Masinter</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc3470">Guidelines for the Use of Extensible Markup Language (XML) within IETF Protocols</a>,&rdquo; BCP&nbsp;70, RFC&nbsp;3470, January&nbsp;2003 (<a href="http://www.rfc-editor.org/rfc/rfc3470.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc3470.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc3470.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XML-MEDIA">[XML-MEDIA]</a></td>
<td class="author-text">Murata, M., St. Laurent, S., and D. Kohn, &ldquo;<a href="http://tools.ietf.org/html/rfc3023">XML Media Types</a>,&rdquo; RFC&nbsp;3023, January&nbsp;2001 (<a href="http://www.rfc-editor.org/rfc/rfc3023.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XML-NAMES">[XML-NAMES]</a></td>
<td class="author-text">Thompson, H., Hollander, D., Layman, A., Bray, T., and R. Tobin, &ldquo;<a href="http://www.w3.org/TR/2009/REC-xml-names-20091208">Namespaces in XML 1.0 (Third Edition)</a>,&rdquo; World Wide Web Consortium Recommendation&nbsp;REC-xml-names-20091208, December&nbsp;2009 (<a href="http://www.w3.org/TR/2009/REC-xml-names-20091208">HTML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XMPP-ADDR">[XMPP-ADDR]</a></td>
<td class="author-text">Saint-Andre, P., &ldquo;<a href="http://tools.ietf.org/html/rfc6122">Extensible Messaging and Presence Protocol (XMPP): Address Format</a>,&rdquo; RFC&nbsp;6122, March&nbsp;2011.</td></tr>
<tr><td class="author-text" valign="top"><a name="XMPP-IM">[XMPP-IM]</a></td>
<td class="author-text">Saint-Andre, P., &ldquo;<a href="http://tools.ietf.org/html/rfc6121">Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence</a>,&rdquo; RFC&nbsp;6121, March&nbsp;2011.</td></tr>
</table>

<a name="rfc.references2"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<h3>16.2.&nbsp;Informative References</h3>
<table width="99%" border="0">
<tr><td class="author-text" valign="top"><a name="AAA">[AAA]</a></td>
<td class="author-text">Housley, R. and B. Aboba, &ldquo;<a href="http://tools.ietf.org/html/rfc4962">Guidance for Authentication, Authorization, and Accounting (AAA) Key Management</a>,&rdquo; BCP&nbsp;132, RFC&nbsp;4962, July&nbsp;2007 (<a href="http://www.rfc-editor.org/rfc/rfc4962.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="ABNF">[ABNF]</a></td>
<td class="author-text">Crocker, D. and P. Overell, &ldquo;<a href="http://tools.ietf.org/html/rfc5234">Augmented BNF for Syntax Specifications: ABNF</a>,&rdquo; STD&nbsp;68, RFC&nbsp;5234, January&nbsp;2008 (<a href="http://www.rfc-editor.org/rfc/rfc5234.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="ACAP">[ACAP]</a></td>
<td class="author-text"><a href="mailto:chris.newman@innosoft.com">Newman, C.</a> and <a href="mailto:jgmyers@netscape.com">J. Myers</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2244">ACAP -- Application Configuration Access Protocol</a>,&rdquo; RFC&nbsp;2244, November&nbsp;1997 (<a href="http://www.rfc-editor.org/rfc/rfc2244.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="ANONYMOUS">[ANONYMOUS]</a></td>
<td class="author-text">Zeilenga, K., &ldquo;<a href="http://tools.ietf.org/html/rfc4505">Anonymous Simple Authentication and Security Layer (SASL) Mechanism</a>,&rdquo; RFC&nbsp;4505, June&nbsp;2006 (<a href="http://www.rfc-editor.org/rfc/rfc4505.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="ASN.1">[ASN.1]</a></td>
<td class="author-text">CCITT, &ldquo;Recommendation X.208: Specification of Abstract Syntax Notation One (ASN.1),&rdquo; 1988.</td></tr>
<tr><td class="author-text" valign="top"><a name="DIGEST-MD5">[DIGEST-MD5]</a></td>
<td class="author-text">Leach, P. and C. Newman, &ldquo;<a href="http://tools.ietf.org/html/rfc2831">Using Digest Authentication as a SASL Mechanism</a>,&rdquo; RFC&nbsp;2831, May&nbsp;2000 (<a href="http://www.rfc-editor.org/rfc/rfc2831.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="DNSSEC">[DNSSEC]</a></td>
<td class="author-text">Arends, R., Austein, R., Larson, M., Massey, D., and S. Rose, &ldquo;<a href="http://tools.ietf.org/html/rfc4033">DNS Security Introduction and Requirements</a>,&rdquo; RFC&nbsp;4033, March&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc4033.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="DNS-TXT">[DNS-TXT]</a></td>
<td class="author-text"><a href="mailto:rosenbaum@lkg.dec.com">Rosenbaum, R.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc1464">Using the Domain Name System To Store Arbitrary String Attributes</a>,&rdquo; RFC&nbsp;1464, May&nbsp;1993 (<a href="http://www.rfc-editor.org/rfc/rfc1464.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="DOS">[DOS]</a></td>
<td class="author-text">Handley, M., Rescorla, E., and IAB, &ldquo;<a href="http://tools.ietf.org/html/rfc4732">Internet Denial-of-Service Considerations</a>,&rdquo; RFC&nbsp;4732, December&nbsp;2006 (<a href="http://www.rfc-editor.org/rfc/rfc4732.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="E2E-REQS">[E2E-REQS]</a></td>
<td class="author-text">Saint-Andre, P., &ldquo;Requirements for End-to-End Encryption in the Extensible Messaging and Presence Protocol (XMPP),&rdquo; Work in&nbsp;Progress, March&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="EMAIL-ARCH">[EMAIL-ARCH]</a></td>
<td class="author-text">Crocker, D., &ldquo;<a href="http://tools.ietf.org/html/rfc5598">Internet Mail Architecture</a>,&rdquo; RFC&nbsp;5598, July&nbsp;2009 (<a href="http://www.rfc-editor.org/rfc/rfc5598.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="ETHERNET">[ETHERNET]</a></td>
<td class="author-text">&ldquo;Information technology - Telecommunications and information exchange between systems - Local and metropolitan area networks - Specific requirements - Part 3: Carrier sense multiple access with collision detection (CSMA/CD) access method and physical layer specifications,&rdquo; IEEE&nbsp;Standard 802.3, September&nbsp;1998.</td></tr>
<tr><td class="author-text" valign="top"><a name="GSS-API">[GSS-API]</a></td>
<td class="author-text"><a href="mailto:jlinn@rsasecurity.com">Linn, J.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2743">Generic Security Service Application Program Interface Version 2, Update 1</a>,&rdquo; RFC&nbsp;2743, January&nbsp;2000 (<a href="http://www.rfc-editor.org/rfc/rfc2743.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="HASHES">[HASHES]</a></td>
<td class="author-text">Hoffman, P. and B. Schneier, &ldquo;<a href="http://tools.ietf.org/html/rfc4270">Attacks on Cryptographic Hashes in Internet Protocols</a>,&rdquo; RFC&nbsp;4270, November&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc4270.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="HTTP">[HTTP]</a></td>
<td class="author-text"><a href="mailto:fielding@ics.uci.edu">Fielding, R.</a>, <a href="mailto:jg@w3.org">Gettys, J.</a>, <a href="mailto:mogul@wrl.dec.com">Mogul, J.</a>, <a href="mailto:frystyk@w3.org">Frystyk, H.</a>, <a href="mailto:masinter@parc.xerox.com">Masinter, L.</a>, <a href="mailto:paulle@microsoft.com">Leach, P.</a>, and <a href="mailto:timbl@w3.org">T. Berners-Lee</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2616">Hypertext Transfer Protocol -- HTTP/1.1</a>,&rdquo; RFC&nbsp;2616, June&nbsp;1999 (<a href="http://www.rfc-editor.org/rfc/rfc2616.txt">TXT</a>, <a href="http://www.rfc-editor.org/rfc/rfc2616.ps">PS</a>, <a href="http://www.rfc-editor.org/rfc/rfc2616.pdf">PDF</a>, <a href="http://xml.resource.org/public/rfc/html/rfc2616.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc2616.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="IANA-GUIDE">[IANA-GUIDE]</a></td>
<td class="author-text">Narten, T. and H. Alvestrand, &ldquo;<a href="http://tools.ietf.org/html/rfc5226">Guidelines for Writing an IANA Considerations Section in RFCs</a>,&rdquo; BCP&nbsp;26, RFC&nbsp;5226, May&nbsp;2008 (<a href="http://www.rfc-editor.org/rfc/rfc5226.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="IANA-PORTS">[IANA-PORTS]</a></td>
<td class="author-text">Cotton, M., Eggert, L., Touch, J., Westerlund, M., and S. Cheshire, &ldquo;Internet Assigned Numbers Authority (IANA) Procedures for the Management of the Transport Protocol Port Number and Service Name Registry,&rdquo; Work in&nbsp;Progress, February&nbsp;2011.</td></tr>
<tr><td class="author-text" valign="top"><a name="IMAP">[IMAP]</a></td>
<td class="author-text">Crispin, M., &ldquo;<a href="http://tools.ietf.org/html/rfc3501">INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1</a>,&rdquo; RFC&nbsp;3501, March&nbsp;2003 (<a href="http://www.rfc-editor.org/rfc/rfc3501.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="IMP-REQS">[IMP-REQS]</a></td>
<td class="author-text"><a href="mailto:mday@alum.mit.edu">Day, M.</a>, <a href="mailto:sonuag@microsoft.com">Aggarwal, S.</a>, and <a href="mailto:jesse@intonet.com">J. Vincent</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2779">Instant Messaging / Presence Protocol Requirements</a>,&rdquo; RFC&nbsp;2779, February&nbsp;2000 (<a href="http://www.rfc-editor.org/rfc/rfc2779.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="INTEROP">[INTEROP]</a></td>
<td class="author-text">Masinter, L., &ldquo;Formalizing IETF Interoperability Reporting,&rdquo; Work in&nbsp;Progress, October&nbsp;2005.</td></tr>
<tr><td class="author-text" valign="top"><a name="IRC">[IRC]</a></td>
<td class="author-text">Kalt, C., &ldquo;<a href="http://tools.ietf.org/html/rfc2810">Internet Relay Chat: Architecture</a>,&rdquo; RFC&nbsp;2810, April&nbsp;2000 (<a href="http://www.rfc-editor.org/rfc/rfc2810.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="IRI">[IRI]</a></td>
<td class="author-text">Duerst, M. and M. Suignard, &ldquo;<a href="http://tools.ietf.org/html/rfc3987">Internationalized Resource Identifiers (IRIs)</a>,&rdquo; RFC&nbsp;3987, January&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc3987.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="LDAP">[LDAP]</a></td>
<td class="author-text">Zeilenga, K., &ldquo;<a href="http://tools.ietf.org/html/rfc4510">Lightweight Directory Access Protocol (LDAP): Technical Specification Road Map</a>,&rdquo; RFC&nbsp;4510, June&nbsp;2006 (<a href="http://www.rfc-editor.org/rfc/rfc4510.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="LINKLOCAL">[LINKLOCAL]</a></td>
<td class="author-text">Cheshire, S., Aboba, B., and E. Guttman, &ldquo;<a href="http://tools.ietf.org/html/rfc3927">Dynamic Configuration of IPv4 Link-Local Addresses</a>,&rdquo; RFC&nbsp;3927, May&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc3927.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="MAILBOXES">[MAILBOXES]</a></td>
<td class="author-text"><a href="mailto:dcrocker@imc.org">Crocker, D.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2142">MAILBOX NAMES FOR COMMON SERVICES, ROLES AND FUNCTIONS</a>,&rdquo; RFC&nbsp;2142, May&nbsp;1997 (<a href="http://www.rfc-editor.org/rfc/rfc2142.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc2142.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc2142.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="POP3">[POP3]</a></td>
<td class="author-text"><a href="mailto:jgm+@cmu.edu">Myers, J.</a> and <a href="mailto:mrose@dbc.mtview.ca.us">M. Rose</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc1939">Post Office Protocol - Version 3</a>,&rdquo; STD&nbsp;53, RFC&nbsp;1939, May&nbsp;1996 (<a href="http://www.rfc-editor.org/rfc/rfc1939.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="PROCESS">[PROCESS]</a></td>
<td class="author-text"><a href="mailto:sob@harvard.edu">Bradner, S.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2026">The Internet Standards Process -- Revision 3</a>,&rdquo; BCP&nbsp;9, RFC&nbsp;2026, October&nbsp;1996 (<a href="http://www.rfc-editor.org/rfc/rfc2026.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="REPORTS">[REPORTS]</a></td>
<td class="author-text">Dusseault, L. and R. Sparks, &ldquo;<a href="http://tools.ietf.org/html/rfc5657">Guidance on Interoperation and Implementation Reports for Advancement to Draft Standard</a>,&rdquo; BCP&nbsp;9, RFC&nbsp;5657, September&nbsp;2009 (<a href="http://www.rfc-editor.org/rfc/rfc5657.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="REST">[REST]</a></td>
<td class="author-text">Fielding, R., &ldquo;<a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/fielding_dissertation.pdf">Architectural Styles and the Design of Network-based Software Architectures</a>,&rdquo; &nbsp;2000.</td></tr>
<tr><td class="author-text" valign="top"><a name="RFC3920">[RFC3920]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P., Ed.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc3920">Extensible Messaging and Presence Protocol (XMPP): Core</a>,&rdquo; RFC&nbsp;3920, October&nbsp;2004 (<a href="http://www.rfc-editor.org/rfc/rfc3920.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc3920.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc3920.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="RFC3921">[RFC3921]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P., Ed.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc3921">Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence</a>,&rdquo; RFC&nbsp;3921, October&nbsp;2004 (<a href="http://www.rfc-editor.org/rfc/rfc3921.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc3921.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc3921.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="SASLPREP">[SASLPREP]</a></td>
<td class="author-text">Zeilenga, K., &ldquo;<a href="http://tools.ietf.org/html/rfc4013">SASLprep: Stringprep Profile for User Names and Passwords</a>,&rdquo; RFC&nbsp;4013, February&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc4013.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="SEC-TERMS">[SEC-TERMS]</a></td>
<td class="author-text">Shirey, R., &ldquo;<a href="http://tools.ietf.org/html/rfc4949">Internet Security Glossary, Version 2</a>,&rdquo; RFC&nbsp;4949, August&nbsp;2007 (<a href="http://www.rfc-editor.org/rfc/rfc4949.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="SMTP">[SMTP]</a></td>
<td class="author-text">Klensin, J., &ldquo;<a href="http://tools.ietf.org/html/rfc5321">Simple Mail Transfer Protocol</a>,&rdquo; RFC&nbsp;5321, October&nbsp;2008 (<a href="http://www.rfc-editor.org/rfc/rfc5321.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="SEC-GUIDE">[SEC-GUIDE]</a></td>
<td class="author-text">Rescorla, E. and B. Korver, &ldquo;<a href="http://tools.ietf.org/html/rfc3552">Guidelines for Writing RFC Text on Security Considerations</a>,&rdquo; BCP&nbsp;72, RFC&nbsp;3552, July&nbsp;2003 (<a href="http://www.rfc-editor.org/rfc/rfc3552.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="TLS-EXT">[TLS-EXT]</a></td>
<td class="author-text">Eastlake 3rd, D., &ldquo;<a href="http://tools.ietf.org/html/rfc6066">Transport Layer Security (TLS) Extensions: Extension Definitions</a>,&rdquo; RFC&nbsp;6066, January&nbsp;2011 (<a href="http://www.rfc-editor.org/rfc/rfc6066.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="TLS-RESUME">[TLS-RESUME]</a></td>
<td class="author-text">Salowey, J., Zhou, H., Eronen, P., and H. Tschofenig, &ldquo;<a href="http://tools.ietf.org/html/rfc5077">Transport Layer Security (TLS) Session Resumption without Server-Side State</a>,&rdquo; RFC&nbsp;5077, January&nbsp;2008 (<a href="http://www.rfc-editor.org/rfc/rfc5077.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="URN-OID">[URN-OID]</a></td>
<td class="author-text">Mealling, M., &ldquo;<a href="http://tools.ietf.org/html/rfc3061">A URN Namespace of Object Identifiers</a>,&rdquo; RFC&nbsp;3061, February&nbsp;2001 (<a href="http://www.rfc-editor.org/rfc/rfc3061.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="USINGTLS">[USINGTLS]</a></td>
<td class="author-text"><a href="mailto:chris.newman@innosoft.com">Newman, C.</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc2595">Using TLS with IMAP, POP3 and ACAP</a>,&rdquo; RFC&nbsp;2595, June&nbsp;1999 (<a href="http://www.rfc-editor.org/rfc/rfc2595.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="UUID">[UUID]</a></td>
<td class="author-text"><a href="mailto:paulle@microsoft.com">Leach, P.</a>, <a href="mailto:michael@refactored-networks.com">Mealling, M.</a>, and <a href="mailto:rsalz@datapower.com">R. Salz</a>, &ldquo;<a href="http://tools.ietf.org/html/rfc4122">A Universally Unique IDentifier (UUID) URN Namespace</a>,&rdquo; RFC&nbsp;4122, July&nbsp;2005 (<a href="http://www.rfc-editor.org/rfc/rfc4122.txt">TXT</a>, <a href="http://xml.resource.org/public/rfc/html/rfc4122.html">HTML</a>, <a href="http://xml.resource.org/public/rfc/xml/rfc4122.xml">XML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0001">[XEP-0001]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0001.html">XMPP Extension Protocols</a>,&rdquo; XSF XEP&nbsp;0001, March&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0016">[XEP-0016]</a></td>
<td class="author-text">Millard, P. and <a href="mailto:stpeter@jabber.org">P. Saint-Andre</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0016.html">Privacy Lists</a>,&rdquo; XSF XEP&nbsp;0016, February&nbsp;2007.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0045">[XEP-0045]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0045.html">Multi-User Chat</a>,&rdquo; XSF XEP&nbsp;0045, July&nbsp;2007.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0060">[XEP-0060]</a></td>
<td class="author-text"><a href="mailto:">Millard, P.</a>, <a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, and <a href="mailto:ralphm@ik.nu">R. Meijer</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0060.html">Publish-Subscribe</a>,&rdquo; XSF XEP&nbsp;0060, July&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0071">[XEP-0071]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0071.html">XHTML-IM</a>,&rdquo; XSF XEP&nbsp;0071, September&nbsp;2008.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0077">[XEP-0077]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0077.html">In-Band Registration</a>,&rdquo; XSF XEP&nbsp;0077, September&nbsp;2009.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0086">[XEP-0086]</a></td>
<td class="author-text"><a href="mailto:rob@cataclysm.cx">Norris, R.</a> and <a href="mailto:stpeter@jabber.org">P. Saint-Andre</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0086.html">Error Condition Mappings</a>,&rdquo; XSF XEP&nbsp;0086, February&nbsp;2004.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0100">[XEP-0100]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a> and <a href="mailto:dizzyd@jabber.org">D. Smith</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0100.html">Gateway Interaction</a>,&rdquo; XSF XEP&nbsp;0100, October&nbsp;2005.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0114">[XEP-0114]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0114.html">Jabber Component Protocol</a>,&rdquo; XSF XEP&nbsp;0114, March&nbsp;2005.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0124">[XEP-0124]</a></td>
<td class="author-text"><a href="mailto:ian.paterson@clientside.co.uk">Paterson, I.</a>, <a href="mailto:dizzyd@jabber.org">Smith, D.</a>, and <a href="mailto:stpeter@jabber.org">P. Saint-Andre</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0124.html">Bidirectional-streams Over Synchronous HTTP (BOSH)</a>,&rdquo; XSF XEP&nbsp;0124, July&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0138">[XEP-0138]</a></td>
<td class="author-text"><a href="mailto:jhildebr@cisco.com">Hildebrand, J.</a> and <a href="mailto:stpeter@jabber.org">P. Saint-Andre</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0138.html">Stream Compression</a>,&rdquo; XSF XEP&nbsp;0138, May&nbsp;2009.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0156">[XEP-0156]</a></td>
<td class="author-text"><a href="mailto:jhildebrand@jabber.com">Hildebrand, J.</a> and <a href="mailto:stpeter@jabber.org">P. Saint-Andre</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0156.html">Discovering Alternative XMPP Connection Methods</a>,&rdquo; XSF XEP&nbsp;0156, June&nbsp;2007.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0160">[XEP-0160]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0160.html">Best Practices for Handling Offline Messages</a>,&rdquo; XSF XEP&nbsp;0160, January&nbsp;2006.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0174">[XEP-0174]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0174.html">Link-Local Messaging</a>,&rdquo; XSF XEP&nbsp;0174, November&nbsp;2008.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0175">[XEP-0175]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0175.html">Best Practices for Use of SASL ANONYMOUS</a>,&rdquo; XSF XEP&nbsp;0175, September&nbsp;2009.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0178">[XEP-0178]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a> and <a href="mailto:">P. Millard</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0178.html">Best Practices for Use of SASL EXTERNAL with Certificates</a>,&rdquo; XSF XEP&nbsp;0178, February&nbsp;2007.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0191">[XEP-0191]</a></td>
<td class="author-text"><a href="mailto:">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0191.html">Simple Communications Blocking</a>,&rdquo; XSF XEP&nbsp;0191, February&nbsp;2007.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0198">[XEP-0198]</a></td>
<td class="author-text"><a href="mailto:justin@affinix.com">Karneges, J.</a>, <a href="mailto:jhildebr@cisco.com">Hildebrand, J.</a>, <a href="mailto:">Saint-Andre, P.</a>, <a href="mailto:fabio.forno@gmail.com">Forno, F.</a>, Cridland, D., and M. Wild, &ldquo;<a href="http://xmpp.org/extensions/xep-0198.html">Stream Management</a>,&rdquo; XSF XEP&nbsp;0198, February&nbsp;2011.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0199">[XEP-0199]</a></td>
<td class="author-text"><a href="mailto:">Saint-Andre, P.</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0199.html">XMPP Ping</a>,&rdquo; XSF XEP&nbsp;0199, June&nbsp;2009.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0205">[XEP-0205]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0205.html">Best Practices to Discourage Denial of Service Attacks</a>,&rdquo; XSF XEP&nbsp;0205, January&nbsp;2009.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0206">[XEP-0206]</a></td>
<td class="author-text"><a href="mailto:ian.paterson@clientside.co.uk">Paterson, I.</a> and <a href="mailto:stpeter@jabber.org">P. Saint-Andre</a>, &ldquo;<a href="http://www.xmpp.org/extensions/xep-0206.html">XMPP Over BOSH</a>,&rdquo; XSF XEP&nbsp;0206, July&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0220">[XEP-0220]</a></td>
<td class="author-text"><a href="mailto:jer@jabber.org">Miller, J.</a>, <a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, and <a href="mailto:">P. Hancke</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0220.html">Server Dialback</a>,&rdquo; XSF XEP&nbsp;0220, March&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0225">[XEP-0225]</a></td>
<td class="author-text"><a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0225.html">Component Connections</a>,&rdquo; XSF XEP&nbsp;0225, October&nbsp;2008.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0233">[XEP-0233]</a></td>
<td class="author-text"><a href="mailto:linuxwolf@outer-planes.net">Miller, M.</a>, <a href="mailto:stpeter@jabber.org">Saint-Andre, P.</a>, and <a href="mailto:jhildebr@cisco.com">J. Hildebrand</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0233.html">Domain-Based Service Names in XMPP SASL Negotiation</a>,&rdquo; XSF XEP&nbsp;0233, June&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="XEP-0288">[XEP-0288]</a></td>
<td class="author-text"><a href="mailto:">Hancke, P.</a> and <a href="mailto:dave.cridland@isode.com">D. Cridland</a>, &ldquo;<a href="http://xmpp.org/extensions/xep-0288.html">Bidirectional Server-to-Server Connections</a>,&rdquo; XSF XEP&nbsp;0288, October&nbsp;2010.</td></tr>
<tr><td class="author-text" valign="top"><a name="XML-FRAG">[XML-FRAG]</a></td>
<td class="author-text">Grosso, P. and D. Veillard, &ldquo;<a href="http://www.w3.org/TR/2001/CR-xml-fragment-20010212">XML Fragment Interchange</a>,&rdquo; World Wide Web Consortium CR&nbsp;CR-xml-fragment-20010212, February&nbsp;2001 (<a href="http://www.w3.org/TR/2001/CR-xml-fragment-20010212">HTML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XML-REG">[XML-REG]</a></td>
<td class="author-text">Mealling, M., &ldquo;<a href="http://tools.ietf.org/html/rfc3688">The IETF XML Registry</a>,&rdquo; BCP&nbsp;81, RFC&nbsp;3688, January&nbsp;2004 (<a href="http://www.rfc-editor.org/rfc/rfc3688.txt">TXT</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XML-SCHEMA">[XML-SCHEMA]</a></td>
<td class="author-text">Thompson, H., Maloney, M., Mendelsohn, N., and D. Beech, &ldquo;<a href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028">XML Schema Part 1: Structures Second Edition</a>,&rdquo; World Wide Web Consortium Recommendation&nbsp;REC-xmlschema-1-20041028, October&nbsp;2004 (<a href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028">HTML</a>).</td></tr>
<tr><td class="author-text" valign="top"><a name="XMPP-URI">[XMPP-URI]</a></td>
<td class="author-text">Saint-Andre, P., &ldquo;<a href="http://tools.ietf.org/html/rfc5122">Internationalized Resource Identifiers (IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP)</a>,&rdquo; RFC&nbsp;5122, February&nbsp;2008 (<a href="http://www.rfc-editor.org/rfc/rfc5122.txt">TXT</a>).</td></tr>
</table>

<a name="schema"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A"></a><h3>Appendix A.&nbsp;
XML Schemas</h3>

<p>The following schemas formally define various namespaces used in this document, in conformance with <a class='info' href='#XML-SCHEMA'>[XML&#8209;SCHEMA]<span> (</span><span class='info'>Thompson, H., Maloney, M., Mendelsohn, N., and D. Beech, &ldquo;XML Schema Part 1: Structures Second Edition,&rdquo; October&nbsp;2004.</span><span>)</span></a>.  Because validation of XML streams and stanzas is optional, these schemas are not normative and are provided for descriptive purposes only.
</p>
<a name="schemas-stream"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.1"></a><h3>A.1.&nbsp;
Stream Namespace</h3>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;?xml version='1.0' encoding='UTF-8'?&gt;

&lt;xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://etherx.jabber.org/streams'
    xmlns='http://etherx.jabber.org/streams'
    elementFormDefault='unqualified'&gt;

  &lt;xs:import namespace='jabber:client'/&gt;
  &lt;xs:import namespace='jabber:server'/&gt;
  &lt;xs:import namespace='urn:ietf:params:xml:ns:xmpp-sasl'/&gt;
  &lt;xs:import namespace='urn:ietf:params:xml:ns:xmpp-streams'/&gt;
  &lt;xs:import namespace='urn:ietf:params:xml:ns:xmpp-tls'/&gt;

  &lt;xs:element name='stream'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence xmlns:client='jabber:client'
                   xmlns:server='jabber:server'&gt;
        &lt;xs:element ref='features'
                    minOccurs='0'
                    maxOccurs='1'/&gt;
        &lt;xs:any namespace='urn:ietf:params:xml:ns:xmpp-tls'
                minOccurs='0'
                maxOccurs='1'/&gt;
        &lt;xs:any namespace='urn:ietf:params:xml:ns:xmpp-sasl'
                minOccurs='0'
                maxOccurs='1'/&gt;
        &lt;xs:any namespace='##other'
                minOccurs='0'
                maxOccurs='unbounded'
                processContents='lax'/&gt;
        &lt;xs:choice minOccurs='0' maxOccurs='1'&gt;
          &lt;xs:choice minOccurs='0' maxOccurs='unbounded'&gt;
            &lt;xs:element ref='client:message'/&gt;
            &lt;xs:element ref='client:presence'/&gt;
            &lt;xs:element ref='client:iq'/&gt;
          &lt;/xs:choice&gt;
          &lt;xs:choice minOccurs='0' maxOccurs='unbounded'&gt;
            &lt;xs:element ref='server:message'/&gt;
            &lt;xs:element ref='server:presence'/&gt;
            &lt;xs:element ref='server:iq'/&gt;
          &lt;/xs:choice&gt;
        &lt;/xs:choice&gt;
        &lt;xs:element ref='error' minOccurs='0' maxOccurs='1'/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name='from' type='xs:string' use='optional'/&gt;
      &lt;xs:attribute name='id' type='xs:string' use='optional'/&gt;
      &lt;xs:attribute name='to' type='xs:string' use='optional'/&gt;
      &lt;xs:attribute name='version' type='xs:decimal' use='optional'/&gt;
      &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
      &lt;xs:anyAttribute namespace='##other' processContents='lax'/&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='features'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:any namespace='##other'
                minOccurs='0'
                maxOccurs='unbounded'
                processContents='lax'/&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='error'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence  xmlns:err='urn:ietf:params:xml:ns:xmpp-streams'&gt;
        &lt;xs:group   ref='err:streamErrorGroup'/&gt;
        &lt;xs:element ref='err:text'
                    minOccurs='0'
                    maxOccurs='1'/&gt;
        &lt;xs:any     namespace='##other'
                    minOccurs='0'
                    maxOccurs='1'
                    processContents='lax'/&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

&lt;/xs:schema&gt;
</pre></div>
<a name="schemas-streamerror"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.2"></a><h3>A.2.&nbsp;
Stream Error Namespace</h3>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;?xml version='1.0' encoding='UTF-8'?&gt;

&lt;xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:ietf:params:xml:ns:xmpp-streams'
    xmlns='urn:ietf:params:xml:ns:xmpp-streams'
    elementFormDefault='qualified'&gt;

  &lt;xs:element name='bad-format' type='empty'/&gt;
  &lt;xs:element name='bad-namespace-prefix' type='empty'/&gt;
  &lt;xs:element name='conflict' type='empty'/&gt;
  &lt;xs:element name='connection-timeout' type='empty'/&gt;
  &lt;xs:element name='host-gone' type='empty'/&gt;
  &lt;xs:element name='host-unknown' type='empty'/&gt;
  &lt;xs:element name='improper-addressing' type='empty'/&gt;
  &lt;xs:element name='internal-server-error' type='empty'/&gt;
  &lt;xs:element name='invalid-from' type='empty'/&gt;
  &lt;xs:element name='invalid-id' type='empty'/&gt;
  &lt;xs:element name='invalid-namespace' type='empty'/&gt;
  &lt;xs:element name='invalid-xml' type='empty'/&gt;
  &lt;xs:element name='not-authorized' type='empty'/&gt;
  &lt;xs:element name='not-well-formed' type='empty'/&gt;
  &lt;xs:element name='policy-violation' type='empty'/&gt;
  &lt;xs:element name='remote-connection-failed' type='empty'/&gt;
  &lt;xs:element name='reset' type='empty'/&gt;
  &lt;xs:element name='resource-constraint' type='empty'/&gt;
  &lt;xs:element name='restricted-xml' type='empty'/&gt;
  &lt;xs:element name='see-other-host' type='xs:string'/&gt;
  &lt;xs:element name='system-shutdown' type='empty'/&gt;
  &lt;xs:element name='undefined-condition' type='empty'/&gt;
  &lt;xs:element name='unsupported-encoding' type='empty'/&gt;
  &lt;xs:element name='unsupported-stanza-type' type='empty'/&gt;
  &lt;xs:element name='unsupported-version' type='empty'/&gt;

  &lt;xs:group name='streamErrorGroup'&gt;
    &lt;xs:choice&gt;
      &lt;xs:element ref='bad-format'/&gt;
      &lt;xs:element ref='bad-namespace-prefix'/&gt;
      &lt;xs:element ref='conflict'/&gt;
      &lt;xs:element ref='connection-timeout'/&gt;
      &lt;xs:element ref='host-gone'/&gt;
      &lt;xs:element ref='host-unknown'/&gt;
      &lt;xs:element ref='improper-addressing'/&gt;
      &lt;xs:element ref='internal-server-error'/&gt;
      &lt;xs:element ref='invalid-from'/&gt;
      &lt;xs:element ref='invalid-id'/&gt;
      &lt;xs:element ref='invalid-namespace'/&gt;
      &lt;xs:element ref='invalid-xml'/&gt;
      &lt;xs:element ref='not-authorized'/&gt;
      &lt;xs:element ref='not-well-formed'/&gt;
      &lt;xs:element ref='policy-violation'/&gt;
      &lt;xs:element ref='remote-connection-failed'/&gt;
      &lt;xs:element ref='reset'/&gt;
      &lt;xs:element ref='resource-constraint'/&gt;
      &lt;xs:element ref='restricted-xml'/&gt;
      &lt;xs:element ref='see-other-host'/&gt;
      &lt;xs:element ref='system-shutdown'/&gt;
      &lt;xs:element ref='undefined-condition'/&gt;
      &lt;xs:element ref='unsupported-encoding'/&gt;
      &lt;xs:element ref='unsupported-stanza-type'/&gt;
      &lt;xs:element ref='unsupported-version'/&gt;
    &lt;/xs:choice&gt;
  &lt;/xs:group&gt;

  &lt;xs:element name='text'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:string'&gt;
          &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:simpleType name='empty'&gt;
    &lt;xs:restriction base='xs:string'&gt;
      &lt;xs:enumeration value=''/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;

&lt;/xs:schema&gt;
</pre></div>
<a name="schemas-starttls"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.3"></a><h3>A.3.&nbsp;
STARTTLS Namespace</h3>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;?xml version='1.0' encoding='UTF-8'?&gt;

&lt;xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:ietf:params:xml:ns:xmpp-tls'
    xmlns='urn:ietf:params:xml:ns:xmpp-tls'
    elementFormDefault='qualified'&gt;

  &lt;xs:element name='starttls'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:choice minOccurs='0' maxOccurs='1'&gt;
        &lt;xs:element name='required' type='empty'/&gt;
      &lt;/xs:choice&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='proceed' type='empty'/&gt;

  &lt;xs:element name='failure' type='empty'/&gt;

  &lt;xs:simpleType name='empty'&gt;
    &lt;xs:restriction base='xs:string'&gt;
      &lt;xs:enumeration value=''/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;

&lt;/xs:schema&gt;
</pre></div>
<a name="schemas-sasl"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.4"></a><h3>A.4.&nbsp;
SASL Namespace</h3>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;?xml version='1.0' encoding='UTF-8'?&gt;

&lt;xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:ietf:params:xml:ns:xmpp-sasl'
    xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
    elementFormDefault='qualified'&gt;

  &lt;xs:element name='mechanisms'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name='mechanism'
                    minOccurs='1'
                    maxOccurs='unbounded'
                    type='xs:NMTOKEN'/&gt;
        &lt;xs:any namespace='##other'
                minOccurs='0'
                maxOccurs='unbounded'
                processContents='lax'/&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='abort' type='empty'/&gt;

  &lt;xs:element name='auth'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:string'&gt;
          &lt;xs:attribute name='mechanism'
                        type='xs:NMTOKEN'
                        use='required'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='challenge' type='xs:string'/&gt;

  &lt;xs:element name='response' type='xs:string'/&gt;

  &lt;xs:element name='success' type='xs:string'/&gt;

  &lt;xs:element name='failure'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:choice minOccurs='0'&gt;
          &lt;xs:element name='aborted' type='empty'/&gt;
          &lt;xs:element name='account-disabled' type='empty'/&gt;
          &lt;xs:element name='credentials-expired' type='empty'/&gt;
          &lt;xs:element name='encryption-required' type='empty'/&gt;
          &lt;xs:element name='incorrect-encoding' type='empty'/&gt;
          &lt;xs:element name='invalid-authzid' type='empty'/&gt;
          &lt;xs:element name='invalid-mechanism' type='empty'/&gt;
          &lt;xs:element name='malformed-request' type='empty'/&gt;
          &lt;xs:element name='mechanism-too-weak' type='empty'/&gt;
          &lt;xs:element name='not-authorized' type='empty'/&gt;
          &lt;xs:element name='temporary-auth-failure' type='empty'/&gt;
        &lt;/xs:choice&gt;
        &lt;xs:element ref='text' minOccurs='0' maxOccurs='1'/&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='text'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:string'&gt;
          &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:simpleType name='empty'&gt;
    &lt;xs:restriction base='xs:string'&gt;
      &lt;xs:enumeration value=''/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;

&lt;/xs:schema&gt;
</pre></div>
<a name="schemas-client"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.5"></a><h3>A.5.&nbsp;
Client Namespace</h3>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;?xml version='1.0' encoding='UTF-8'?&gt;

&lt;xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='jabber:client'
    xmlns='jabber:client'
    elementFormDefault='qualified'&gt;

  &lt;xs:import
      namespace='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;

  &lt;xs:element name='message'&gt;
     &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:choice minOccurs='0' maxOccurs='unbounded'&gt;
            &lt;xs:element ref='subject'/&gt;
            &lt;xs:element ref='body'/&gt;
            &lt;xs:element ref='thread'/&gt;
          &lt;/xs:choice&gt;
          &lt;xs:any     namespace='##other'
                      minOccurs='0'
                      maxOccurs='unbounded'
                      processContents='lax'/&gt;
          &lt;xs:element ref='error'
                      minOccurs='0'/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name='from'
                      type='xs:string'
                      use='optional'/&gt;
        &lt;xs:attribute name='id'
                      type='xs:NMTOKEN'
                      use='optional'/&gt;
        &lt;xs:attribute name='to'
                      type='xs:string'
                      use='optional'/&gt;
        &lt;xs:attribute name='type'
                      use='optional'
                      default='normal'&gt;
          &lt;xs:simpleType&gt;
            &lt;xs:restriction base='xs:NMTOKEN'&gt;
              &lt;xs:enumeration value='chat'/&gt;
              &lt;xs:enumeration value='error'/&gt;
              &lt;xs:enumeration value='groupchat'/&gt;
              &lt;xs:enumeration value='headline'/&gt;
              &lt;xs:enumeration value='normal'/&gt;
            &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
        &lt;/xs:attribute&gt;
        &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
     &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='body'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:string'&gt;
          &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='subject'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:string'&gt;
          &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='thread'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:NMTOKEN'&gt;
          &lt;xs:attribute name='parent'
                        type='xs:NMTOKEN'
                        use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='presence'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:choice minOccurs='0' maxOccurs='unbounded'&gt;
          &lt;xs:element ref='show'/&gt;
          &lt;xs:element ref='status'/&gt;
          &lt;xs:element ref='priority'/&gt;
        &lt;/xs:choice&gt;
        &lt;xs:any     namespace='##other'
                    minOccurs='0'
                    maxOccurs='unbounded'
                    processContents='lax'/&gt;
        &lt;xs:element ref='error'
                    minOccurs='0'/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name='from'
                    type='xs:string'
                    use='optional'/&gt;
      &lt;xs:attribute name='id'
                    type='xs:NMTOKEN'
                    use='optional'/&gt;
      &lt;xs:attribute name='to'
                    type='xs:string'
                    use='optional'/&gt;
      &lt;xs:attribute name='type' use='optional'&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base='xs:NMTOKEN'&gt;
            &lt;xs:enumeration value='error'/&gt;
            &lt;xs:enumeration value='probe'/&gt;
            &lt;xs:enumeration value='subscribe'/&gt;
            &lt;xs:enumeration value='subscribed'/&gt;
            &lt;xs:enumeration value='unavailable'/&gt;
            &lt;xs:enumeration value='unsubscribe'/&gt;
            &lt;xs:enumeration value='unsubscribed'/&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:attribute&gt;
      &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='show'&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:restriction base='xs:NMTOKEN'&gt;
        &lt;xs:enumeration value='away'/&gt;
        &lt;xs:enumeration value='chat'/&gt;
        &lt;xs:enumeration value='dnd'/&gt;
        &lt;xs:enumeration value='xa'/&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='status'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='string1024'&gt;
          &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:simpleType name='string1024'&gt;
    &lt;xs:restriction base='xs:string'&gt;
      &lt;xs:minLength value='1'/&gt;
      &lt;xs:maxLength value='1024'/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;

  &lt;xs:element name='priority' type='xs:byte'/&gt;

  &lt;xs:element name='iq'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:any     namespace='##other'
                    minOccurs='0'
                    maxOccurs='1'
                    processContents='lax'/&gt;
        &lt;xs:element ref='error'
                    minOccurs='0'/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name='from'
                    type='xs:string'
                    use='optional'/&gt;
      &lt;xs:attribute name='id'
                    type='xs:NMTOKEN'
                    use='required'/&gt;
      &lt;xs:attribute name='to'
                    type='xs:string'
                    use='optional'/&gt;
      &lt;xs:attribute name='type' use='required'&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base='xs:NMTOKEN'&gt;
            &lt;xs:enumeration value='error'/&gt;
            &lt;xs:enumeration value='get'/&gt;
            &lt;xs:enumeration value='result'/&gt;
            &lt;xs:enumeration value='set'/&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:attribute&gt;
      &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='error'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence xmlns:err='urn:ietf:params:xml:ns:xmpp-stanzas'&gt;
        &lt;xs:group ref='err:stanzaErrorGroup'/&gt;
        &lt;xs:element ref='err:text'
                    minOccurs='0'/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name='by'
                    type='xs:string'
                    use='optional'/&gt;
      &lt;xs:attribute name='type' use='required'&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base='xs:NMTOKEN'&gt;
            &lt;xs:enumeration value='auth'/&gt;
            &lt;xs:enumeration value='cancel'/&gt;
            &lt;xs:enumeration value='continue'/&gt;
            &lt;xs:enumeration value='modify'/&gt;
            &lt;xs:enumeration value='wait'/&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:attribute&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

&lt;/xs:schema&gt;
</pre></div>
<a name="schemas-server"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.6"></a><h3>A.6.&nbsp;
Server Namespace</h3>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;?xml version='1.0' encoding='UTF-8'?&gt;

&lt;xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='jabber:server'
    xmlns='jabber:server'
    elementFormDefault='qualified'&gt;

  &lt;xs:import
      namespace='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;

  &lt;xs:element name='message'&gt;
     &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:choice minOccurs='0' maxOccurs='unbounded'&gt;
            &lt;xs:element ref='subject'/&gt;
            &lt;xs:element ref='body'/&gt;
            &lt;xs:element ref='thread'/&gt;
          &lt;/xs:choice&gt;
          &lt;xs:any namespace='##other'
                  minOccurs='0'
                  maxOccurs='unbounded'
                  processContents='lax'/&gt;
          &lt;xs:element ref='error'
                      minOccurs='0'/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name='from'
                      type='xs:string'
                      use='required'/&gt;
        &lt;xs:attribute name='id'
                      type='xs:NMTOKEN'
                      use='optional'/&gt;
        &lt;xs:attribute name='to'
                      type='xs:string'
                      use='required'/&gt;
        &lt;xs:attribute name='type'
                      use='optional'
                      default='normal'&gt;
          &lt;xs:simpleType&gt;
            &lt;xs:restriction base='xs:NMTOKEN'&gt;
              &lt;xs:enumeration value='chat'/&gt;
              &lt;xs:enumeration value='error'/&gt;
              &lt;xs:enumeration value='groupchat'/&gt;
              &lt;xs:enumeration value='headline'/&gt;
              &lt;xs:enumeration value='normal'/&gt;
            &lt;/xs:restriction&gt;
          &lt;/xs:simpleType&gt;
        &lt;/xs:attribute&gt;
        &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
     &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='body'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:string'&gt;
          &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='subject'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:string'&gt;
          &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='thread'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:NMTOKEN'&gt;
          &lt;xs:attribute name='parent'
                        type='xs:NMTOKEN'
                        use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='subject'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:NMTOKEN'&gt;
          &lt;xs:attribute name='parent'
                        type='xs:NMTOKEN'
                        use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='presence'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:choice minOccurs='0' maxOccurs='unbounded'&gt;
          &lt;xs:element ref='show'/&gt;
          &lt;xs:element ref='status'/&gt;
          &lt;xs:element ref='priority'/&gt;
        &lt;/xs:choice&gt;
        &lt;xs:any     namespace='##other'
                    minOccurs='0'
                    maxOccurs='unbounded'
                    processContents='lax'/&gt;
        &lt;xs:element ref='error'
                    minOccurs='0'/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name='from'
                    type='xs:string'
                    use='required'/&gt;
      &lt;xs:attribute name='id'
                    type='xs:NMTOKEN'
                    use='optional'/&gt;
      &lt;xs:attribute name='to'
                    type='xs:string'
                    use='required'/&gt;
      &lt;xs:attribute name='type' use='optional'&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base='xs:NMTOKEN'&gt;
            &lt;xs:enumeration value='error'/&gt;
            &lt;xs:enumeration value='probe'/&gt;
            &lt;xs:enumeration value='subscribe'/&gt;
            &lt;xs:enumeration value='subscribed'/&gt;
            &lt;xs:enumeration value='unavailable'/&gt;
            &lt;xs:enumeration value='unsubscribe'/&gt;
            &lt;xs:enumeration value='unsubscribed'/&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:attribute&gt;
      &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='show'&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:restriction base='xs:NMTOKEN'&gt;
        &lt;xs:enumeration value='away'/&gt;
        &lt;xs:enumeration value='chat'/&gt;
        &lt;xs:enumeration value='dnd'/&gt;
        &lt;xs:enumeration value='xa'/&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='status'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='string1024'&gt;
          &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:simpleType name='string1024'&gt;
    &lt;xs:restriction base='xs:string'&gt;
      &lt;xs:minLength value='1'/&gt;
      &lt;xs:maxLength value='1024'/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;

  &lt;xs:element name='priority' type='xs:byte' default='0'/&gt;

  &lt;xs:element name='iq'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:any namespace='##other'
                minOccurs='0'
                maxOccurs='1'
                processContents='lax'/&gt;
        &lt;xs:element ref='error'
                    minOccurs='0'/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name='from'
                    type='xs:string'
                    use='required'/&gt;
      &lt;xs:attribute name='id'
                    type='xs:NMTOKEN'
                    use='required'/&gt;
      &lt;xs:attribute name='to'
                    type='xs:string'
                    use='required'/&gt;
      &lt;xs:attribute name='type' use='required'&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base='xs:NMTOKEN'&gt;
            &lt;xs:enumeration value='error'/&gt;
            &lt;xs:enumeration value='get'/&gt;
            &lt;xs:enumeration value='result'/&gt;
            &lt;xs:enumeration value='set'/&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:attribute&gt;
      &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:element name='error'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence xmlns:err='urn:ietf:params:xml:ns:xmpp-stanzas'&gt;
        &lt;xs:group ref='err:stanzaErrorGroup'/&gt;
        &lt;xs:element ref='err:text'
                    minOccurs='0'/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attribute name='by'
                    type='xs:string'
                    use='optional'/&gt;
      &lt;xs:attribute name='type' use='required'&gt;
        &lt;xs:simpleType&gt;
          &lt;xs:restriction base='xs:NMTOKEN'&gt;
            &lt;xs:enumeration value='auth'/&gt;
            &lt;xs:enumeration value='cancel'/&gt;
            &lt;xs:enumeration value='continue'/&gt;
            &lt;xs:enumeration value='modify'/&gt;
            &lt;xs:enumeration value='wait'/&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      &lt;/xs:attribute&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

&lt;/xs:schema&gt;
</pre></div>
<a name="schemas-bind"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.7"></a><h3>A.7.&nbsp;
Resource Binding Namespace</h3>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;?xml version='1.0' encoding='UTF-8'?&gt;

&lt;xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:ietf:params:xml:ns:xmpp-bind'
    xmlns='urn:ietf:params:xml:ns:xmpp-bind'
    elementFormDefault='qualified'&gt;

  &lt;xs:element name='bind'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:choice&gt;
        &lt;xs:element name='resource' type='resourceType'/&gt;
        &lt;xs:element name='jid' type='fullJIDType'/&gt;
      &lt;/xs:choice&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:simpleType name='fullJIDType'&gt;
    &lt;xs:restriction base='xs:string'&gt;
      &lt;xs:minLength value='8'/&gt;
      &lt;xs:maxLength value='3071'/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;

  &lt;xs:simpleType name='resourceType'&gt;
    &lt;xs:restriction base='xs:string'&gt;
      &lt;xs:minLength value='1'/&gt;
      &lt;xs:maxLength value='1023'/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;

&lt;/xs:schema&gt;
</pre></div>
<a name="schemas-stanzaerror"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.A.8"></a><h3>A.8.&nbsp;
Stanza Error Namespace</h3>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
&lt;?xml version='1.0' encoding='UTF-8'?&gt;

&lt;xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:ietf:params:xml:ns:xmpp-stanzas'
    xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'
    elementFormDefault='qualified'&gt;

  &lt;xs:element name='bad-request' type='empty'/&gt;
  &lt;xs:element name='conflict' type='empty'/&gt;
  &lt;xs:element name='feature-not-implemented' type='empty'/&gt;
  &lt;xs:element name='forbidden' type='empty'/&gt;
  &lt;xs:element name='gone' type='xs:string'/&gt;
  &lt;xs:element name='internal-server-error' type='empty'/&gt;
  &lt;xs:element name='item-not-found' type='empty'/&gt;
  &lt;xs:element name='jid-malformed' type='empty'/&gt;
  &lt;xs:element name='not-acceptable' type='empty'/&gt;
  &lt;xs:element name='not-allowed' type='empty'/&gt;
  &lt;xs:element name='not-authorized' type='empty'/&gt;
  &lt;xs:element name='policy-violation' type='empty'/&gt;
  &lt;xs:element name='recipient-unavailable' type='empty'/&gt;
  &lt;xs:element name='redirect' type='xs:string'/&gt;
  &lt;xs:element name='registration-required' type='empty'/&gt;
  &lt;xs:element name='remote-server-not-found' type='empty'/&gt;
  &lt;xs:element name='remote-server-timeout' type='empty'/&gt;
  &lt;xs:element name='resource-constraint' type='empty'/&gt;
  &lt;xs:element name='service-unavailable' type='empty'/&gt;
  &lt;xs:element name='subscription-required' type='empty'/&gt;
  &lt;xs:element name='undefined-condition' type='empty'/&gt;
  &lt;xs:element name='unexpected-request' type='empty'/&gt;

  &lt;xs:group name='stanzaErrorGroup'&gt;
    &lt;xs:choice&gt;
      &lt;xs:element ref='bad-request'/&gt;
      &lt;xs:element ref='conflict'/&gt;
      &lt;xs:element ref='feature-not-implemented'/&gt;
      &lt;xs:element ref='forbidden'/&gt;
      &lt;xs:element ref='gone'/&gt;
      &lt;xs:element ref='internal-server-error'/&gt;
      &lt;xs:element ref='item-not-found'/&gt;
      &lt;xs:element ref='jid-malformed'/&gt;
      &lt;xs:element ref='not-acceptable'/&gt;
      &lt;xs:element ref='not-authorized'/&gt;
      &lt;xs:element ref='not-allowed'/&gt;
      &lt;xs:element ref='policy-violation'/&gt;
      &lt;xs:element ref='recipient-unavailable'/&gt;
      &lt;xs:element ref='redirect'/&gt;
      &lt;xs:element ref='registration-required'/&gt;
      &lt;xs:element ref='remote-server-not-found'/&gt;
      &lt;xs:element ref='remote-server-timeout'/&gt;
      &lt;xs:element ref='resource-constraint'/&gt;
      &lt;xs:element ref='service-unavailable'/&gt;
      &lt;xs:element ref='subscription-required'/&gt;
      &lt;xs:element ref='undefined-condition'/&gt;
      &lt;xs:element ref='unexpected-request'/&gt;
    &lt;/xs:choice&gt;
  &lt;/xs:group&gt;

  &lt;xs:element name='text'&gt;
    &lt;xs:complexType&gt;
      &lt;xs:simpleContent&gt;
        &lt;xs:extension base='xs:string'&gt;
          &lt;xs:attribute ref='xml:lang' use='optional'/&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:simpleType name='empty'&gt;
    &lt;xs:restriction base='xs:string'&gt;
      &lt;xs:enumeration value=''/&gt;
    &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;

&lt;/xs:schema&gt;
</pre></div>
<a name="contact"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.B"></a><h3>Appendix B.&nbsp;
Contact Addresses</h3>

<p>Consistent with <a class='info' href='#MAILBOXES'>[MAILBOXES]<span> (</span><span class='info'>Crocker, D., &ldquo;MAILBOX NAMES FOR COMMON SERVICES, ROLES AND FUNCTIONS,&rdquo; May&nbsp;1997.</span><span>)</span></a>, organization that offer XMPP services are encouraged to provide an Internet mailbox of "XMPP" for inquiries related to that service, where the host portion of the resulting mailto URI is the organization's domain, not the domain of the XMPP service itself (e.g., the XMPP service might be offered at im.example.com but the Internet mailbox would be &lt;xmpp@example.com&gt;).
</p>
<a name="provisioning"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.C"></a><h3>Appendix C.&nbsp;
Account Provisioning</h3>

<p>Account provisioning is out of scope for this specification.
      Possible methods for account provisioning include account
      creation by a server administrator and in-band account
      registration using the 'jabber:iq:register' namespace as
      documented in <a class='info' href='#XEP-0077'>[XEP&#8209;0077]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;In-Band Registration,&rdquo; September&nbsp;2009.</span><span>)</span></a>.  An XMPP server
      implementation or administrative function MUST ensure that any
      JID assigned during account provisioning (including localpart,
      domainpart, resourcepart, and separator characters) conforms to
      the canonical format for XMPP addresses defined in
      <a class='info' href='#XMPP-ADDR'>[XMPP&#8209;ADDR]<span> (</span><span class='info'>Saint-Andre, P., &ldquo;Extensible Messaging and Presence Protocol (XMPP): Address Format,&rdquo; March&nbsp;2011.</span><span>)</span></a>.
</p>
<a name="diffs"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.D"></a><h3>Appendix D.&nbsp;
Differences from RFC 3920</h3>

<p>Based on consensus derived from implementation and deployment experience as well as formal interoperability testing, the following substantive modifications were made from RFC 3920 (in addition to numerous changes of an editorial nature).
</p>
<p>
        </p>
<ul class="text">
<li>Moved specification of the XMPP address format to a separate document.
</li>
<li>Recommended or mandated use of the 'from' and 'to' attributes on stream headers.
</li>
<li>More fully specified the stream closing handshake.
</li>
<li>Specified the recommended stream reconnection algorithm.
</li>
<li>Changed the name of the &lt;xml-not-well-formed/&gt; stream error condition to &lt;not-well-formed/&gt; for compliance with the XML specification.
</li>
<li>Removed the unnecessary and unused &lt;invalid-id/&gt; stream error (see RFC 3920 for historical documentation).
</li>
<li>Specified return of the &lt;restricted-xml/&gt; stream error in response to receipt of prohibited XML features.
</li>
<li>More completely specified the format and handling of the &lt;see-other-host/&gt; stream error, including consistency with RFC 3986 and RFC 5952 with regard to IPv6 addresses (e.g., enclosing the IPv6 address in square brackets '[' and ']').
</li>
<li>Specified that the SASL SCRAM mechanism is a mandatory-to-implement technology for client-to-server streams.
</li>
<li>Specified that TLS plus the SASL PLAIN mechanism is a mandatory-to-implement technology for client-to-server streams.
</li>
<li>Specified that support for the SASL EXTERNAL mechanism is required for servers but only recommended for clients (since end-user X.509 certificates are difficult to obtain and not yet widely deployed).
</li>
<li>Removed the hard two-connection rule for server-to-server streams.
</li>
<li>More clearly specified the certificate profile for both public key certificates and issuer certificates.
</li>
<li>Added the &lt;reset/&gt; stream error (<a class='info' href='#streams-error-conditions-reset'>Section&nbsp;4.9.3.16<span> (</span><span class='info'>reset</span><span>)</span></a>) condition to handle expired/revoked certificates or the addition of security-critical features to an existing stream.
</li>
<li>Added the &lt;account-disabled/&gt;, &lt;credentials-expired/&gt;, &lt;encryption-required/&gt;, and &lt;malformed-request/&gt; SASL error conditions to handle error flows mistakenly left out of RFC 3920 or discussed in RFC 4422 but not in RFC 2222.
</li>
<li>Removed the unused &lt;payment-required/&gt; stanza error.
</li>
<li>Removed the unnecessary requirement for escaping of characters that map to certain predefined entities, since they do not need to be escaped in XML.
</li>
<li>Clarified the process of DNS SRV lookups and fallbacks.
</li>
<li>Clarified the handling of SASL security layers.
</li>
<li>Clarified that a SASL simple user name is the localpart, not the bare JID.
</li>
<li>Clarified the stream negotiation process and associated flow chart.
</li>
<li>Clarified the handling of stream features.
</li>
<li>Added a 'by' attribute to the &lt;error/&gt; element for stanza errors so that the entity that has detected the error can include its JID for diagnostic or tracking purposes.
</li>
<li>Clarified the handling of data that violates the well-formedness definitions for XML 1.0 and XML namespaces.
</li>
<li>Specified the security considerations in more detail, especially with regard to presence leaks and denial-of-service attacks.
</li>
<li>Moved documentation of the Server Dialback protocol from this specification to a separate specification maintained by the XMPP Standards Foundation.
</li>
</ul><p>
      
</p>
<a name="intro-ack"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<a name="rfc.section.E"></a><h3>Appendix E.&nbsp;
Acknowledgements</h3>

<p>This document is an update to, and derived from, RFC 3920.  This document would have been impossible without the work of the contributors and commenters acknowledged there.
</p>
<p>Hundreds of people have provided implementation feedback, bug reports, requests for clarification, and suggestions for improvement since publication of RFC 3920.  Although the document editor has endeavored to address all such feedback, he is solely responsible for any remaining errors and ambiguities.
</p>
<p>Special thanks are due to Kevin Smith, Matthew Wild, Dave Cridland, Philipp Hancke, Waqas Hussain, Florian Zeitz, Ben Campbell, Jehan Pages, Paul Aurich, Justin Karneges, Kurt Zeilenga, Simon Josefsson, Ralph Meijer, Curtis King, and others for their comments during Working Group Last Call.
</p>
<p>Thanks also to Yaron Sheffer and Elwyn Davies for their reviews on behalf of the Security Directorate and the General Area Review Team, respectively.
</p>
<p>The Working Group chairs were Ben Campbell and Joe Hildebrand.  The responsible Area Director was Gonzalo Camarillo.
</p>
<a name="rfc.authors"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc">&nbsp;TOC&nbsp;</a></td></tr></table>
<h3>Author's Address</h3>
<table width="99%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="author-text">&nbsp;</td>
<td class="author-text">Peter Saint-Andre</td></tr>
<tr><td class="author-text">&nbsp;</td>
<td class="author-text">Cisco</td></tr>
<tr><td class="author-text">&nbsp;</td>
<td class="author-text">1899 Wyknoop Street, Suite 600</td></tr>
<tr><td class="author-text">&nbsp;</td>
<td class="author-text">Denver, CO  80202</td></tr>
<tr><td class="author-text">&nbsp;</td>
<td class="author-text">USA</td></tr>
<tr><td class="author" align="right">Phone:&nbsp;</td>
<td class="author-text">+1-303-308-3282</td></tr>
<tr><td class="author" align="right">EMail:&nbsp;</td>
<td class="author-text"><a href="mailto:psaintan@cisco.com">psaintan@cisco.com</a></td></tr>
</table>
</body></html>