.NET core 3.1 中 SOAP WSDL api 调用的 SecurityNegotiationException
我有一个调用外部 SOAP WSDL 的 .NET core API。
我面临的问题是 SSL 证书似乎存在某种问题:
这是完整的错误(没有堆栈跟踪):
System.ServiceModel.Security.SecurityNegotiationException: Could not establish trust relationship for the SSL/TLS secure channel with authority 'api.address.xyz'.
---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
更多详细信息:
我使用了 Visual Studio 中的 WFC Web 服务服务参考工具2022 年创建互联服务。
我对 .NET core 完全陌生。
我正在使用 Google Cloud Run。
该问题似乎仅在应用程序部署在 Cloud Run 上时才会出现。
我尝试过的:
首先想到的是在服务器上安装根和中间CA证书,但在Cloud Run上这似乎是不可能的,或者至少我找不到如何做吧。
我尝试告诉应用程序接受使用 Program.cs
中的此代码获得的任何证书:
public static IHostBuilder CreateHostBuilder(string[] args)
{
var port = Environment.GetEnvironmentVariable("PORT") ?? "8080";
var url = $"http://0.0.0.0:{port}";
//var url = "http://localhost:5001";
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>().UseUrls(url).ConfigureKestrel(o =>
{
o.ConfigureHttpsDefaults(opts =>
{
opts.ClientCertificateMode = ClientCertificateMode.RequireCertificate;
opts.AllowAnyClientCertificate();
});
});
});
}
但它不起作用。
我还尝试更新我安装的所有可能的 NuGet 包并重新创建连接的服务,但什么也没有。
我想我没有抓住要点。
I have a .NET core API that calls an external SOAP WSDL.
The problem that i'm facing is that there seems to be some kind of problem with the SSL certificate:
This is the full error (without the stacktrace):
System.ServiceModel.Security.SecurityNegotiationException: Could not establish trust relationship for the SSL/TLS secure channel with authority 'api.address.xyz'.
---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
A bit more details:
I used the WFC Web Service service reference tool from Visual Studio 2022 to create the connected service.
I'm totally new to .NET core.
I'm using Google Cloud Run.
The problem seems to present itself only when the application is deployed on Cloud Run.
What i tried:
The first thing that came to mind was installing the root and intermediate CA certificate on the server, but on Cloud Run it seems to be impossible, or at least i can't find how to do it.
I tried telling the app to accept whatever certificate it gets using this code in Program.cs
:
public static IHostBuilder CreateHostBuilder(string[] args)
{
var port = Environment.GetEnvironmentVariable("PORT") ?? "8080";
var url = quot;http://0.0.0.0:{port}";
//var url = "http://localhost:5001";
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>().UseUrls(url).ConfigureKestrel(o =>
{
o.ConfigureHttpsDefaults(opts =>
{
opts.ClientCertificateMode = ClientCertificateMode.RequireCertificate;
opts.AllowAnyClientCertificate();
});
});
});
}
But it does not work.
I also tried updating all possible NuGet packages that i installed and recreating the connected service but nothing.
I think i'm missing the point.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论