【问题标题】:WCF consume Https Web Service, error: Could not establish trust relationship for the SSL/TLS secure channel with authorityWCF 使用 Https Web 服务,错误:无法为具有权限的 SSL/TLS 安全通道建立信任关系
【发布时间】:2017-10-07 16:57:57
【问题描述】:

连接到 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>

非常感谢您的帮助。

【问题讨论】:

    标签: wcf security ssl certificate


    【解决方案1】:

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

    &lt;sslCertificateAuthentication trustedStoreLocation="CurrentUser" certificateValidationMode="PeerOrChainTrust"/&gt;

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

    ChainTrust:Busca un CA que sea válido y que esté registrado en el repositorio de autoridades de certificación delequipo, 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) delequipo。

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

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

    :没有实现验证算法

    问候

    【讨论】:

      猜你喜欢
      • 2015-02-12
      • 2023-03-15
      • 1970-01-01
      • 2010-12-17
      • 2018-11-10
      • 2014-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多