【发布时间】:2019-10-20 08:26:19
【问题描述】:
我正在尝试使用 c# .NET 4.5 使用soap11 和客户端证书凭据通过https 连接到soap Web 服务。我使用vs的工具来添加服务引用,它为我创建了一个soap客户端。
我已经创建了一个 customBinding 来通过 soap11 完成 https:
App.config
<system.serviceModel>
<bindings>
<customBinding>
<binding name="*****" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:05:00" sendTimeout="00:05:00">
<textMessageEncoding messageVersion="Soap11"/>
<httpsTransport useDefaultWebProxy="false" requireClientCertificate="true" allowCookies="false" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="******************"
behaviorConfiguration="******************"
binding="customBinding" bindingConfiguration="******************"
contract="******************"
name="******************" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="******************">
<clientCredentials>
<clientCertificate findValue="******************" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
c#代码:
var client = new IConsultService.ConsultServiceClient();
client.consult("1");
client.consult("1"); <!-- fail error 404 - there was not endpoint listening at
如果我在没有证书的情况下发布接收 tomcat 404,如果我第一次发送客户端证书工作正常,并且在我看来我被重定向了。问题是在第二次请求失败(404)时,如果我再次实例化客户端失败。只有在停止应用程序并重新启动时才能再次工作。似乎有些东西缓存在程序的静态堆栈中。
由于是 404,我的猜测是来自客户端证书,如果我在没有证书的情况下请求,则错误是相同的。
我尝试以编程方式创建绑定,设置 ClientBase.CacheSetting = CacheSetting.AlwaysOff 没有运气。
编辑1: 使用 System.Net.HttpWebRequest 发生同样的情况,第一个请求 ok,第二个请求 404。
编辑2: 握手第一个请求发送“证书,客户端密钥交换”和第二个请求“更改密码密钥交换”似乎有一些东西
有没有办法强制关闭通道并始终发送“证书,客户端密钥交换”?
谢谢
【问题讨论】:
-
有趣的是我有相反的问题。第一次调用失败,后续调用都成功。
标签: c# wcf network-programming ssl-certificate