如何解决无法在 Linux 上的 Azure 应用服务中加载“libSystem.Security.Cryptography.Native.OpenSsl”
我正在尝试在 Linux 上的 Azure 应用服务上使用 ssl 证书。该证书是从运行在 .net 核心上的 X509Store 商店加载的。但是当 AppService 尝试将 HttpRequest 发送到验证证书的一方时,我收到以下错误。
The SSL connection could not be established,see inner exception. ::InnerException:: System.TypeInitializationException: The type initializer for 'Crypto' threw an exception.
---> System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libSystem.Security.Cryptography.Native.OpenSsl' or one of its dependencies. In order to help diagnose loading problems,consider setting the LD_DEBUG environment variable: liblibSystem.Security.Cryptography.Native.OpenSsl: cannot open shared object file: No such file or directory
at Interop.CryptoInitializer.EnsureOpenSslInitialized()
at Interop.CryptoInitializer..cctor()
--- End of inner exception stack trace ---
at Interop.CryptoInitializer.Initialize()
at Interop.Crypto..cctor()
--- End of inner exception stack trace ---
at Interop.CryptoInitializer.Initialize()
at Interop.Crypto..cctor()
--- End of inner exception stack trace ---
at Interop.Crypto.EvpPkeyGetRsa(SafeEvpPKeyHandle pkey)
at System.Security.Cryptography.RSAOpenSsl..ctor(SafeEvpPKeyHandle pkeyHandle)
at Internal.Cryptography.Pal.OpenSslX509CertificateReader.GetRSAPrivateKey()
at Internal.Cryptography.Pal.CertificateExtensionsCommon.GetPrivateKey[T](X509Certificate2 certificate,Predicate`1 matchesConstraints)
at System.Security.Cryptography.X509Certificates.RSACertificateExtensions.GetRSAPrivateKey(X509Certificate2 certificate)
at System.Net.Security.SafeFreeSslCredentials..ctor(X509Certificate certificate,SslProtocols protocols,EncryptionPolicy policy)
at System.Net.Security.SecureChannel.AcquireClientCredentials(Byte[]& thumbPrint)
at System.Net.Security.SecureChannel.GenerateToken(Byte[] input,Int32 offset,Int32 count,Byte[]& output)
at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming,Int32 count)
at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming,AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ForceAuthentication(Boolean receiveFirst,Byte[] buffer,AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessAuthentication(LazyAsyncResult lazyResult,CancellationToken cancellationToken)
at System.Net.Security.SslStream.BeginAuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions,CancellationToken cancellationToken,AsyncCallback asyncCallback,Object asyncState)
at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__65_0(SslClientAuthenticationOptions arg1,CancellationToken arg2,AsyncCallback callback,Object state)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2](Func`5 beginMethod,Func`2 endFunction,Action`1 endAction,TArg1 arg1,TArg2 arg2,Object state,TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,Action`1 endMethod,Object state)
at System.Net.Security.SslStream.AuthenticateAsClientAsync(SslClientAuthenticationOptions sslClientAuthenticationOptions,CancellationToken cancellationToken)
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream,SslClientAuthenticationOptions sslOptions,CancellationToken cancellationToken) ::StackTrace:: at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream,CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request,Boolean allowHttp2,CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request,Boolean doRequestAuth,CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
at TestProject.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
证书加载成功。但是错误发生在 SSL 连接上。 我尝试将应用服务托管为一个独立的应用程序,但我们仍然存在无法加载共享库的问题(显然,因为它是一个操作系统库)。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。