非 WCF サービスにメッセージを送信している WCF クライアントがあり、そのサービスでは、WS-Security Timestamp 要素の署名に使用される HMAC-SHA1 署名方法の処理に問題があります。理想的には、RSA-SHA1 署名方式を使用したいのですが、WCF でその署名方式を使用することができませんでした。
私が使用しているバインディングは、HTTPS 経由で SAML 2.0 トークンを送信できるカスタム バインディングです。
<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>
発信リクエストの署名は次のようになります。
<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>
http://www.w3.org/2000/09/xmldsig#hmac-sha1であることに注意し<SignatureMethod>
てください
興味深い点の 1 つは、HMAC-SHA1 アルゴリズムが対称 (暗号化と復号に 1 つのキー) であるのに対し、RSA-SHA1 は非対称 (暗号化と復号に 1 つのキーが必要) であることです。WCF は対称であり、交換される SAML トークンが共有シークレット (キー) であるため、HMAC-SHA1 アルゴリズムを使用していると思います。SAML トークンを対称アルゴリズムの共有キーとして使用することは理にかなっていますが、WCF に RSA-SHA1 のような非対称アルゴリズムを強制的に使用させるオプションはありますか?
binding/security/defaultAlgorithmSuite 属性を変更することで、署名方法を少し変更することができましたが、さまざまなオプションを使用しても、ここで RSA-SHA1 を指定することはできません。
defaultAlgorithm = デフォルト:
<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"/>
タイムスタンプ署名で RSA-SHA1 を使用するように WCF を強制する方法はありますか?