Ssl ASP.NET核心WEB API应用程序在本地主机上的HTTPS上出错
我最近刚拿到我的第一个副总裁。它运行CentOS 8和Nginx。我正在使用默认的ASP.NET CORE REST API项目,将其发布并部署到服务器 设置如下所示: 普通客户端浏览器Cloudflare DNS/Proxy Nginx在VPS上REST在本地主机上API在Kestrel上 我让Cloudflare为其SSL提供服务。然后,Nginx被设置为反向代理。而且,dot.net核心应用程序正在Ssl ASP.NET核心WEB API应用程序在本地主机上的HTTPS上出错,ssl,nginx,asp.net-core,centos,Ssl,Nginx,Asp.net Core,Centos,我最近刚拿到我的第一个副总裁。它运行CentOS 8和Nginx。我正在使用默认的ASP.NET CORE REST API项目,将其发布并部署到服务器 设置如下所示: 普通客户端浏览器Cloudflare DNS/Proxy Nginx在VPS上REST在本地主机上API在Kestrel上 我让Cloudflare为其SSL提供服务。然后,Nginx被设置为反向代理。而且,dot.net核心应用程序正在https://localhost:5001和http://localhost:5000 除
https://localhost:5001
和http://localhost:5000
除了通过https://localhost:5001
内部给出SSL错误:
错误:“localhost”的证书不受信任
错误:“localhost”的证书没有已知的颁发者
我已经使用OpenSSL为自己制作了一个自签名SSL,证书在这方面100%运行良好。我已经将rootCA.pem添加到CA的受信任列表中。Nginx正在使用我为反向代理生成的SSL证书和密钥。但是,证书也不起作用
而且,当我试图公开访问该网站时,会出现以下错误
此网站无法提供安全连接
randomwebsite.com使用不受支持的协议。
错误\u SSL\u版本\u或\u密码\u不匹配
但是,如果我在应用程序上禁用https重定向,该应用程序可以在线正常运行。问题是本地主机证书不受信任。由于某些原因,我的证书没有被使用,Kestrel正在生成自己的证书,这肯定与我在NGINX反向代理中设置的证书不匹配
那么,如何在CentOS 8上运行的ASP.NET核心应用程序中使用Nginx作为反向代理设置SSL证书和密钥
我是ASP.NET核心的新手,所以我很难理解这个问题
launchSettings.json:
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:63514",
"sslPort": 44370
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"REST_API": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
}
}
}
Startup.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace REST_API
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
您必须安装ssl证书
sudo apt get安装ca证书
ca证书已安装Marios您找到解决方案了吗?