首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Lumesse服务和WSSE纯文本安全问题

Lumesse服务和WSSE纯文本安全问题
EN

Stack Overflow用户
提问于 2014-09-30 17:02:42
回答 1查看 531关注 0票数 2

我们目前正在重新开发一个遗留项目,该项目利用Lumesse提供的SOAP服务,名为over。

Started

这是在ASP.NET应用程序中使用的;原始开发人员(他已经离开很久了)从来没有利用过使用所提供的WSDL,更倾向于手动构建请求并解析响应。虽然这是完全疯狂的,但这正是Lumesse的文档在使用.NET时所建议的,因为他们的服务使用的是过时的WSSE纯文本安全性。

虽然我们通常不会违背常规,但我们更愿意使用内置的支持来使用SOAP服务,而不是像以前的开发人员那样滚动我们自己的解决方案。

我们已经遇到了一些问题,比如无法生成临时类,而我们已经入侵了这些类。

不幸的是,当涉及到发送成功的SOAP请求时,我们现在陷入困境。

当我们提出请求时抛出的异常是:

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

深入挖掘,实际反应如下:

代码语言:javascript
复制
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Header /> 
    <env:Body>
      <env:Fault xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
        <faultcode xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">wsse:FailedCheck</faultcode> 
        <faultstring>Expired message.</faultstring> 
      </env:Fault>
   </env:Body>
</env:Envelope>

似乎是“签名或解密无效”。使用其他开发人员的笨拙的解决方案,使用相同的凭据,可以像预期的那样工作。

,为什么它会在这里失败,我们能做些什么来修复它呢?是否有可能不诉诸于滚动我们自己的请求和响应(甚至推荐?)服务?

http://schemas.xmlsoap.org/specs/ws-security/ws-security.htm

我们使用的WSDL,从Lumesse提供:

https://api3.lumesse-talenthub.com/CareerPortal/SOAP/FoAdvert?WSDL

我们碰到的端点:

key=xxx

到目前为止,我们的代码主要是基于With C#, WCF SOAP consumer that uses WSSE plain text authentication? -的,类似于相同的问题.

Correct way communicate WSSE Usernametoken for SOAP webservice也有同样的问题,但答案是我们将绑定细节存储在web.config中。

代码语言:javascript
复制
using (LumesseSoapTest.FoAdvert.FoAdvertWebServiceClient client = new LumesseSoapTest.FoAdvert.FoAdvertWebServiceClient())
{
    client.ClientCredentials.UserName.UserName = "xxxx";

    client.ClientCredentials.UserName.Password = "xxxx";

    var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);

    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;

    binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

    client.Endpoint.Binding = binding;

    var response = client.getAdvertisements(new LumesseSoapTest.FoAdvert.getAdvertisements());
}

示例request期望,从前面的开发人员的部分家庭滚动解决方案-工作如预期:

代码语言:javascript
复制
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.mrted.com/">
    <soapenv:Header>
        <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:UsernameToken wsu:Id="UsernameToken-11">
                <wsse:Username>xxxx</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
                    xxxx
                </wsse:Password> 
                <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">5Xhsv3Yp2l1xGpL3pNYy6A==
                </wsse:Nonce>
                <wsu:Created>2012-06-22T09:07:26.631Z</wsu:Created>
            </wsse:UsernameToken>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
        <getAdvertisements xmlns="http://ws.mrted.com/">
            <firstResult>0</firstResult>
            <maxResults>0</maxResults>
        </getAdvertisements>
    </soapenv:Body>
</soapenv:Envelope>

我们当前发送的示例请求:

代码语言:javascript
复制
<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>
        <ActivityId CorrelationId="d309ce44-ed91-4314-87ee-e3abee4f531e" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">dd9a8c26-e673-464d-87e4-5cb8b76989c3</ActivityId>
        <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>2014-09-30T16:15:47.426Z</u:Created>
                <u:Expires>2014-09-30T16:20:47.426Z</u:Expires>
            </u:Timestamp>
            <o:UsernameToken u:Id="uuid-c3275c63-6d98-4ae3-a7a7-afe314d23d6c-3">
                <o:Username>xxxx</o:Username>
                <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxxx</o:Password>
            </o:UsernameToken>
        </o:Security>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <getAdvertisements xmlns="http://ws.mrted.com/">
            <firstResult>0</firstResult>
            <maxResults>0</maxResults>
        </getAdvertisements>
    </s:Body>
</s:Envelope>

任何帮助都将不胜感激。

更新

好的,使用这个被黑客攻击的XML,我可以从API中得到一个响应。

我只是不知道如何从我们的请求中产生这个结果。同样,任何帮助都将受到极大的感谢。

代码语言:javascript
复制
<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="UsernameToken-11">
        <o:Username>xxx</o:Username>
        <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxx
        </o:Password>
        <o:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
          5Xhsv3Yp2l1xGpL3pNYy6A==
        </o:Nonce>
        <o:Created>2012-06-22T09:07:26.631Z</o:Created>
      </o:UsernameToken>
    </o:Security>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <getAdvertisements xmlns="http://ws.mrted.com/"><firstResult>0</firstResult><maxResults>10</maxResults>
    </getAdvertisements>
   </s:Body>
</s:Envelope>

更新2(使其工作!)

最后,在大约9个小时后,我们找到了一个地方。我将把这一点留给那些完全不幸地使用Lumesse (或另一个类似的Java服务)的人。

我们在上面发送的XML的主要问题是Security节点下的时间戳节点。它将处理的无关节点,大概是因为它不是Security节点下的第一个节点吗?谁知道呢(这实际上是我第一次以任何形式使用SOAP / WCF,哈哈!)

所以,时间戳节点需要运行,如果需要使用basicHttpBinding或wsHttpBinding这样的标准绑定,则需要创建自定义绑定。下面是一个模仿basicHttpBinding的例子,显然是取自http://www.mikeobrien.net/blog/removing-wss-timestamp-from-wcf/

示例配置:

代码语言:javascript
复制
<customBinding>
  <binding name="MyBinding">
    <security authenticationMode="UserNameOverTransport" includeTimestamp="false" />
    <textMessageEncoding messageVersion="Soap11" />
    <httpsTransport maxReceivedMessageSize="26214400" />
  </binding>
</customBinding>

然后,只需像调用服务那样调用服务,传递凭证(您可能可以将这些信息与上述内容一起存储在web.config中,但我目前不知道该如何操作)。

代码语言:javascript
复制
using (LumesseSoapTest.FoAdvert.FoAdvertWebServiceClient client = new LumesseSoapTest.FoAdvert.FoAdvertWebServiceClient())
{
  client.ClientCredentials.UserName.UserName = "xxxx";

  client.ClientCredentials.UserName.Password = "xxxx";

  foreach (var ad in response.advertisementResult.advertisements)
  {
    @ad.jobTitle <br />
  }

}

再次感谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-16 21:24:10

我也在使用相同的api,也有同样的问题。如果您向下滚动到本文的底部:http://www.hanselman.com/blog/BreakingAllTheRulesWithWCF.aspx Scott通过代码而不是通过配置删除时间戳。

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

https://stackoverflow.com/questions/26126257

复制
相关文章

相似问题

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