在CertificateValidationCallBack中,当我在Android上运行此代码而在Windows上设置相同的值时,sender为null。下面的代码使用同步方法,但我也测试了异步,它们的行为相同。这是Xamarin.Android的错误还是我错过了什么?
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);
我正在运行所有Xamarin和Android SDK工具的最新版本(今天更新,2016年12月23日)。