【发布时间】:2017-08-08 05:40:42
【问题描述】:
我们有一个 .NET 应用程序需要与严格要求 SSL3 才能工作的 API 进行交互,但是我们不希望我们的整个网站都在该安全协议中运行。
为了在 .NET 框架中实现这一点,我们使用了AppDomain and, therefore, remoting。但是,我们正在将我们的应用程序移植到 .NET Core 2.0,我们不再可以使用该功能。
我们提出的解决方案是使用 Azure Functions 拥有一个无服务器函数,该函数可以联系 API 并返回交互结果,因此充当代理。
这是我们在函数中设置的一些代码:
// set the protocol to SSL3 app wide
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
// ignore any SSL errors
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
但是运行它会给我们以下错误:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.ComponentModel.Win32Exception: The client and server cannot communicate, because they do not possess a common algorithm
at System.Net.SSPIWrapper.AcquireCredentialsHandle(SSPIInterface SecModule, String package, CredentialUse intent, SecureCredential scc)
at System.Net.Security.SecureChannel.AcquireCredentialsHandle(CredentialUse credUsage, SecureCredential& secureCredential)
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 offset, Int32 count)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.TlsStream.CallProcessAuthentication(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at Submission#0.<Run>d__1.MoveNext() in :line 15
是否可以让 Azure Functions 执行我们正在尝试执行的操作,或者我们尝试设置的设置在沙盒环境中没有得到遵守?
【问题讨论】:
标签: c# azure ssl azure-functions