【问题标题】:Hot to implement wcf client with ws-security with timestamp, username, encrypt and signature?使用带有时间戳、用户名、加密和签名的 ws-security 来实现 wcf 客户端很热门?
【发布时间】:2014-06-30 19:13:10
【问题描述】:

我尝试使用 WS-Security 规范编写 java 服务器的 wcf 客户端。有什么方法可以按照我在问题中给出的顺序(时间戳、用户名、加密和签名)在 C# 中以编程方式实现客户端

【问题讨论】:

  • 服务使用什么肥皂版本?如果 Soap 1.1 那么你必须使用 CustomBinding 如果 1.2 你可以使用 WsHttpBinding 。顺便说一句,为什么要编码而不是配置?
  • 我应该使用 Soap 1.1。其实我不知道怎么配置或者编码。可以的话,能不能通过配置举个例子?

标签: wcf-client ws-security


【解决方案1】:

你的帖子很难说你的相应设置是什么。这里有我用来消费使用 ws-security 的 java web 服务的配置。在我的情况下,我获得了客户端证书,并且为我导出并从服务站点安装证书的服务。 对于您肯定会遇到的几个问题,请参阅this site 在下面将 xx 替换为您的证书指纹。 让我们知道您的进展。

  <system.serviceModel>
    <bindings>

      <customBinding>

 <binding name="MyBindingName" >          
          <textMessageEncoding messageVersion="Soap11"/>
          <security authenticationMode="MutualCertificate" enableUnsecuredResponse="true" allowSerializedSigningTokenOnReply="true"
                    messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
                    includeTimestamp="true">
          </security>
          <httpsTransport />
        </binding>        
      </customBinding>


    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="ClientCertificateBehavior">
          <clientCredentials>
            <clientCertificate findValue="xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx"
                               storeLocation="CurrentUser" storeName="My" 
                               x509FindType="FindByThumbprint" />

            <serviceCertificate>
              <defaultCertificate findValue="xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx" 
                                  storeLocation="CurrentUser" storeName="My"
                                  x509FindType="FindByThumbprint"/>
              <authentication  />
            </serviceCertificate> 
          </clientCredentials>

        </behavior>

      </endpointBehaviors>

    </behaviors>
    <client>
      <endpoint address="https://YOURSERVICE_ADDRESS"
        binding="customBinding" bindingConfiguration="MyBindingName"
        contract="srvContract" name="srvContract"  behaviorConfiguration="ClientCertificateBehavior">
      </endpoint>

    </client>
  </system.serviceModel>

【讨论】:

    猜你喜欢
    • 2020-12-20
    • 2012-03-11
    • 1970-01-01
    • 1970-01-01
    • 2021-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-25
    相关资源
    最近更新 更多