【发布时间】:2017-10-06 12:12:37
【问题描述】:
我需要创建 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; };
}
【问题讨论】:
标签: c# wcf ssl https wcf-binding