无法找到"System.IdentityModel.Tokens.UserNameSecurityToken"令牌类型的令牌身份验证器.

Fen*_*ton 3 wcf wcf-binding wcf-security

我试图让第三方Java客户端与我编写的WCF服务进行通信.

收到消息时收到以下异常:

无法找到"System.IdentityModel.Tokens.UserNameSecurityToken"令牌类型的令牌身份验证器.根据当前的安全设置,不能接受该类型的令牌.

这是我的配置:

捆绑

<customBinding>
    <binding name="TestSecureBinding">
        <security authenticationMode="MutualCertificate" />
        <textMessageEncoding messageVersion="Soap11WSAddressing10" />
        <httpsTransport requireClientCertificate="true" maxReceivedMessageSize="5242880" />
    </binding>
</customBinding>
Run Code Online (Sandbox Code Playgroud)

行为:

  <serviceBehaviors>
    <behavior name="TestCertificateBehavior">
      <serviceCredentials>
        <clientCertificate>
          <certificate storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="Test 01"/>
          <authentication certificateValidationMode="PeerTrust" trustedStoreLocation="LocalMachine" revocationMode="NoCheck"/>
        </clientCertificate>
        <serviceCertificate storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="Test 01"/>
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
Run Code Online (Sandbox Code Playgroud)

终点:

  <service name="TestService"
           behaviorConfiguration="TestCertificateBehavior">
    <endpoint
      name="TestEndpoint"
      address="https://localhost:443"
      contract="TestServiceContract"
      binding="customBinding"
      bindingConfiguration="TestSecureBinding">
    </endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="https://localhost:443" />
      </baseAddresses>
    </host>

  </service>
Run Code Online (Sandbox Code Playgroud)

有谁知道是什么原因造成的?

Chr*_*ris 6

因为错误的引用证书的方式已被用于某处,如果我没记错,你可以直接引用证书或使用密钥标识符 - 无论如何,为了超越它,你应该能够将allowSerializedSigningTokenOnReply标记添加到你的安全性标记客户端绑定配置并将其设置为true.

应该超越它适合你-请记住,把这个客户端

对不起,我找不到参考文献 - 我记得在某个地方读它,现在找不到!:(****编辑在这里它是**** - http://webservices20.blogspot.co.uk/2010/10/wcf-cannot-find-token-authenticator.html

<customBinding>  
<binding name="TestSecureBinding"> 
        <security allowSerializedSigningTokenOnReply="true" /> 
        etc
    </binding> 
<customBinding> 
Run Code Online (Sandbox Code Playgroud)