I'm working on a Xamarin.Android app that has to communicate with a socket server with some of the calls needing to be encrypted.
OSX - 10.10.1 Xamarin Studio - Version 5.5.4 (build 15) Xamarin.Android - Version: 4.20.0.28 (Business Edition) App Target Framework - 4.0.3
I'm trying to get the SslStream class working based on some examples I've seen on MSDN.
TcpClient client = new TcpClient("myaddress", myport);
Console.WriteLine ("Connected...");
// Create an SSL stream that will close the client's stream.
SslStream sslStream = new SslStream(
client.GetStream(), false, new RemoteCertificateValidationCallback (ValidateServerCertificate), null);
sslStream.AuthenticateAsClient("myhost");
The call to AuthenticateAsClient fails with the following exception:
System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Incorrect protocol version received from server
The exact same code works fine under Windows running from Visual Studio and .NET 4.5 on the same machine and network configuration.
Any ideas why it behaves differently between Xamarin.Android and Windows? Also, anyone know of a reliable PCL base socket library?
thanks
Mark Reynolds