虽然我使用以下代码在iOS和Android中固定证书,但我的回调被调用并且固定已完成,但是当使用TLS1.2更新服务器时,我们的回调被调用iOS,但它没有在Android中调用
void PinServerCertificate()
{
try
{
ServicePointManager.ServerCertificateValidationCallback += ServicePointManager_ServerCertificateValidationCallback;
WebRequest wr = WebRequest.Create(GlobalVariables.BaseURL);
wr.GetResponse();
}
catch (Exception ex)
{
RemoLogger.Log("Exception" + ex.Message);
}
}
bool ServicePointManager_ServerCertificateValidationCallback(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
if (null == certificate)
{
CertificateValidation.IsValid = false;
return false;
}
string pk = certificate.GetPublicKeyString();
if (pk.Equals(this.publicKey))
{
CertificateValidation.IsValid = true;
return true;
}
CertificateValidation.IsValid = false;
return false;
}
Followed below link for TLS1.2 support
我们使用AndroidClientHandler和Managed [HttpClientHandler]进行了检查,但没有得到任何解决方案,请告知我们在Android中出了什么问题。
感谢您的帮助