I need to send a message from a WCF client to a Java web service that requires the body to be signed. There seems to be a lot of information on this topic, but I can’t decide what I really need to do to achieve this.
I was told the following:
- The client certificate provides authentication and is included as a binary security token.
- The client certificate and private key are used to sign the body of the SOAP message.
- The service decodes the SOAP security header and receives the client code.
- The response of the service is not signed or encrypted.
I am also provided with an example request and response, which is given below.
Having generated my client and trying to configure the bindings, I get a request sent to me back (I assume that this is instead of an error, I do not know why this is happening or I think that this is relevant). I tried creating a custom binding only for subscription ( as suggested here ):
Dim asec As AsymmetricSecurityBindingElement = CType(SecurityBindingElement.CreateMutualCertificateBindingElement(ServiceModel.MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10, True), AsymmetricSecurityBindingElement)
asec.SetKeyDerivation(False)
asec.AllowInsecureTransport = True
asec.IncludeTimestamp = True
but this also encrypts the message and gives an error: Endpoint {http://ServiceAddress}ServiceName does not contain operation meta data for: {http://www.w3.org/2001/04/xmlenc#}EncryptedData
The study suggests that I need to modify the client.vb file for the client proxy, but when I tried to decorate the request property with the level = sign level, it only minimally respects this, so I suspect that this is the wrong approach.
How to get a binding for the correct connection with the service?
: CreateCertificateOverTransportBindingElement, , , , , , xml . , 500 , , .
:
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://[removed]/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" env:mustUnderstand="1">
<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="token-2-1384851101218-1328853118">MIICBjCCAW8CAwLm/jANBgkqhkiG9w0BAQUFADBAMRQwEgYDVQQDDAtGb3JkRXRpcyBDQTEbMBkG
A1UECgwSRm9yZCBNb3RvciBDb21wYW55MQswCQYDVQQGEwJHQjAgFw0xMzA0MTYxMjQ0MThaGA8y
MTEzMDQxNjEyNDQxOFowUzERMA8GA1UEAwwIREVVVEVTVDYxFDASBgNVBAsMC0ZTQSBTZXJ2aWNl
MRswGQYDVQQKDBJGb3JkIE1vdG9yIENvbXBhbnkxCzAJBgNVBAYTAkdCMIGfMA0GCSqGSIb3DQEB
AQUAA4GNADCBiQKBgQC2r/plg8pUmc35Vajc1ji4koYIFgvb5LFUs4GFl/4R0eRspjNwJ7TW1B3s
XyGd272l5oGyNazsGeAZQ88XDRbL5Q60HwrDaKuA/UvT7pKaQufwvIJUWmUwry0K72x7x4jQNWC1
fR3XXzztlrjpf9MmOkbQE1GMdKonldiCu59YcwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAIdSHIsq
KrUAlwbD7AMSQ1PfyIRP9pX94416ELpcr6h/+2RnYF40HcZO9/oU1VJIgCJREI+pRpR2DISDFAhA
LhqzxLTy4G45zcuKjaoKSi6UcaOfsqxuagEanga2CXsapHHB/DB84jLES6fGf79z09xYZ+82iEm5
Kgm6eho2Bqgn</wsse:BinarySecurityToken>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#element-1-1384851100999-344078580">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>sArRh/ub3qQBGzBS+W3zeoHNcTk=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
T6bNaNlFP0CfMGEOWQUprdufyHN7BhjETw8o1JH/sb8we23c+f5qvTmYIHYNH89ervkkCRSYlaQu
SyES0toWkH9Od6CqTiwmN2uubID71z9RgA3Vw9SlEAwI7iJi9iHRRqyiDXZkastVHmd7lXQRqYjQ
7/03PSvZjv8K42n8XEE=
</ds:SignatureValue>
<ds:KeyInfo>
<wsse:SecurityTokenReference wsu:Id="reference-3-1384851101219-204425426"><wsse:Reference URI="#token-2-1384851101218-1328853118" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/></wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
</env:Header>
<env:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="element-1-1384851100999-344078580">
<ns0:list>
<String_1>[removed]</String_1>
</ns0:list>
</env:Body>
</env:Envelope>
:
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<ns0:listResponse xmlns:ns0="[removed]/1.0">
<result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<value>
<code>[removed]</code>
<description>[removed]</description>
</value>
</result>
</ns0:listResponse>
</env:Body>
</env:Envelope>