首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >实现WIF ActAs方案:传出消息的身份检查失败

实现WIF ActAs方案:传出消息的身份检查失败
EN

Stack Overflow用户
提问于 2012-09-26 15:33:45
回答 1查看 1K关注 0票数 0

因此,我尝试从一个网站使用一个WCF服务,并将站点从STS获得的IClaimsIdentity传递到服务。

当我试图通过ActAs通道调用服务方法时,我在客户机上得到以下错误(查看跟踪日志,它永远不会到达服务,并且STS正确地发送所有令牌):

传出邮件的标识检查失败。对于“http://schemas.xmlsoap.org/ws/2005/05/identity/right/possessproperty”目标端点,预期的标识是“identity (http://localhost/MyWCFHost/MyService.svchttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/thumbprint)”。

我有一个自定义的IssuedTokenForCertificate绑定,据我所见,所有的证书都是正常的,它应该可以工作,但是没有骰子。我希望再多一双眼睛看看我的配置,并帮我:

使用网站配置:

代码语言:javascript
复制
  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="CustomBinding_IMyService">
          <security defaultAlgorithmSuite="Default" authenticationMode="IssuedTokenForCertificate"
            requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10"
            requireSignatureConfirmation="true">
            <issuedTokenParameters tokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1">
              <additionalRequestParameters>
                <trust:SecondaryParameters xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
                  <trust:TokenType xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</trust:TokenType>
                  <trust:KeyType xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/ws-sx/ws-trust/200512/SymmetricKey</trust:KeyType>
                </trust:SecondaryParameters>
              </additionalRequestParameters>
              <issuer address="http://localhost/MyCompany.SecurityTokenService/ActAsIssuer.svc"
                binding="ws2007HttpBinding" bindingConfiguration="http://localhost/MyCompany.SecurityTokenService/ActAsIssuer.svc">
              </issuer>
              <issuerMetadata address="http://localhost/MyCompany.SecurityTokenService/ActAsIssuer.svc/mex" />
            </issuedTokenParameters>
            <localClientSettings detectReplays="true" />
            <localServiceSettings detectReplays="true" />
          </security>
          <textMessageEncoding />
          <httpTransport />
        </binding>
      </customBinding>
      <ws2007HttpBinding>
        <binding name="http://localhost/MyCompany.SecurityTokenService/ActAsIssuer.svc">
          <security>
            <message establishSecurityContext="false" />
          </security>
        </binding>
      </ws2007HttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost/MyWCFHost/MyService.svc" binding="customBinding"
        bindingConfiguration="CustomBinding_IMyService" contract="MyService.IMyService"
        name="CustomBinding_IMyService">
        <identity>
          <!--<certificate encodedValue="AwAAAAEAAAAUAAAAV2ILlfzl9NIHEiGv1rUCSitq8I0gAAAAAQAAAP8BAAAwggH7MIIBaKADAgECAhBTTBmG1HyUkEDVFmVUxfDLMAkGBSsOAwIdBQAwFTETMBEGA1UEAxMKRXRhbmEgUm9vdDAeFw0xMjA5MjExMjE2MDRaFw0zOTEyMzEyMzU5NTlaMB8xHTAbBgNVBAMTFEV0YW5hIFNUUyBFbmNyeXB0aW9uMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0lbzr1b1aNiXGhwKMTO58QbLbbKoUtTRkA4egMlmip1Vm46BnscWAMvXA5kyzuqK6Cw/5bel15i0pZXR4kjByKbSr65V0/ODGrkUHaYb5vT8RzCczYcgzJmPGWawMYYJT8PXLXHkFmZZGXFZhiUBzyNMWh8YH16I/wFtUgmaBAQIDAQABo0owSDBGBgNVHQEEPzA9gBAV68U+Vhoc0Nu9qPJXfJSRoRcwFTETMBEGA1UEAxMKRXRhbmEgUm9vdIIQgnOTDbZVCaJFTK8PPAGynTAJBgUrDgMCHQUAA4GBACHLr32oqkFjKGN/fqk2VnsNNIs9niHQ4Q6UbJ252YWf4wFIz9Ho/+ZdFxC4tSHxa/IMH0kzYpRL5p61Zd8/QeryWCStqvoNPwyapaY3g0Pkm6dy6NJ82kX5eJxLjdJp8MVadPJs4VA7Smf+e9lMMoONAGP07AvzAVhtiYK2yMmH" />-->
          <certificateReference findValue="57620B95FCE5F4D2071221AFD6B5024A2B6AF08D" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

WCF服务配置:

代码语言:javascript
复制
  <system.serviceModel>
    <diagnostics>
      <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
    </diagnostics>
    <services>
      <service name="RPWCFApp.MyService" behaviorConfiguration="MyServiceBehaviour">
        <endpoint address="" binding="customBinding" bindingConfiguration="CustomBindingConfiguration_IssuedTokenOverTransport" contract="RPWCFApp.IMyService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehaviour">
          <federatedServiceHostConfiguration />
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceCredentials>
            <serviceCertificate findValue="81A5DB3796F48B00FAC37CE67D7D8CA43078B996" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <extensions>
      <behaviorExtensions>
        <add name="federatedServiceHostConfiguration" type="Microsoft.IdentityModel.Configuration.ConfigureServiceHostBehaviorExtensionElement, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </behaviorExtensions>
    </extensions>

    <bindings>
      <customBinding>
        <binding name="CustomBindingConfiguration_IssuedTokenOverTransport">
          <security authenticationMode="IssuedTokenForCertificate" messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10">
            <issuedTokenParameters keyType="SymmetricKey" tokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1">
              <issuer address="http://localhost/MyCompany.SecurityTokenService/ActAsIssuer.svc" binding="ws2007HttpBinding" bindingConfiguration="IssuedTokenBinding" />
              <issuerMetadata address="http://localhost/MyCompany.SecurityTokenService/ActAsIssuer.svc/mex" />
            </issuedTokenParameters>
          </security>
          <textMessageEncoding />
          <httpTransport />
        </binding>
      </customBinding>
      <ws2007HttpBinding>
        <binding name="IssuedTokenBinding">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="Windows" establishSecurityContext="false" />
          </security>
        </binding>
      </ws2007HttpBinding>
    </bindings>
  </system.serviceModel>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-27 08:01:00

通过将服务配置中的绑定更改为ws2007FederationHttpBinding而不是CustomBinding来解决我的问题,并更新我的客户机服务引用。

代码语言:javascript
复制
<bindings>
  <ws2007FederationHttpBinding>
    <binding name="serviceBinding" receiveTimeout="05:00:00" sendTimeout="05:00:00">
      <security mode="Message">
        <message>
          <issuerMetadata address="http://localhost/MyCompany.SecurityTokenService/ActAsIssuer.svc/mex"/>
        </message>
      </security>
    </binding>
  </ws2007FederationHttpBinding>
</bindings>

然后,由于我使用的是自签名证书,所以必须使用客户端配置中的以下端点行为来更改certificateValidationMode:

代码语言:javascript
复制
<behaviors>
  <endpointBehaviors>
    <behavior name="MyServiceBehavior" >
      <clientCredentials>
        <serviceCertificate>
          <authentication certificateValidationMode="PeerOrChainTrust"/>
        </serviceCertificate>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
</behaviors>

最后,我只需确保我的证书在可信的人员存储中,最后在调用服务时得到正确的IClaimsIdentity :)

希望这能帮上忙,因为这让我一时抓狂.

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12605336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档