简体   繁体   中英

XMPP TLS connection with SslStream

I am trying to create a simple xmpp client that connects to Gtalk. 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 .

The first SSlStream.Read is to receive the greeting reply, it went fine . 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."

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.

 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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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