简体   繁体   English

与SslStream的XMPP TLS连接

[英]XMPP TLS connection with SslStream

I am trying to create a simple xmpp client that connects to Gtalk. 我正在尝试创建一个连接到Gtalk的简单xmpp客户端。 The first part of the handshake seems to work. 握手的第一部分似乎有效。 Ror the TLS handshake I created a client SslStream, connected to the intended server (talk.google.com) and successfully got authenticated . 通过TLS握手,我创建了一个客户端SslStream,并将其连接到目标服务器(talk.google.com)并成功通过了身份验证。

The first SSlStream.Read is to receive the greeting reply, it went fine . 第一个SSlStream.Read是接收问候回复,一切正常。 I do a SslStream.write to send my first command, but when i do my Sslstream.Read() to get the reply , i get this error."System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine." 我执行SslStream.write发送第一个命令,但是当我执行Sslstream.Read()以获取答复时,出现此错误。“ System.IO.IOException:无法从传输连接读取数据:已建立连接被您主机上的软件中止了。”

Can anyone point me to the right direction? 谁能指出我正确的方向?

I am using code very similar to the example on msdn http://msdn.microsoft.com/en-us/library/system.net.security.sslstream.aspx except that I switch from a Network stream to a Sslstream when TLS is negotiated. 我使用的代码与msdn http://msdn.microsoft.com/zh-cn/library/system.net.security.sslstream.aspx上的示例非常相似,不同之处在于,当TLS为TLS时,我从网络流切换到了Sslstream洽谈。

 netStream.Flush(); 
 sslStream = new SslStream(netStream,               
               true,
               new RemoteCertificateValidationCallback(ValidateServerCertificate),
               null
               );

  sslStream.AuthenticateAsClient("talk.google.com");

I'd try using one of the existing XMPP libraries for .Net: 我会尝试使用现有的.Net XMPP库之一:

Even if you don't use of these libs, you'll get some good ideas from looking at the code. 即使您不使用这些库,也可以通过查看代码获得一些好主意。

In this case, you probably want: 在这种情况下,您可能想要:

sslStream.AuthenticateAsClient("gmail.com");

where gmail.com is the domain name from the JID you're trying to log in as. 其中gmail.com是您要尝试登录的JID中的域名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM