【问题标题】:Consuming a web service using digest authentication使用摘要身份验证使用 Web 服务
【发布时间】:2012-03-13 15:15:16
【问题描述】:

我们使用 C# 通过 SOAP 发送 XML 数据。该服务需要使用#PasswordDigest#Base64Binary Nonce 进行HttpDigest 身份验证。我们的binding 代码:

protected BasicHttpBinding binding = new BasicHttpBinding()
{
            Name = "ShipmentServiceSoapBinding",
            CloseTimeout = new TimeSpan(0, 01, 0),
            OpenTimeout = new TimeSpan(0, 01, 0),
            ReceiveTimeout = new TimeSpan(0, 10, 0),
            SendTimeout = new TimeSpan(0, 5, 0),
            AllowCookies = false,
            BypassProxyOnLocal = false, 
            HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
            MaxBufferPoolSize = 5242880,
            MaxReceivedMessageSize = 655360,
            MessageEncoding = WSMessageEncoding.Text ,
            TextEncoding =  new UTF8Encoding(),
            UseDefaultWebProxy = true,
            ReaderQuotas = new XmlDictionaryReaderQuotas() { MaxDepth = 32, MaxStringContentLength = 81920, MaxArrayLength = 1638400, MaxBytesPerRead = 409600, MaxNameTableCharCount = 163840 },
            Security = new BasicHttpSecurity() { Mode = BasicHttpSecurityMode.TransportWithMessageCredential, 
                                                 //Message = new BasicHttpMessageSecurity() { AlgorithmSuite = SecurityAlgorithmSuite.Default, ClientCredentialType = BasicHttpMessageCredentialType.UserName}, 
                                                 Transport = new HttpTransportSecurity(){ ClientCredentialType = HttpClientCredentialType.Digest}},

};

根据我们选择的 BasicHttpSecurityMode 类型,我们遇到了 3 个不同的问题。

  1. 传输 - XML 不包含任何安全信息
  2. TransportCredentialOnly - 我们得到的错误表明端点不能是 https://
  3. TransportWithMessagecredential - 这不使用摘要

现在他们的 ServiceReference 允许我们使用 ClientCredentials 类,所以这是我们尝试使用 HttpDigest 的方法:

typeClient.ClientCredentials.HttpDigest.ClientCredential.UserName = "username";
typeClient.ClientCredentials.HttpDigest.ClientCredential.Password = "password";

我读过其他 StackOverflow 问题,对于摘要,我们应该将 SoapHeader 与 AuthHeader 一起使用,但我们无法将其与 API 中提供的内容相匹配。还有其他方法吗?还是他们的 API 没有为 C# 正确编写?

【问题讨论】:

    标签: c# web-services api digest-authentication


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-19
      • 1970-01-01
      • 1970-01-01
      • 2013-01-31
      • 1970-01-01
      • 2010-09-28
      • 1970-01-01
      • 2011-05-20
      相关资源
      最近更新 更多