C# 调用SSPI失败,请参阅内部异常-无法联系本地安全机构
我有一个WPF应用程序,它使用SSLStream连接到服务器并发送/接收一些消息。我的代码主要基于这个示例(SslTcpClient): 这几个月来效果不错。但是,在获得此windows更新(windows 10版本1511和windows Server 2016技术预览版4的累积更新:2016年6月14日-)之后。我的应用程序开始报告此异常:C# 调用SSPI失败,请参阅内部异常-无法联系本地安全机构,c#,.net,networking,network-programming,sspi,C#,.net,Networking,Network Programming,Sspi,我有一个WPF应用程序,它使用SSLStream连接到服务器并发送/接收一些消息。我的代码主要基于这个示例(SslTcpClient): 这几个月来效果不错。但是,在获得此windows更新(windows 10版本1511和windows Server 2016技术预览版4的累积更新:2016年6月14日-)之后。我的应用程序开始报告此异常: System.Security.Authentication.AuthenticationException: A call to SSPI faile
System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The Local Security Authority cannot be contacted
--- End of inner exception stack trace ---
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
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.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
at MyAPP.Core.Services.Network.Impl.SslTcpClient.ClientSideHandshake()
at MyAPP.Core.Services.Network.Impl.SslTcpClient.Connect()
at MyAPP.Core.Services.Impl.MessageService.SendMessage(String message)
我能做什么?这是解决方案,在注册表中设置: [HKEY\U LOCAL\U MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\KeyExchangeAlgorithms\Diffie Hellman] “ClientMinKeyBitLength”=dword:00000200
如前所述这意味着另一方正在使用另一版本的TLS,而您正在使用旧版本。
在建立连接之前,将安全属性设置为TLS12。 这是一个众所周知的问题,因为许多提供商开始使用TLS12(如贝宝、亚马逊等)
如果正在使用SslStream,则需要在AuthenticateTaseClient调用中显式设置TLS版本,例如:
ssl.AuthenticateAsClient(url, null, SslProtocols.Tls12, false);
尝试将servicePrincipalName添加到客户端App.config文件中
<client>
<endpoint ............................
<identity>
<servicePrincipalName/>
</identity>
</endpoint>
</client>
我在使用Oracle.ManagedDataAccess.dll
连接到Oracle
数据库时遇到此异常
“Oracle.ManagedDataAccess.Client.OracleException(0x80004005):Oracle无法连接到服务器或无法分析连接字符串-->OracleInternal.Network.NetworkException(0x80004005):Oracle:Oracle无法连接到服务器或无法分析连接字符串-->System.Security.Authentication.AuthenticationException:调用SSPI失败,请参阅内部异常。-->System.ComponentModel.Win32Exception:安全包中没有可用的凭据\r\n---内部异常结束ck trace---\r\n位于System.Net.Security.NegoState.StartSendAuthResetSignal(LazyAsyncResult-lazyResult,字节[]消息,异常异常)\r\n位于System.Net.Security.NegoState.StartSendBlob(字节[]消息,LazyAsyncResult-lazyResult)\r\n位于
经过长时间的查找和尝试,我终于找到了作品,添加了设置
部分,并在app.config
中设置name=“SQLNET.AUTHENTICATION\u SERVICES”value=”“
:
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) "/>
</dataSources>
<settings>
<setting name="SQLNET.AUTHENTICATION_SERVICES" value=""/>
</settings>
</version>
</oracle.manageddataaccess.client>
在上面答案中的参考链接中,您可以进一步尝试,设置:
SQLNET.AUTHENTICATION_SERVICES=()
在您的Oracle Client
文件夹中的sqlnet.ora
也可以使用。在Windows 10计算机上进行此更新后,我们遇到了相同的问题。我们正在使用MySQL.NET连接器通过SSL连接到远程MySQL数据库。Jon,您找到解决方案了吗?我在连接MySQL数据库时遇到了相同的问题。参考关于删除DH 512支持原因的MS技术讨论。我无法以任何其他方式使其工作,因此感谢您的提示。在我的情况下,消息是“安全包中没有可用的凭据”,它也可以工作,Life Saver!
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) "/>
</dataSources>
<settings>
<setting name="SQLNET.AUTHENTICATION_SERVICES" value=""/>
</settings>
</version>
</oracle.manageddataaccess.client>