小编Ped*_*eal的帖子

.NET CORE 5 发出 HTTPS 请求时出现“HandshakeFailure”

这个请求根本无法在 c# 上工作(RestClient 或 HttpClient)。当我尝试连接到 RestSharp 上的端点时,我得到 StatusCode 0,在 HttpClient 上我得到此异常:

身份验证失败,因为远程方发送了 TLS 警报:“HandshakeFailure”。

有趣的是,它在邮递员上运行得很好(是的,我尝试从邮递员生成代码,但它仍然不起作用)。

我查看了邮递员,它使用了 TLS 1.2 证书,然后我尝试了以下操作:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

依然没有。

检查了 url、身份验证、标头、http 动词,一切正常。

Obs:我只能通过 VPN 访问此端点,这听起来像吗?

检查邮递员使用的 TLS 版本

https ssl-certificate .net-core asp.net-core

10
推荐指数
1
解决办法
1万
查看次数

在 IIS 上部署 API 时不显示 Swagger UI

好吧,我将 Swagger 用于我的 API 文档,它在 localhost 中运行良好,当我将它托管在 IIS 上时,问题就开始了。出于某种原因,它不再起作用了

本地主机:

https://localhost:44381/swagger/index.html
Run Code Online (Sandbox Code Playgroud)

接口:

http://200.155.29.14/SimuladorFrete/Swagger/index.html
Run Code Online (Sandbox Code Playgroud)

当我在 ISS 中部署 Swagger 后尝试打开它时,我得到的只是一个空白页面和一个 500 内部服务器错误,这并没有说明异常。

这是我的配置方法(startup.cs)

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();

    }
    app.UseHttpsRedirection();

    app.UseRouting();

    app.UseAuthorization();

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllers();
    });
    app.UseSwagger();
    app.UseStaticFiles();
    app.UseSwaggerUI(c =>
    {
        if (env.IsDevelopment())
        {
            c.SwaggerEndpoint("/swagger/v1/swagger.json", "Web API V1");
        }
        else
        {
            // To deploy on IIS
            c.SwaggerEndpoint("/SimulaFrete/swagger/v1/swagger.json", "Web API V1");
        }

    });
}
Run Code Online (Sandbox Code Playgroud)

这是我的 ConfigureServices 方法:

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllers().AddNewtonsoftJson();

    services.AddSwaggerGen(c =>
    { …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-web-api swagger swashbuckle asp.net-core

1
推荐指数
2
解决办法
6969
查看次数