WCF安全标题问题似乎与环境有关

时间:2013-07-19 17:32:29

标签: wcf iis soap

我有一个WCF服务,配置为通过basicHttpsBinding执行自定义身份验证。身份验证过程在我的开发计算机(Windows 7,IIS 7.5)上运行正常,但在部署到Windows Server 2008计算机(也称为IIS 7.5)时,WCF拒绝识别一个标头,特别是Security来自{{ 1}}。

客户端配置如下:

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd

服务器配置非常相似,添加了密码验证信息:

<basicHttpsBinding>
    <binding name="MyBinding" transferMode="Streamed" 
             maxReceivedMessageSize="4294967290" maxBufferSize="65536">
        <security mode="TransportWithMessageCredential" >
            <message clientCredentialType="UserName"/>
        </security>
    </binding>
</basicHttpsBinding>
...
<client>
    <endpoint address="https://myservice.com/MyService.svc"
        binding="basicHttpsBinding" bindingConfiguration="MyBinding"
        contract="Service.IMyService" name="MyServiceEndpoint" />
</client>

正如所料,客户端请求包含带有身份验证信息的标头:

<service name="Service.IMyService" behaviorConfiguration="MyBehavior">
    <endpoint binding="basicHttpsBinding" name="MyServiceEndpoint" 
              contract="Service.IMyService" bindingConfiguration="MyBinding" />
</service>
...
<basicHttpsBinding>
    <binding name="MyBinding" transferMode="Streamed" 
             maxReceivedMessageSize="4294967290"
             maxBufferSize="65536">
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName" />
      </security>
    </binding>
</basicHttpsBinding>
...
<behavior name="MyBehavior">
    <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="Custom" 
                customUserNamePasswordValidatorType="Service.CredentialValidator, MyAssembly" />
        <serviceCertificate findValue="MyCert" storeLocation="LocalMachine" 
                storeName="My" x509FindType="FindBySubjectName" />
    </serviceCredentials>
  ...
</behavior>

在本地,标题理解为:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <o:UsernameToken u:Id="uuid-d7168ad6-a829-49ae-9952-dd286ed2ba6d-7">
                <o:Username>username</o:Username>
                <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</o:Password>
            </o:UsernameToken>
        </o:Security>
    </s:Header>
    ...
</s:Envelope>

但是在部署时,没有这样的运气:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        ...
        <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <u:Timestamp u:Id="_0">
                <u:Created>2013-07-19T17:28:00.631Z</u:Created>
                <u:Expires>2013-07-19T17:33:00.631Z</u:Expires>
            </u:Timestamp>
        </o:Security>
    </s:Header>
    ...
</s:Envelope>

我已经完成了所有典型的ASP.NET / WCF设置步骤,包括修复和重新注册处理程序等等。是否还有其他因素可能导致这两种环境之间存在差异?

0 个答案:

没有答案