配置 SSL/TLS 证书时 ASP.NET 总是返回错误

配置 SSL/TLS 证书时 ASP.NET 总是返回错误

我在 IIS 上配置了 ASP.NET Core Web API 并添加了 Let's Encrypt 证书。我已将同一证书添加到两个网站(在同一个域内)一个是 API,另一个是 Angular 前端。我可以登录 Angular 平台,但所有其他请求都返回“500 内部错误”,没有进一步解释。

所有请求在 Postman 上都能很好地运行

我究竟做错了什么?

任何帮助表示感谢

启动文件

public class Startup
{
    public IConfiguration Configuration { get; set; }
    public Startup(IHostingEnvironment env)
    {
        var builder = new ConfigurationBuilder()
            .SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
            .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
            .AddEnvironmentVariables();
        Configuration = builder.Build();

        myConfig = Configuration["Origin"];
        var config = Configuration.GetSection("JWTConfig").Get<JWTConfig>();
        JWTSecret = config.JWTSecret;
    }

    private readonly StartupSettings _startupSettings;
    private AppSettings _appSettings;

    public Startup(IOptions<StartupSettings> startupSettings, IOptions<AppSettings> appSettings)
    {
        _startupSettings = startupSettings.Value;
        _appSettings = appSettings.Value;
    }

    // This method gets called by the runtime. Use this method to add services to the container.
    // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {


        services.Configure<AppSettings>(Configuration.GetSection("DatabaseSettings"));
        services.Configure<AppSettingsAnex>(Configuration.GetSection("DatabaseAnexSettings"));
        services.Configure<StartupSettings>(Configuration.GetSection("ApplicationSettings"));
        services.Configure<IISOptions>(o =>
        {
            o.ForwardClientCertificate = false;
        });

        services.AddCors();
        services.AddMvc();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(  IApplicationBuilder app, 
                            IHostingEnvironment env, 
                            ILoggerFactory loggerFactory,
                            IOptions<AppSettings> appSettings,
                            IMemoryCache cache
                            ) {
        _appSettings = appSettings.Value;

        loggerFactory.AddConsole(Configuration.GetSection("Logging"));
        loggerFactory.AddDebug(LogLevel.Trace);

        app.UseCors(builder =>
            builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials()
        );
      if (env.IsDevelopment()) {  app.UseDeveloperExceptionPage(); }

        app.UseAuthentication();
        app.UseStaticFiles();
        app.UseUserTokenMiddleware(); // Middleware que gere a token / sessão dos pedidos http
        app.UseMvcWithDefaultRoute();
    }
}

IIS 配置

浏览器控制台日志

笔记Chrome 发出有关 SPDY 错误 (net::ERR_SPDY_PROTOCOL_ERROR) 的异常。这里但没有解决

相关内容