gpt4 book ai didi

asp.net-core - 在 Linux 中绕过 ASP.NET Core 中的 SSL 验证

转载 作者:行者123 更新时间:2023-12-02 01:17:33 26 4
gpt4 key购买 nike

我们的客户有一个使用自签名证书运行的 Cloud foundry 的本地托管。我们正在 ASP.NET Core 中为他开发微服务。在此期间,我们需要使用 HttpClient 进行非加密的 HTTP 调用。

  • 有什么方法可以绕过 SSL 客户端中的 SSL 验证检查Ubuntu(我知道它可以用于 windows)?

我知道以前有一些答案,但没有提供任何解决方案。因此,请不要将此问题标记为重复

最佳答案

您可以像这样使用 HttpClientHandler 的证书验证回调:

static void Main(string[] args)
{
using (var handler = new HttpClientHandler())
using (var client = new HttpClient(handler))
{
handler.ServerCertificateCustomValidationCallback += (message, xcert, chain, errors) => true;

var result = client.GetStringAsync("https://self-signed.badssl.com/").Result;
Console.WriteLine(result.Substring(0, 100));
}
}

在 Windows 上的 Ubuntu 上使用 Bash 测试

关于asp.net-core - 在 Linux 中绕过 ASP.NET Core 中的 SSL 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41917303/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com