Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, May 3, 2019 8:31 AM
I get this error in versions with Android 5.0 and lower versions
Error : System.Net.WebException: Error: TrustFailure (A call to SSPI failed, see inner exception.) > System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. > Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSLinternal:CERTIFICATEVERIFYFAILED\n at /Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/external/boringssl/ssl/handshakeclient.c:1132\n at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00038] in :0 \n at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status) [0x0003e]
My Code: `string result = ""; try { HttpClient client = await GetClient(); var MyUrl = Url + "api/Univesitemain/Yemeklistesi";
result = await client.GetStringAsync(MyUrl);
}
catch (Exception ex)
{
var error = ex.ToString();
}
return JsonConvert.DeserializeObject<IEnumerable<YemekListesi>>(result);`
All replies (8)
Sunday, May 12, 2019 12:50 PM ✅Answered
My App it Worked after add this code To android MainActivity inside OnCreate() ServicePointManager.ServerCertificateValidationCallback += (o, cert, chain, errors) => true;
Monday, May 13, 2019 3:19 PM ✅Answered
Or add it like this
public async Task GetClient() { HttpClientHandler handler = new HttpClientHandler(); handler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true; HttpClient client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("Accept", "application/json"); return client; }
Friday, October 11, 2019 5:10 AM
hello @abdalrhman ,
which one is best and where should I assign client for the second solution you did return client.
Friday, October 11, 2019 7:04 AM
@vinothswami said: hello @abdalrhman ,
which one is best and where should I assign client for the second solution you did return client.
i am add thre second solution in my WebService class
Tuesday, October 15, 2019 3:19 PM
Thank you @abdalrhman, I did the first solution in Android main activity.
Friday, January 17, 2020 7:16 AM
@abdalrhman said: Or add it like this
public async Task GetClient() { HttpClientHandler handler = new HttpClientHandler(); handler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true; HttpClient client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("Accept", "application/json"); return client; }
I wish I was rich man, was gonna pay you for this, I almost abandoned one of my awesome projects and Xamarin completely because of this error. Thank you a million times. ???
Sunday, January 26, 2020 9:16 PM
@abdalrhman said: My App it Worked after add this code To android MainActivity inside OnCreate()
ServicePointManager.ServerCertificateValidationCallback += (o, cert, chain, errors) => true;
It didn´t work for me :'(
Friday, September 4, 2020 8:36 AM
Hmm. The accepted answer appears to be 'ignore any certificate errors'. Doesn't sound like a good solution to me.