2012-02-20 41 views
9

Tôi có một máy khách WCF đang gửi thư tới dịch vụ không phải WCF và dịch vụ đó đang gặp sự cố khi xử lý phương thức chữ ký HMAC-SHA1 được sử dụng để ký WS -Phần tử Dấu thời gian bảo mật. Lý tưởng nhất, chúng tôi muốn sử dụng phương pháp chữ ký RSA-SHA1 nhưng tôi đã không thể có được WCF để sử dụng phương pháp chữ ký đó.WCF Client - Chỉ định thuật toán chữ ký cho chữ ký WS-Security Dấu thời gian

Các ràng buộc tôi đang sử dụng là một ràng buộc tùy chỉnh được cho phép tôi để gửi một SAML 2.0 thẻ qua HTTPS:

<customBinding> 
    <!-- This binding is a WS2007FederationHttpBinding without Secure Sessions that uses Text message encoding. --> 
    <binding 
     name="WS2007FederationHttpBinding_NoSecureSession_Text" 
     closeTimeout="00:01:00" 
     openTimeout="00:01:00" 
     receiveTimeout="00:10:00" 
     sendTimeout="00:01:00"> 
     <security 
      authenticationMode="IssuedTokenOverTransport" 
      requireSignatureConfirmation="true" 
      securityHeaderLayout="Lax" 
      messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" 
      keyEntropyMode="CombinedEntropy" 
      includeTimestamp="true"> 
      <issuedTokenParameters 
       tokenType="urn:oasis:names:tc:SAML:2.0:assertion"> 
       <!-- This describes the STS. That is, the URL, the binding to use, and its Identity --> 
       <issuer 
        address="http://hostname//STS.svc" 
        binding="ws2007HttpBinding" 
        bindingConfiguration="StsUserNameBindingConfiguration"> 
        <identity> 
         <!-- This is the certificate used for signing on the STS. --> 
         <!-- Replace "sts-signing-certificate-thumbprint" with the actual thumbprint of the STS's signing certificate --> 
         <certificateReference 
          findValue="sts-signing-certificate-thumbprint" 
          storeLocation="LocalMachine" 
           storeName="My" 
           x509FindType="FindByThumbprint"/> 
        </identity> 
       </issuer> 
      </issuedTokenParameters> 

      <!-- This basically says "Don't use Secure Conversation" --> 
      <secureConversationBootstrap/> 
     </security> 

     <!-- Use Text Encoding --> 
     <textMessageEncoding/> 

     <!-- This says to use HTTPS when communicating with the remote service --> 
     <httpsTransport 
      requireClientCertificate="true" 
      maxBufferPoolSize="134217728" 
      maxReceivedMessageSize="134217728" 
      maxBufferSize="134217728"/> 
    </binding> 
</customBinding> 

Chữ ký trong yêu cầu đi trông như thế này:

<Signature 
    xmlns="http://www.w3.org/2000/09/xmldsig#"> 
    <SignedInfo> 
     <CanonicalizationMethod 
      Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
     <SignatureMethod 
      Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/> 
     <Reference 
      URI="#_0"> 
      <Transforms> 
       <Transform 
        Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
      </Transforms> 
      <DigestMethod 
       Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> 
      <DigestValue>GZfW1RkyS4DHYFPHRnRuqNSo+qE=</DigestValue> 
     </Reference> 
    </SignedInfo> 
    <SignatureValue>rMzQ/kEV7AXcO3wm9hfQXNoX5r4=</SignatureValue> 
    <KeyInfo> 
     <o:SecurityTokenReference 
      b:TokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0" 
      xmlns:b="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd"> 
      <o:KeyIdentifier 
       ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID">_9f79359e-63dc-4e38-888c-6567dac4b41b</o:KeyIdentifier> 
     </o:SecurityTokenReference> 
    </KeyInfo> 
</Signature> 

Lưu ý rằng <SignatureMethod>http://www.w3.org/2000/09/xmldsig#hmac-sha1

Một điều thú vị là thuật toán HMAC-SHA1 là đối xứng (một khóa để mã hóa và giải mã) trong khi RSA-SHA 1 là không đối xứng (yêu cầu một khóa để mã hóa và một để giải mã). Tôi nghĩ WCF sử dụng thuật toán HMAC-SHA1 vì nó là đối xứng và mã thông báo SAML được trao đổi là bí mật được chia sẻ (khóa). Có ý nghĩa khi sử dụng mã thông báo SAML làm khóa chia sẻ cho một thuật toán đối xứng nhưng có một tùy chọn có sẵn để buộc WCF sử dụng một thuật toán không đối xứng như RSA-SHA1 không?

tôi đã có thể nhận được một số thay đổi nhẹ của phương pháp chữ ký bằng cách thay đổi các ràng buộc/security/defaultAlgorithmSuite thuộc tính nhưng các tùy chọn khác nhau không cho tôi khả năng để xác định RSA-SHA1 đây:

defaultAlgorithm = Mặc định :

<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>

defaultAlgorithm = Basic256:

<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>

defaultAlgorithm = Basic256Rsa15:

<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>

defaultAlgorithm = Basic256Sha256:

<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#hmac-sha256"/> <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>

defaultAlgorithm = Basic256Sha256Rsa15:

<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#hmac-sha256"/> <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>

Có cách nào tôi có thể buộc WCF sử dụng RSA-SHA1 trên chữ ký Dấu thời gian?

Trả lời

Các vấn đề liên quan