【问题标题】:Kerberos Authentication with WCF customBinding使用 WCF customBinding 进行 Kerberos 身份验证
【发布时间】:2010-08-25 12:57:07
【问题描述】:

我正在使用 ASMX Web 服务并使用 customBinding 为该服务创建 WCF 客户端。在 customBinding 安全部分中,我使用 authenticationMode 作为“KerberosOverTransport”并使用 HTTP 作为传输介质。请看下面的代码。

<customBinding>
    <binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00"
      receiveTimeout="00:10:00" sendTimeout="00:01:00">
      <security allowSerializedSigningTokenOnReply="true" authenticationMode="KerberosOverTransport"
        requireDerivedKeys="false" messageProtectionOrder="SignBeforeEncryptAndEncryptSignature"
        messageSecurityVersion="Default" requireSecurityContextCancellation="false">
        <secureConversationBootstrap />
      </security>
      <textMessageEncoding messageVersion="Soap11" />
      <httpTransport authenticationScheme="Ntlm" unsafeConnectionNtlmAuthentication="false" />
    </binding>
  </customBinding>
</bindings>
<client>
  <endpoint address="http://localhost:1612/TestService.asmx" binding="customBinding"
    bindingConfiguration="Service1Soap" contract="WCFProxy.Service1Soap"
    name="Service1Soap" />
</client>

当我创建 Proxy 类的实例并调用 Web 服务的 Hello World 方法时,我得到以下异常。

“'Service1Soap'.'urn:Service1' 合约的 'CustomBinding'.'http://tempuri.org/' 绑定配置了需要传输级别完整性和机密性的身份验证模式。但是传输无法提供完整性和机密性。 "

================================================ ============================================

在 System.ServiceModel.Dispatcher.SecurityValidationBehavior.SoapOverSecureTransportRequirementsRule.ValidateSecurityBinding(SecurityBindingElement securityBindingElement, Binding binding, ContractDescription contract) 在 System.ServiceModel.Dispatcher.SecurityValidationBehavior.ValidateSecurityBinding(SecurityBindingElement sbe,绑定绑定,ContractDescription 合同) 在 System.ServiceModel.Dispatcher.SecurityValidationBehavior.ValidateBinding(绑定绑定、ContractDescription 合约、SecurityBindingElement&securityBindingElement) 在 System.ServiceModel.Dispatcher.SecurityValidationBehavior.System.ServiceModel.Description.IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint) 在 System.ServiceModel.Description.ServiceEndpoint.Validate(布尔 runOperationValidators,布尔 isForService) 在 System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint) 在 System.ServiceModel.ChannelFactory.CreateFactory() 在 System.ServiceModel.ChannelFactory.OnOpening() 在 System.ServiceModel.Channels.CommunicationObject.Open(时间跨度超时) 在 System.ServiceModel.ClientBase1.System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.ClientBase1.Open() 在 D:\Rakesh\Test Projects\WebServiceCustomBinding\WCFClient\Program.cs:line 16 中的 WCFClient.Program.Main(String[] args) 在 System.AppDomain._nExecuteAssembly(程序集程序集,字符串 [] 参数) 在 System.AppDomain.ExecuteAssembly(字符串 assemblyFile,证据 assemblySecurity,String [] args) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在 System.Threading.ThreadHelper.ThreadStart_Context(对象状态) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback 回调,对象状态) 在 System.Threading.ThreadHelper.ThreadStart()

我在谷歌上搜索这个异常时没有运气。研发部分到现在已经2天了。请在此问题上为我提供一些帮助。有你的帮助我会很高兴的!

问候, 拉克什。

【问题讨论】:

    标签: wcf wcf-binding wcf-client kerberos


    【解决方案1】:

    尝试使用具有以下安全性的 BasicHttpBinding:

    <bindings>
      <basicHttpBinding>
        <binding name="Secured">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    

    您也可以查看article - 有一部分是关于设置客户端的。

    【讨论】:

    • 在开始使用 customBinding 之前,我已经尝试过使用 basicHttpBinding。我使用 customBinding 的原因是我的应用程序需要与需要 Kerberos 身份验证才能实现 SSO 的 Java Web 服务互操作。更多的 Java Web 服务可以安装在 Windows 以外的任何类型的平台上,因此在该平台上 Windows clientCredentialType 可能无法正常工作。感谢您的回复。你能建议我解决上述要求吗?很抱歉之前没有提供这些细节!
    • 比您需要用于测试的 Java Web 服务。如果您拥有该服务的 WSDL 以及描述其配置的安全策略,那就太棒了。目前您正在尝试使用与 Java 不同的 ASMX 模拟服务。
    • 是的,我明白了。我的实际要求是在 C#.NET 中构建一个 WCF 客户端,该客户端将实现 Kerberos 身份验证以实现 SSO。这反过来将由 Java Windows 应用程序用于验证用户并分配 Kerberos 令牌。目前 Java 应用程序还没有准备好,所以我试图让这个客户端只与 ASMX Web 服务一起工作。稍后在使用 ASMX 服务成功测试后,我将尝试将此客户端与 Java 应用程序集成。
    【解决方案2】:

    尝试改用&lt;httpsTransport requireClientCertificate="true"/&gt; 绑定元素。

    【讨论】:

      猜你喜欢
      • 2023-03-12
      • 1970-01-01
      • 2011-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多