xmpp笔记2(客户端到服务器的例子)--xml

xmpp(

客户端到服务器的例子

)

1 步:客户端初始流给服务器: <stream:stream

xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='example.com'
version='1.0'>

步 2:服务器以发送给客户端一个流标记作为响应: <stream:stream

xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='c2s_123'
from='example.com'
version='1.0'>

步 3:服务器发送 STARTTLS 扩展给客户端,并带有认证机制与任何其它流特征: <stream:features>

<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'> <required/>

</starttls>
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>

<mechanism>DIGEST-MD5</mechanism>

<mechanism>PLAIN</mechanism> </mechanisms>

</stream:features>
步 4:客户端发送 STARTTLS 命令给服务器:

<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/> 步 5:服务器通知客户端它被允许处理

<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
步 5(替代):服务器通知客户端 TLS 协商失败,并关闭流与 TCP 连接:

<failure xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>

</stream:stream>
步 6:客户端与服务器试图协商通过现存的 TCP 连接 完成 TLS 协商。 步 7:如果 TLS 协商成功,客户端初始化一个新流给服务器:

<stream:stream xmlns='jabber:client'

xmlns:stream='http://etherx.jabber.org/streams' to='example.com'
version='1.0'>

步 7(代替 ):如果 TLS 协商不成功,服务器关闭 TCP 连接。
步 8:服务器靠发送带有任何可利用流特征的流头给客户端作为响应。

<stream:stream xmlns='jabber:client'

xmlns:stream='http://etherx.jabber.org/streams' from='example.com'
id='c2s_234'
version='1.0'>

<stream:features>
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>

<mechanism>DIGEST-MD5</mechanism> <mechanism>PLAIN</mechanism>

<mechanism>EXTERNAL</mechanism> </mechanisms>

</stream:features>
步 9:客户端继续 SASL 协商(6)

  

【微分享】:障碍与失败,是通往成功最稳靠的踏脚石,肯研究、利用它们,便能从失败中培养出成功。

posted @ 2016-03-18 13:32  super1250  阅读(281)  评论(0编辑  收藏  举报