gpt4 book ai didi

azure - 无法在 Azure 应用服务上启动 Kestrel 抛出无法配置 HTTPS 端点异常

转载 作者:行者123 更新时间:2023-12-02 22:55:53 29 4
gpt4 key购买 nike

我的应用程序已部署到运行 dotnet core 3.1.2Azure 应用服务。 (扩展已安装)

连接到 Kudo 控制台并运行 dotnet Reporting.API.dll 时,输出为:

dotnet Reporting.API.dll
[09:53:21 DBG] Hosting starting
[09:53:25 INF] Azure Web Sites environment detected. Using 'D:\home\ASP.NET\DataProtection-Keys' as key repository; keys will not be encrypted at rest.
[09:53:25 INF] Starting the processing server.
[09:53:25 DBG] Reading data from file 'D:\home\ASP.NET\DataProtection-Keys\key-9d61e53e-50f6-48c2-9fb1-76edd2ec884c.xml'.
[09:53:25 DBG] Reading data from file 'D:\home\ASP.NET\DataProtection-Keys\key-9f563cfe-7cea-4332-8010-c2e0c485ee39.xml'.
[09:53:25 DBG] Reading data from file 'D:\home\ASP.NET\DataProtection-Keys\key-a4632346-de3c-4726-b84d-067511ba48de.xml'.
[09:53:25 DBG] Reading data from file 'D:\home\ASP.NET\DataProtection-Keys\key-cbf59895-b970-4cbf-aad1-eb4387edb6ab.xml'.
[09:53:25 DBG] Reading data from file 'D:\home\ASP.NET\DataProtection-Keys\key-f5be7258-dbc8-4f36-8f3e-930073d353b2.xml'.
[09:53:25 DBG] Found key {9d61e53e-50f6-48c2-9fb1-76edd2ec884c}.
[09:53:25 DBG] Found key {9f563cfe-7cea-4332-8010-c2e0c485ee39}.
[09:53:25 DBG] Found key {a4632346-de3c-4726-b84d-067511ba48de}.
[09:53:25 DBG] Found key {cbf59895-b970-4cbf-aad1-eb4387edb6ab}.
[09:53:25 DBG] Found key {f5be7258-dbc8-4f36-8f3e-930073d353b2}.
[09:53:25 DBG] Considering key {a4632346-de3c-4726-b84d-067511ba48de} with expiration date 2020-05-26 16:44:50Z as default key.
[09:53:25 DBG] Opening CNG algorithm 'AES' from provider 'null' with chaining mode CBC.
Unhandled exception.[09:53:25 DBG] Opening CNG algorithm 'SHA256' from provider 'null' with HMAC.
[09:53:25 DBG] Using key {a4632346-de3c-4726-b84d-067511ba48de} as the default key.
[09:53:25 DBG] Key ring with default key {a4632346-de3c-4726-b84d-067511ba48de} was loaded during application startup.
[09:53:25 DBG] Failed to locate the development https certificate at 'null'.
[09:53:25 DBG] Unable to locate an appropriate development https certificate.
[09:53:25 FTL] Unable to start Kestrel.
System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
[09:53:25 DBG] Hosting shutdown
[09:53:25 INF] Queued Hosted Service is stopping.
System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at Reporting.API.Program.Main(String[] args) in C:\agent-02\_work\35\s\src\Reporting.API\Program.cs:line 19

我的 Startup.cs 非常标准:

public void Configure(IApplicationBuilder app)
{
app.UseCors("CorsPolicy");

app.UseRouting();

app.UseAuthentication();

app.UseAuthorization();

app.UseMvc();
}

有什么想法吗?

更新:我已从配置方法中删除了 app.UseHttpsRedirection();

为了澄清起见:仅 HTTPS 设置为 true

enter image description here

最佳答案

您可以尝试配置 Kestrel 以使用您的证书:

//**Program.cs :**
static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webHostBuilder =>
{
webHostBuilder.**UseKestrel**((builderContext, options) =>
{
options.Configure(builderContext.Configuration.**GetSection("Kestrel")**);
});
});

//**appsettings.json (or appsettings.development.json etc) :**
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://yoursite.azurewebsites.net"
},

// Note: You most likely only need one of the following Https sections, thus only one is uncommented here...

//"HttpsInlineCertFile": {
// "Url": "https://yoursite.azurewebsites.net:443",
// "Certificate": {
// "Subject": "YourCertName",
// "Store": "My", //"root",
// "Location": "LocalMachine", //"CurrentUser",
// "AllowInvalid": "True"
// }
//}
//"HttpsInlineCertStore": {
// "Url": "https://yoursite.azurewebsites.net:443",
// "Certificate": {
// "Subject": "YourCertName",
// "Store": "My", //"root",
// "Location": "LocalMachine", //"CurrentUser",
// "AllowInvalid": "True"
// }
//}
//"HttpsDefaultCert": {
// "Url": "https://yoursite.azurewebsites.net:443"
//}
"Https": {
"Url": "https://*:443"
"Certificate": {
"Subject": "localhost",
"Store": "My", //"root",
"Location": "LocalMachine", //"CurrentUser",
"AllowInvalid": "True"
}
}
}
// If using HttpsDefaultCert above, uncomment the following...
//,
//"Certificates": {
// "Default": {
// "Subject": "YourCertName",
// "Store": "My", //"root",
// "Location": "LocalMachine", //"CurrentUser",
// "AllowInvalid": true
// }
//}
}

关于azure - 无法在 Azure 应用服务上启动 Kestrel 抛出无法配置 HTTPS 端点异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60430781/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com