WCF consume Https Web Service, error: Could not establish trust relationship for the SSL/TLS secure channel with authority
WCF consume Https Web Service, error: Could not establish trust relationship for the SSL/TLS secure channel with authority
连接到 https 网络服务服务器时出现此错误:
无法为具有权限的 SSL/TLS 安全通道建立信任关系
我正在使用消息层安全性,正文是用 CERT 证书加密的。服务器证书的证书验证不受 ServicePointManager.ServerCertificateValidationCallback 委托控制,我不能用它来接受证书。
https://xxxxx.com/callservice 证书已加载到调用服务器上,我做错了什么?一个加载证书的例子?
如果你有任何疑问,请让我回答你。
web.config
<system.serviceModel>
<extensions>
<bindingElementExtensions>
<add name="SecurityBindingElement" type="Service.AsymetricSecurityExtentionElement, Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bindingElementExtensions>
</extensions>
<bindings>
<customBinding>
<binding name="SUMA">
<MySecurityBindingElement/>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://xxxxx.com/callservice"
binding="customBinding" bindingConfiguration="SUMA" contract="ConsultaService"
name="SUMA" behaviorConfiguration="cliBeh" >
<identity>
<certificateReference storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" findValue="CERT"/>
</identity>
</endpoint>
</client>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="1" maxConcurrentInstances="2147483647" maxConcurrentSessions="10" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="cliBeh">
<clientCredentials>
<clientCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" findValue="CERT"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
非常感谢您的帮助。
我得到的服务器没有return这个错误信息,在serviceCertificate
部分添加如下内容
<sslCertificateAuthentication trustedStoreLocation="CurrentUser" certificateValidationMode="PeerOrChainTrust"/>
我们有这些选项供服务器验证客户端颁发的证书的真实性。它是由certificateValidationMode的值决定的,可以取这些值。
ChainTrust:按照信任链查找有效且已在设备的证书颁发机构存储库中注册的 CA。如果未指定其他模式,则这是默认设置。
PeerTrust:在计算机的 Trusted People 存储库中搜索证书。
PeerOrChainTrust:根据前两个选项之一进行搜索。
自定义:允许您执行自定义验证。为此,有必要实现一个类并将其分配给属性 CustomCertificateValidatorType。
None: 不执行验证
一声问候
连接到 https 网络服务服务器时出现此错误:
无法为具有权限的 SSL/TLS 安全通道建立信任关系
我正在使用消息层安全性,正文是用 CERT 证书加密的。服务器证书的证书验证不受 ServicePointManager.ServerCertificateValidationCallback 委托控制,我不能用它来接受证书。 https://xxxxx.com/callservice 证书已加载到调用服务器上,我做错了什么?一个加载证书的例子?
如果你有任何疑问,请让我回答你。
web.config
<system.serviceModel>
<extensions>
<bindingElementExtensions>
<add name="SecurityBindingElement" type="Service.AsymetricSecurityExtentionElement, Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bindingElementExtensions>
</extensions>
<bindings>
<customBinding>
<binding name="SUMA">
<MySecurityBindingElement/>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://xxxxx.com/callservice"
binding="customBinding" bindingConfiguration="SUMA" contract="ConsultaService"
name="SUMA" behaviorConfiguration="cliBeh" >
<identity>
<certificateReference storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" findValue="CERT"/>
</identity>
</endpoint>
</client>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="1" maxConcurrentInstances="2147483647" maxConcurrentSessions="10" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="cliBeh">
<clientCredentials>
<clientCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" findValue="CERT"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
非常感谢您的帮助。
我得到的服务器没有return这个错误信息,在serviceCertificate
部分添加如下内容<sslCertificateAuthentication trustedStoreLocation="CurrentUser" certificateValidationMode="PeerOrChainTrust"/>
我们有这些选项供服务器验证客户端颁发的证书的真实性。它是由certificateValidationMode的值决定的,可以取这些值。
ChainTrust:按照信任链查找有效且已在设备的证书颁发机构存储库中注册的 CA。如果未指定其他模式,则这是默认设置。
PeerTrust:在计算机的 Trusted People 存储库中搜索证书。
PeerOrChainTrust:根据前两个选项之一进行搜索。
自定义:允许您执行自定义验证。为此,有必要实现一个类并将其分配给属性 CustomCertificateValidatorType。
None: 不执行验证
一声问候