WCF 使用 Https Web 服务,错误:无法与权限建立 SSL/TLS 安全通道的信任关系



连接到https Web服务服务器时给我此错误:

无法与权限建立 SSL/TLS 安全通道的信任关系

我正在使用消息层安全性,正文使用 CERT 证书加密。服务器证书的证书验证不受 ServicePointManager.ServerCertificateValidationCallback 委托的控制,我不能用它来接受证书。 https://xxxxx.com/callservice 证书加载到调用服务器上,我做错了什么?¿加载证书的一些示例?

如果您有任何疑问,请告诉我回答您。

网络.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>

非常感谢您的帮助。

我让服务器不返回此错误消息,在服务证书部分添加以下内容

<sslCertificateAuthentication trustedStoreLocation="CurrentUser" certificateValidationMode="PeerOrChainTrust"/>

Tenemos estas opciones para que el servidor verifique la autenticidad del certificado emitido por el cliente.Se determina por el valor decertificateValidationMode, puede tomar estos valores.

ChainTrust: Busca un CA que sea válido y que esté registrado en el repositorio de autoridades de certificación del equipo, siguiendo una cadena de confianza.Este es el valor por defecto si no se especifica otro modo.

PeerTrust: Busca el certificado en el repositorio de Trusted People (personas de confianza) del equipo.

PeerOrChainTrust: Busca en base a una de las dos opciones anteriores.

Custom: Permite realizar una validación a medida.Para ello es necesario implementar una clase y asignarlo a la propiedad CustomCertificateValidatorType.

None: No se realiza validación alguna

一个问候

最新更新