locked
A call to SSPI failed SSL routines:OPENSSL s with Android 5.0 and lower versions RRS feed

  • Question

  • User380049 posted

    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);`
    
    Friday, May 3, 2019 8:31 AM

Answers

  • User380049 posted

    My App it Worked after add this code To android MainActivity inside OnCreate() ServicePointManager.ServerCertificateValidationCallback += (o, cert, chain, errors) => true;

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, May 12, 2019 12:50 PM
  • User380049 posted

    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; }

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, May 13, 2019 3:19 PM

All replies

  • User380049 posted

    My App it Worked after add this code To android MainActivity inside OnCreate() ServicePointManager.ServerCertificateValidationCallback += (o, cert, chain, errors) => true;

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, May 12, 2019 12:50 PM
  • User380049 posted

    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; }

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, May 13, 2019 3:19 PM
  • User380224 posted

    hello @abdalrhman ,

    which one is best and where should I assign client for the second solution you did return client.

    Friday, October 11, 2019 5:10 AM
  • User380049 posted

    @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

    Friday, October 11, 2019 7:04 AM
  • User380224 posted

    Thank you @abdalrhman, I did the first solution in Android main activity.

    Tuesday, October 15, 2019 3:19 PM
  • User392285 posted

    @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. ???

    Friday, January 17, 2020 7:16 AM
  • User194668 posted

    @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 :'(

    Sunday, January 26, 2020 9:16 PM
  • User151946 posted

    Hmm. The accepted answer appears to be 'ignore any certificate errors'. Doesn't sound like a good solution to me.

    Friday, September 4, 2020 8:36 AM