使用wcf客户端的证书无效

时间:2013-04-10 22:30:11

标签: wcf certificate wshttpbinding transport-security

我创建了一个简单的wcf服务,使用此web.config:

部署在iis上
<?xml version="1.0"?>
<configuration>

<system.web>
    <compilation debug="true" targetFramework="4.0" />
</system.web>
<system.diagnostics>
    <trace autoflush="true" />
    <sources>
        <source name="System.ServiceModel"
          switchValue="Verbose"
          propagateActivity="true">
            <listeners>
                <add name="sdt"
                       type="System.Diagnostics.XmlWriterTraceListener"
                       initializeData= "log.e2e" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>
<system.serviceModel>
    <services>
         <service behaviorConfiguration="ServiceBehavior" name="WcfService1.Service1">
             <endpoint address="" binding="wsHttpBinding"
                 bindingConfiguration="wsHttpEndpointBinding"
                 name="wsHttpEndpoint" contract="WcfService1.IService1">
             </endpoint>

             <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
                 name="MexHttpsBindingEndpoint" contract="IMetadataExchange" />
         </service>
    </services>
    <bindings>
        <wsHttpBinding>
            <binding name="wsHttpEndpointBinding">
                <security mode="TransportWithMessageCredential">
                    <transport clientCredentialType="Windows" />
                    <message clientCredentialType="UserName" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehavior">
                <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
                <serviceCredentials>
                    <userNameAuthentication userNamePasswordValidationMode="Windows" />
                </serviceCredentials>
            </behavior>
        </serviceBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>

</configuration>

我跟着这个例子:

http://msdn.microsoft.com/en-us/library/aa354508%28v=vs.100%29.aspx

除会员身份验证外。我按照程序在我的客户端计算机和服务器计算机上安装了证书。如果我浏览该服务,则会显示证书问题,但无论如何我可以访问不推荐的站点,我可以看到wsdl。使用wcf客户端,它会抛出错误“无法为SSL / TLS安全通道建立信任关系”。但是使用WCFStorm www.wcfstorm.com/,它可以工作。

我不知道是否始终需要从客户端验证证书,或者证书是否存在问题。这是一个测试环境...感谢任何指导!!

0 个答案:

没有答案