In CertificateValidationCallBack, sender is null when I run this code on Android while the same value is set on Windows. The code below uses sync methods but I also tested async and they behave the same. Is it a bug of Xamarin.Android or am I missing something?
static bool CertificateValidationCallBack(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
}
...
Socket sock = new Socket(SocketType.Stream, ProtocolType.Tcp);
sock.Connect(IPAddress.Parse("192.168.0.100"), 993);
NetworkStream ns = new NetworkStream(sock);
SslStream ssl = new SslStream(ns, true, CertificateValidationCallBack);
ssl.AuthenticateAsClient("localhost", null, SslProtocols.Tls12, false);
sock.Disconnect(false);
I'm running the up-to-date version of all Xamarin and Android SDK tools (updated today, 23-Dec-2016).