Created
October 5, 2021 18:05
-
-
Save alexeygritsenko/5efd1e1e2877c703b73888039d282210 to your computer and use it in GitHub Desktop.
Solution for Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Net; | |
using System.Net.Http; | |
using System.Text; | |
namespace MyXamarinNativeApp.Shared.Helpers | |
{ | |
public class HttpClientHelper | |
{ | |
public static HttpClient Create(CookieContainer cookieContainer = null) | |
{ | |
HttpClient http; | |
#if __ANDROID__ | |
var handler = new Xamarin.Android.Net.AndroidClientHandler(); | |
if (cookieContainer != null) | |
handler.CookieContainer = cookieContainer; | |
http = new HttpClient(handler); | |
#else | |
var handler = new HttpClientHandler(); | |
if (cookieContainer != null) | |
handler.CookieContainer = cookieContainer; | |
http = new HttpClient(handler); | |
#endif | |
return http; | |
} | |
public static HttpClientHandler CreateHandle() | |
{ | |
HttpClientHandler handler; | |
#if __ANDROID__ | |
handler = new Xamarin.Android.Net.AndroidClientHandler(); | |
#else | |
handler = new HttpClientHandler(); | |
#endif | |
return handler; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a small refactor for your proposal :