Skip to content

Instantly share code, notes, and snippets.

@jbollman7
Created June 15, 2021 00:02
Show Gist options
  • Save jbollman7/f9e9b690d5b746e82556add0cc5af988 to your computer and use it in GitHub Desktop.
Save jbollman7/f9e9b690d5b746e82556add0cc5af988 to your computer and use it in GitHub Desktop.
SSL Hanlder. when invalid/selfsigned certs got you down
using System.Net.Http;
using System.Security.Authentication;
namespace Auth_ConnectionLib
{
public static class SslHandle
{
public static HttpClientHandler FixInvalidSsl()
{
var httpClientHandler = new HttpClientHandler
{
SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls,
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
};
return httpClientHandler;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment