我将我的asp.net core 3.1应用程序配置为使用身份服务器4。在我的本地计算机和本地IIS中,一切正常。如果我发布到Azure App Service,则证书加载失败,并显示以下错误:
2020-04-05T02:01:46.200965138Z Documentation: http://aka.ms/webapp-linux
2020-04-05T02:01:46.200972938Z Dotnet quickstart: https://aka.ms/dotnet-qs
2020-04-05T02:01:46.200980839Z ASP .NETCore Version: 3.1.0
2020-04-05T02:01:46.200988739Z Note: Any data outside '/home' is not persisted
2020-04-05T02:01:46.624585930Z Running oryx -appPath /home/site/wwwroot -output /opt/startup/startup.sh -defaultAppFilePath /defaulthome/hostingstart/hostingstart.dll -bindPort 8080 -userStartupCommand ''
2020-04-05T02:01:46.758919856Z Oryx Version: 0.2.20200114.13, Commit: 204922f30f8e8d41f5241b8c218425ef89106d1d, ReleaseTagName: 20200114.13
2020-04-05T02:01:46.769077531Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-04-05T02:01:46.770324503Z Could not find operation ID in manifest. Generating an operation id...
2020-04-05T02:01:46.771110686Z Build Operation ID: 2c1fda2a-9303-49d7-8d96-2fd6b961de83
2020-04-05T02:01:48.583605155Z Writing output script to '/opt/startup/startup.sh'
2020-04-05T02:01:48.934026596Z Trying to find the startup DLL name...
2020-04-05T02:01:48.934770080Z Found the startup D name: IDP.dll
2020-04-05T02:01:48.935266269Z Running the command: dotnet "IDP.dll"
2020-04-05T02:01:50.341053110Z [02:01:50 Information]
2020-04-05T02:01:50.341106512Z Starting host...
2020-04-05T02:01:50.341118212Z
2020-04-05T02:01:52.133020171Z [02:01:52 Fatal]
2020-04-05T02:01:52.133081573Z Host terminated unexpectedly.
2020-04-05T02:01:52.133093173Z Interop+Crypto+OpenSslCryptographicException: error:2006D002:BIO routines:BIO_new_file:system lib
2020-04-05T02:01:52.133102374Z at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle)
2020-04-05T02:01:52.134995630Z at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
2020-04-05T02:01:52.135015331Z at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
2020-04-05T02:01:52.135025731Z at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)
2020-04-05T02:01:52.135048232Z at IDP.Startup.ConfigureServices(IServiceCollection services) in C:\Users\xxxx\IDP\Startup.cs:line 47
2020-04-05T02:01:52.135072332Z at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
2020-04-05T02:01:52.140072381Z at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2020-04-05T02:01:52.140095582Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
2020-04-05T02:01:52.140545195Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
2020-04-05T02:01:52.140562795Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
2020-04-05T02:01:52.140572496Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
2020-04-05T02:01:52.140919606Z at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services)
2020-04-05T02:01:52.140980508Z at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass12_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
2020-04-05T02:01:52.141103111Z at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
2020-04-05T02:01:52.141119512Z at Microsoft.Extensions.Hosting.HostBuilder.Build()
2020-04-05T02:01:52.141498823Z at IDP.Program.Main(String[] args) in C:\Users\xxxx\IDP\Program.cs:line 37
2020-04-05T02:01:52.141564625Z
2020-04-05 02:01:53.668 ERROR - Container xxxxidp_0_bb9e5be5 for site xxxxidp has exited, failing site start
2020-04-05 02:01:53.676 ERROR - Container xxxxidp_0_bb9e5be5 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2020-04-05 02:01:53.693 INFO - Stoping site xxxxidp because it failed during startup.
Status_WatchFile :: Error Error: ENOENT: no such file or directory, open '/appsvctmp/status.txt'
这是我启动时的配置服务:
builder.AddSigningCredential(new X509Certificate2($"{Environment.ContentRootPath}\\Certificate\\my certificate.pfx", Configuration.GetValue<string>("CertificatePassword")));
这是我的项目文件夹结构中的证书,
如果我做错了,请提供帮助。尝试了一天以上,却无法弄清楚我要去哪里。
[经过近几周的时间并分析了所有可能性之后,我才弄清楚哪里出了问题。引起麻烦的是\
。我的申请中已添加证书。下一行适用于Windows机器,
builder.AddSigningCredential(new X509Certificate2($"{Environment.ContentRootPath}\\Certificate\\my certificate.pfx", Configuration.GetValue<string>("CertificatePassword")));
但是我了解到\
在涉及路径时在linux
中不起作用。因此,我将\
替换为正斜杠/
,并且它在windows
和linux
中均有效。
builder.AddSigningCredential(new X509Certificate2($"{Environment.ContentRootPath}/Certificate/my certificate.pfx", Configuration.GetValue<string>("CertificatePassword")));
希望这确实对某些人有所帮助。