[英]How can I disable the SSL Certificate check in the .NET Core http client?
I am trying to connect to a website via a proxy.我正在尝试通过代理连接到网站。 This is happening in an AWS Lambda with .NET Core SDK using an http client.
这发生在 AWS Lambda 和 .NET Core SDK 使用 Z80791B3AE7002CB88C246876D9FAAF8 客户端。 The call looks pretty much like this:
调用看起来很像这样:
handler = new HttpClientHandler()
{
CookieContainer = cookieContainer,
Proxy = new WebProxy(
new Uri(Environment.GetEnvironmentVariable("proxyURL"))),
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
SslProtocols = SslProtocols.Tls12,
ClientCertificateOptions = ClientCertificateOption.Manual
};
using(var client = new HttpClient(handler))
{
var content = await client.GetAsync("https://my-website.com/");
}
I am not able to make the call to "https://my-website.com/".我无法拨打“https://my-website.com/”电话。 The call times out without an error message.
调用超时,没有错误消息。
However I was able to access the website using Golang and resty in an AWS Lambda, skipping the TLS Check:但是,我能够使用 Golang 访问该网站,并在 AWS Lambda 中休息,跳过 TLS 检查:
client := resty.New()
resp, err := client.
SetProxy(os.Getenv("proxyURL")).
SetRetryCount(3).SetTimeout(3*time.Second).SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}).
R().Get("https://my-website.com/")
My question is: how can I achieve the behaviour from my Golang Code in my .NET Core Code?我的问题是:如何在 .NET 核心代码中实现 Golang 代码的行为?
TL; TL; DR: The problem lied not within certificate validation, but in a security group rule.
DR:问题不在于证书验证,而在于安全组规则。
DangerousAcceptAnyServerCertificateValidator
already achieves the aim of ignoring certificate validation problems.DangerousAcceptAnyServerCertificateValidator
已经达到了忽略证书验证问题的目的。HttpClient
. HttpClient
超时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.