如何解决ASP.Net Core-X509Certificate2在CentOS 8中引起OpenSslCryptographicException
我正在尝试在Centos 8中部署ASP.Net Core应用程序。无论是从访问数据库还是从任何常用术语来讲,我的应用程序在Windows和Linux上都运行良好。但是对于这行代码-
byte[] byteStream = Encoding.ASCII.GetBytes(certString);
X509Certificate2 certificate = new X509Certificate2(byteStream); //Error in this line
我在CentOS 8中发现了这样的错误
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
Interop+Crypto+OpenSslCryptographicException: error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error
at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromBlob(Byte[] rawData,SafePasswordHandle password,X509KeyStorageFlags keyStorageFlags) in /_/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs:line 59
at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] data) in /_/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs:line 56
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData) in /_/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs:line 48
at XmlSigner.Library.XmlSign.GetLastSignerCertificateModel(XmlDocument xmlDocument) in /home/abrar/XML-Signer-ASP.NetCore-PostGRE/Library/XmlSign.cs:line 97
at XmlSigner.Library.XmlSign.GetAllSign(XmlDocument xmlDocument) in /home/abrar/XML-Signer-ASP.NetCore-PostGRE/Library/XmlSign.cs:line 70
at XmlSigner.ViewModels.ApplicationSignViewModel..ctor(XmlFile xmlFile) in /home/abrar/XML-Signer-ASP.NetCore-PostGRE/ViewModels/ApplicationSignViewModel.cs:line 23
at XmlSigner.Controllers.LeaveApplicationsController.Sign(Nullable`1 id) in /home/abrar/XML-Signer-ASP.NetCore-PostGRE/Controllers/LeaveApplicationsController.cs:line 113
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper,ObjectMethodExecutor executor,Object controller,Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker,ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker,Task lastTask,State next,Scope scope,Object state,Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next,Scope& scope,Object& state,Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker,Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker,Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next,Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker,Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker,Task task,IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint,Task requestTask,ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware,HttpContext context,Task task)
fail: XmlSigner.Controllers.HomeController[0]
Error In UI page
重新-
我在centos中使用supervisor
来启动和运行服务,并且supervisor
的配置文件是这样的-
[program:dotnetWebApp]
command=dotnet "Xml Signer.dll" --urls "http://*:80;https://*:5001"
directory=/home/abrar/PublishedWebApp/
environment=ASPNETCORE__ENVIRONMENT=Development
user=root
stopsignal=INT
autostart=true
autorestart=true
startsecs=1
stderr_logfile=/var/log/dotnetWebApp.err.log
stdout_logfile=/var/log/dotnetWebApp.out.log
有人可以帮忙吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。