【问题标题】:WCF and client certificate authenticationWCF 和客户端证书身份验证
【发布时间】:2013-06-13 15:04:32
【问题描述】:

在 C#/WCF 中编写 Web 服务客户端并且无法让通道进行身份验证。这是我尝试执行 API 调用时收到的错误消息:

"Could not establish secure channel for SSL/TLS with authority 'www.redacted.com'."

还有配置文件:

    <behaviors>
        <endpointBehaviors>
            <behavior name="NewBehavior0">
                <clientCredentials>
                    <clientCertificate findValue="th um bp ri nt va lu e  go es he re"
                        x509FindType="FindByThumbprint" />
                </clientCredentials>
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <bindings>
        <basicHttpBinding>
            <binding name="WsApiServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
                <security mode="Transport">
                    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                    <message clientCredentialType="UserName" algorithmSuite="Default"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://www.<redacted>.com/services/WsApiService/"
            behaviorConfiguration="NewBehavior0" binding="basicHttpBinding"
            bindingConfiguration="WsApiServiceSoapBinding" contract="WsApiServicePortType"
            name="WsApiServicePort" />
    </client>

我在客户端代码中唯一要做的就是执行对 getDoc 方法的调用。代理类是从 WCF 下的 WSDL 自动生成的。我已验证证书已安装在 certmgr 的个人类别中,未过期,并且适用于所有目的。 (我应该注意到,同样的证书在 WSE 下工作得很好。)我四处搜索,找不到任何与其当前配置相矛盾的东西。

有什么想法吗?如果您需要查看更多代码,请告诉我,我会尽快发布。

【问题讨论】:

  • 服务证书是自签名的吗?
  • 是的。它是由第三方网络服务签发和签署的。
  • 那就看看这个问题:stackoverflow.com/questions/1742938/…
  • 我不确定该问题是否与我的问题相关。 - 错误信息不同。我的不是信任问题。 - 除了否定服务器证书验证之外,我已经尝试了那里的所有内容。无论如何,这种特定方法不是一种选择。我将看看是否有某种方法可以强迫我的客户披露它正在使用的证书。也许朝那个方向挖掘会发现一些东西。
  • 那么您将如何验证您的自签名证书?在每种情况下,您都必须盲目相信它。我建议您至少尝试验证回调的事情。至少你可以拒绝这个假设:)

标签: c# wcf web-services authentication


【解决方案1】:

好吧,在深入挖掘之后,我发现我使用了错误的指纹。我使用的证书属于同一颁发者的证书,但用于不同的端点(不知道我是如何混淆它们的)。现在我已经使用了正确的证书,我可以建立 SSL。

现在我只需要弄清楚为什么这个 MTOM 服务对我的 MTOM 请求感到惊讶:P

【讨论】:

  • 很高兴听到这个消息!有时解决方案就在我们眼皮底下!
猜你喜欢
  • 2011-04-09
  • 2013-10-07
  • 2018-02-12
  • 2012-01-03
  • 1970-01-01
  • 2022-06-23
  • 1970-01-01
  • 1970-01-01
  • 2013-01-26
相关资源
最近更新 更多