![](/img/trans.png)
[英]WCF WF Service, Could not establish secure channel for SSL/TLS with authority
[英]WCF client binding to access https service. Could not establish secure channel for SSL/TLS with authority
我需要創建WCF客戶端來連接通過https提供的服務。 負責WCF的當前客戶端配置如下所示:
<wsHttpBinding>
<binding name="TestBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
<client>
<endpoint address="https://address/etc" binding="wsHttpBinding" bindingConfiguration="TestBinding" contract="TestService.Test" name="TestName"/>
</client>
不幸的是我收到了一個錯誤:
Exception: System.ServiceModel.Security.SecurityNegotiationException
Message: Could not establish secure channel for SSL/TLS with authority 'address'.
Source: mscorlib
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
...
Nested Exception
Exception: System.Net.WebException
Message: The request was aborted: Could not create SSL/TLS secure channel.
Source: System
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
我沒有權限修改任何此服務
更新:
出於測試目的,我忽略了Application_Start中的global.asax中的證書,但我仍然得到相同的異常
protected void Application_Start(object sender, EventArgs e) {
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
}
不受信任的證書可能導致此問題。 在致電您的服務之前嘗試這個:
protected void BypassCertificateError()
{
ServicePointManager.ServerCertificateValidationCallback = delegate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
}
但請注意,這不是一個好的做法,因為它完全忽略了服務器證書。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.