通过SSL为IIS6配置WCF传输安全性

时间:2011-06-28 12:18:16

标签: wcf security ssl iis-6 transport

我一直在尝试在IIS6上使用SSL设置WCF传输安全性。

客户端位于同一域中的单独计算机上。

我理解证书,根CA等的前提,并且具有一组用于消息安全的工作证书,并且可以在相同的环境设置中使用这些无probs。 (我上周没学到很多东西:)。

当我将客户端切换到SSL时,我正试图让我的客户端对IIS 6服务进行身份验证。在打电话时总是收到“不允许匿名认证”。

在IIS中我有

  • 在SSL端口443的站点上设置的根签名CA证书 (如果我浏览https:// svc页面,我可以看到IE挂锁,页面显示你需要证书进行通信)

在安全通信下我有

  • 需要SSL渠道
  • 需要128位加密
  • 需要客户端证书
  • 启用客户端证书映射(在IIS框上设置多个到1的映射到管理员帐户,现在在证书主题O字段上匹配)

在网站安全(身份验证和访问控制)下

  • 匿名访问=开启
  • 集成Windows身份验证=关闭
  • 基本身份验证=开启

对于客户端wsHttpBinding,我有一个可以进行身份​​验证的证书和一个提供此信息的自定义端点行为,但我认为它没有这么做!

更新的服务器配置

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="CertificateWithTransport">
                <security mode="Transport">
                    <transport clientCredentialType="Certificate"/>
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <services>
        <service name="WCFServiceCertificate.Service1" behaviorConfiguration="credentialConfig">                
            <endpoint address="https://svnvmig02/Service1.svc" 
                        binding="wsHttpBinding" 
                        bindingConfiguration="CertificateWithTransport" 
                        contract="WCFServiceCertificate.IService1">
            </endpoint>
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="credentialConfig">                   
                <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false"/>                    
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

更新的客户配置

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IService1">
                <security mode="Transport">
                    <transport clientCredentialType="Certificate" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://svnvmig02/Service1.svc" binding="wsHttpBinding" behaviorConfiguration="CustomBehavior"
            bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
            name="WSHttpBinding_IService1">
        </endpoint>
    </client>
    <behaviors>
        <endpointBehaviors>
            <behavior name="CustomBehavior">
                <clientCredentials>
                    <clientCertificate findValue="svnvmig02" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>
                    <serviceCertificate>
                        <authentication certificateValidationMode="PeerTrust"/>
                    </serviceCertificate>
                </clientCredentials>
            </behavior>
        </endpointBehaviors>
    </behaviors>
</system.serviceModel>  

修改 可能值得一提的是我的VS项目是3.5,但IIS6正在运行.net4

使用修改后的配置(感谢Fabio;)我现在可以从客户端计算机上浏览地址https://svnvmig01/Service1.svc并查看生成的svc页面,该页面允许我点击也可用的wsdl URl。

我在网上找到的大多数页面都指的是自托管或IIS7 ....我希望IIS7支持更好;)

非常感谢任何帮助:)

2 个答案:

答案 0 :(得分:1)

您的配置包括:

https://svnvmig02:8091/Service1.svc

ssl的正常端口是443。

可能是请求未转到您希望转到的网站。因此,您收到了意外的错误消息。

检查IIS日志以确定哪个站点正在接收请求。

答案 1 :(得分:1)

我认为您的问题可能是您将IIS设置为:

  

匿名访问=关闭

我在我的几台服务器上使用传输安全性,并且所有IIS6都将该设置设置为ON,而不是OFF。这也对应于您提供的错误消息:

  

'不允许匿名认证'

如果没有匿名访问权限,IIS将要求用户输入用户名/密码,或者传递windows / active目录/ kerberos凭据。