Forum Xamarin.Forms

Rest Api Https Reqest (The certificate authority is invalid or incorrect)

Hello,

I'm trying to get simple json data from my linux SSH remote server (UWP, Android) but it refuse to respond to my App.

But i'm confused why i can get the data when i send the request with my browser(with not secure warning) or through Postman(with Settings option: SSL certificate Off) ??

I'm wonder how could i resolve this, how can i avoid certificate authority and get the data (just like in Postman), and how shall i actually have to deal with SSL certification in my HTTPS reqeust. My server support OpenSSL.

MAIN SEGMENT OF MY CODE:

    HttpClient client = new HttpClient();
    var response = await client.GetStringAsync("https://" +  ServerApiLinkConnection);
    Debug.WriteLine(response);

ERROR:

    System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Exception: The text associated with this error code could not be found.

    The certificate authority is invalid or incorrect

       at System.Net.Http.HttpHandlerToFilter.SendAsync(HttpRequestMessage request, CancellationToken cancel)
       at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
       --- End of inner exception stack trace ---
       at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
       at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
       at System.Net.Http.HttpClient.GetStringAsyncCore(Task`1 getTask)

Answers

Sign In or Register to comment.