繁体   English   中英

使用Azure Functions中的SSL3调用外部API

[英]Using SSL3 from Azure Functions to Call External API

我们有一个.NET应用程序需要与一个API进行交互,该API严格要求SSL3才能使API工作,但是我们不希望我们的整个站点在该安全协议中运行。

为了在.NET框架中实现这一点,我们使用了AppDomain,因此使用了远程处理 但是, 我们正在将我们的应用程序移植到.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功能执行我们正在尝试执行的操作,或者我们尝试设置的设置是否在沙盒环境中不受尊重?

Azure Functions在Windows工作人员之上运行,就像Web Apps一样,因为他们都是App Service的一部分。 它下面是相同的沙箱。

如果您在Kudu 的注册表中使用PowerShell,您会发现SSL 3.0在系统范围内被禁用,这对任何现代服务都是可以预期的。

SSL 3.0注册表项

来自IvanRistić的优秀防弹SSL和TLS书籍:

DisabledByDefault - 此设置适用于未明确配置已启用协议但使用系统默认值的应用程序。 如果条目不存在或值为0,则默认启用协议。 如果值为1,则默认情况下禁用协议。 通常,Windows将禁用SSL 2并启用所有其他协议。

运行SSL 3.0-only API的人在过去10年中度过了太多假期。 对那些人讲一些感觉。 SSL 3.0易受BEAST攻击,Microsoft的实现中没有AES,不支持GCM,SHA256和SHA384套件,也没有椭圆曲线加密,所以没有前向保密。

如果您在晚上睡觉时不依赖于SSL 3.0,则必须使用 .NET / Windows(System.Security和SCHANNEL)提供的TLS库不同的TLS库 OpenSSL,BoringSSL,GnuTLS,LibreSSL如果你找到一个C#包装器,或者你有足够的时间来自己动手,它们都是你的选择。

这里真正的解决方案是通过虚拟机代理所有请求。 您可以控制操作系统,控制TLS堆栈。 然后,您可以向您的遥控器说SSL 3.0。 我不敢相信我这么说 - 给我他们的电话号码!

更新:您现在可以使用(更多)轻量级容器实例来代理SSL 3.0流量。 请参阅https://docs.microsoft.com/en-us/azure/container-instances/container-instances-overview

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM