WCF和客户端证书身份验证

时间:2013-06-13 15:04:33

标签: c# wcf web-services authentication

在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下工作得很好。)我一直在搜索,找不到任何与当前配置相符的东西。

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

1 个答案:

答案 0 :(得分:0)

嗯,在深入挖掘之后,我发现我使用了错误的指纹。我使用的那个属于来自同一发行人的证书,但是对于不同的终点(不确定我是如何混淆它们的)。现在我已经使用了正确的证书,我可以建立SSL。

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