2016-05-11 5 views
1

Javaサービスを使用する必要があり、セキュリティ要件によって、メッセージに署名とタイムスタンプが必要であるが、暗号化は不要であることが示されています。WCFクライアントの暗号化を無効にする

は私がカスタムバインディングを採用しようとしていると、正常例に従って、タイムスタンプに署名するが、メッセージ本体は常に暗号化されている追加しました:

<system.serviceModel> 
    <bindings> 
     <customBinding> 
      <binding name="SignTimestampOnly"> 
       <security messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11" 
        authenticationMode="MutualCertificate" requireDerivedKeys="false" includeTimestamp="true" keyEntropyMode="ClientEntropy" securityHeaderLayout="LaxTimestampFirst" 
        requireSignatureConfirmation="false" messageProtectionOrder="SignBeforeEncrypt" enableUnsecuredResponse="true" requireSecurityContextCancellation="false" 
        allowInsecureTransport="true" /> 
       <textMessageEncoding messageVersion="Soap12" writeEncoding="utf-8"/> 
       <httpTransport /> 
      </binding> 

     </customBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/myurl" binding="customBinding" bindingConfiguration="SignTimestampOnly" contract="IService" name="Service"> 
      <identity> 
       <dns value="Service" /> 
      </identity> 
     </endpoint> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
      <behavior> 
       <clientCredentials> 
        <clientCertificate findValue="..." storeLocation="CurrentUser" 
             storeName="My" x509FindType="FindByThumbprint" /> 
        <serviceCertificate> 
         <authentication certificateValidationMode="PeerTrust" /> 
         <defaultCertificate findValue="..." storeLocation="CurrentUser" 
             storeName="My" x509FindType="FindByThumbprint" /> 
        </serviceCertificate> 
       </clientCredentials> 
      </behavior> 
     </endpointBehaviors> 
    </behaviors> 
</system.serviceModel> 

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
    <s:Header> 
     <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo2ZxfrkBGk9AsTA8KWukb2AAAAAADLwbydLv0kmqZo1361cxb7JSYAqPOP5HmzAGAtf6H7MACQAA</VsDebuggerCausalityData> 
     <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="uuid-f761d810-63b1-485b-a89f-1d3da446f273-1"> 
       <u:Created>2016-05-11T14:34:10.237Z</u:Created> 
       <u:Expires>2016-05-11T14:39:10.237Z</u:Expires> 
      </u:Timestamp> 
      <o:BinarySecurityToken u:Id="uuid-76114032-1c65-4a4d-9f54-9d5d68e0dc2b-2">...</o:BinarySecurityToken> 
      <e:EncryptedKey Id="_0" xmlns:e="http://www.w3.org/2001/04/xmlenc#"> 
       <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"> 
        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" xmlns="http://www.w3.org/2000/09/xmldsig#"/> 
       </e:EncryptionMethod> 
       <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"> 
        <o:SecurityTokenReference> 
         <o:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">WLVP0ah+F2LGQm9mvqQfPJ/sA4w=</o:KeyIdentifier> 
        </o:SecurityTokenReference> 
       </KeyInfo> 
       <e:CipherData>...</e:CipherData> 
       <e:ReferenceList> 
        <e:DataReference URI="#_2"/> 
       </e:ReferenceList> 
      </e:EncryptedKey> 
      <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#rsa-sha1"/> 
        <Reference URI="#_1"> 
         <Transforms> 
          <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
         </Transforms> 
         <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> 
         <DigestValue>2PRP+JjT6OhZcHo9QUMtvwNltY4=</DigestValue> 
        </Reference> 
        <Reference URI="#uuid-f761d810-63b1-485b-a89f-1d3da446f273-1"> 
         <Transforms> 
          <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
         </Transforms> 
         <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> 
         <DigestValue>zkmVC2HFZxdBV03114Ije8gAQE0=</DigestValue> 
        </Reference> 
       </SignedInfo> 
       <SignatureValue>...</SignatureValue> 
       <KeyInfo> 
        <o:SecurityTokenReference> 
         <o:Reference ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" URI="#uuid-76114032-1c65-4a4d-9f54-9d5d68e0dc2b-2"/> 
        </o:SecurityTokenReference> 
       </KeyInfo> 
      </Signature> 
     </o:Security> 
    </s:Header> 
    <s:Body u:Id="_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     <e:EncryptedData Id="_2" Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:e="http://www.w3.org/2001/04/xmlenc#"> 
      <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/> 
      <e:CipherData> 
       <e:CipherValue>...</e:CipherValue> 
      </e:CipherData> 
     </e:EncryptedData> 
    </s:Body> 
</s:Envelope> 

は、これは私の設定です

暗号化をオフにすることはできますが、署名とタイムスタンプは保持できますか?

答えて

2

このページでは、暗号化を無効にする方法について説明します。

https://social.msdn.microsoft.com/Forums/vstudio/en-US/72c5a1b1-55d6-49b0-8a4b-7db763d90ad3/disable-encryption-of-body-signed-with-x509-certificate?forum=wcf

あなたのServiceContractインターフェイス属性でこの動作を設定することができます。

// Set the ProtectionLevel on the whole service to Sign. 
[ServiceContract(ProtectionLevel = ProtectionLevel.Sign)] 
public interface Calculator 

https://msdn.microsoft.com/en-us/library/aa347791.aspx

+0

私はそれを消費しています、サービスを制御することはできません。 –

+2

私があなたに与えた最初のリンクを見てください。私はそのトピックの最後のコメントがあなたが必要とするものだと思います。クライアントプロキシのエンドポイントコントラクトの保護動作を変更できます。 – fduman

+0

'proxy.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign;を設定すると、私のために働いています。ありがとう。 – StefanOS

関連する問題