.NET Core 3身份验证-如何使用SSO忽略无效的证书

我正在使用DEV ADFS服务器在.NET Core 3.1(预览版)应用程序中进行身份验证-碰巧是Blazor Server,但不确定是否有任何区别。

问题是证书无效(过期)。它只是“唯一的开发人员”,因此我们可以接受,但是如何让我的.NET Core 3.x应用程序忽略证书错误。

在完整框架中,您可以添加:

servicepointManager.ServerCertificateValidationCallback = this.ValidateServerCertificateMethod;

但这似乎不受支持。

我拥有的是:

坚果包装

<PackageReference Include="microsoft.AspNetCore.Authentication.WsFederation" Version="3.1.0-preview2.19528.8" />

Startup.cs

public static void ConfigureServices(IServiceCollection services)
{
    services
        .AddAuthentication(sharedOptions =>
        {
            sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
        })
        .AddWsFederation(options =>
        {
            options.Wtrealm = "https://localhost:44323/";
            options.MetadataAddress = "https://adfs.devserver.com/Federationmetadata/2007-06/Federationmetadata.xml";
            options.UseTokenLifetime = false;
        })
        .AddCookie();

    services.AddRazorPages();
    services.AddServerSideBlazor();

    ....
}

public static void Configure(IApplicationBuilder app,IWebHostEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Error");
        app.UseHsts();
    }

    app.UseHttpsRedirection();
    app.UseStaticfiles();
    app.UseRouting();

    app.UseAuthentication();
    app.Use(async (context,next) =>
    {
        context.Response.Headers.Add("X-Frame-Options","DENY");
        var user = context.User;
        if (user?.Identities.HasnoItems(identity => identity.IsAuthenticated) ?? true)
        {
            await context.ChallengeAsync(WsFederationDefaults.AuthenticationScheme).ConfigureAwait(false);
        }
        else if (next != null)
        {
            await next().ConfigureAwait(false);
        }
    });

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapBlazorHub();
        endpoints.MapFallbackToPage("/_Host");
    });
}

执行对context.ChallengeAsync的调用时,我收到一个汇总异常,其中包括:

  

system.security.Authentication.AuthenticationException:远程   根据验证程序,证书无效。

如何绕过验证?

谢谢

admanyh 回答:.NET Core 3身份验证-如何使用SSO忽略无效的证书

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3108356.html

大家都在问