2012-02-20 44 views
9

Tengo un cliente WCF que está enviando un mensaje a un servicio que no pertenece a WCF y que tiene problemas para manejar el método de firma HMAC-SHA1 utilizado para firmar el WS - Elemento de sello de tiempo de seguridad. Idealmente, nos gustaría usar el método de firma RSA-SHA1 pero no he podido lograr que WCF use ese método de firma.WCF Client - Especificación del algoritmo de firma para la firma WS-Security Timestamp

La unión estoy usando es una unión a medida que me da tiempo para enviar un token de SAML 2.0 a través de 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> 

La firma en la solicitud de salida es el siguiente:

<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> 

Observe que <SignatureMethod> es http://www.w3.org/2000/09/xmldsig#hmac-sha1

Una cosa interesante es que el algoritmo HMAC-SHA1 es simétrico (una clave para cifrar y descifrar) mientras que RSA-SHA 1 es asimétrico (requiere una clave para encriptar y otra para descifrar). Creo que WCF usa el algoritmo HMAC-SHA1 porque es simétrico y el token SAML que se intercambia es el secreto compartido (clave). Tiene sentido usar el token SAML como la clave compartida para un algoritmo simétrico, pero ¿hay alguna opción disponible para forzar a WCF a usar un algoritmo asimétrico como RSA-SHA1?

he podido conseguir alguna ligera modificación del método de firma por el cambio de la unión/security/defaultAlgorithmSuite atributo pero las diversas opciones no me dan la posibilidad de especificar RSA-SHA1 aquí:

defaultAlgorithm = por defecto :

<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"/>

¿Hay alguna manera de forzar WCF para utilizar RSA-SHA1 sobre la firma de marca de hora?

Respuesta

Cuestiones relacionadas