Hi,
I'm trying to perform a client authentication with certificate.
I use the code below, it is working fine in Windows but I get an error in Android ( [ERROR] FATAL UNHANDLED EXCEPTION: System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.).
What is wrong?
byte[] bb = ...certificate...;
X509Certificate Cert = new X509Certificate2(bb, "pwd", X509KeyStorageFlags.UserKeySet);
string url = "....";
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
ServicePointManager.ServerCertificateValidationCallback += (sender1, cert, chain, sslPolicyErrors) => true;
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(url);
Request.ClientCertificates.Add(Cert);
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes("user:pwd"));
Request.Headers.Add("Authorization", "Basic " + encoded);
Request.UserAgent = "Client Cert Sample";
Request.Method = "GET";
HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();