We currently have OpenSSL 1.0.2o on the HPNS. We have a customer requirement to send a SOAP request with the same WS-Security header which is being generated by a windows test app 'SoapUI' (SmartBear). Internally the customer is using another black box they refer to as DataPower (IBM Websphere). Their DataPower is also generating WS-Security headers in SOAP requests acceptable by their server. No one, including the customer, has any idea how this security header is generated. They are telling us to just send what SoapUI sends. I am stuck trying to generate the same signature on the HPNS openssl that I see in my windows SoapUI tool.
So far as I understand it these are the steps I need to perform:
1) Canonicalize (Exclusive XML Canonicalization) the portion of the request that will be digested, in our case everything in and including the <soapenv:Body>...</soapenv:Body>.
2) Generate a digest value from the canonicalized version from step 1. Include this in the <DigestValue> within the <SignedInfo>...<Reference> element.
3) Canonicalize the <SignedInfo>...</SignedInfo> portion of the <Signature> element.
4) Digest the Canonicalized version of the <SignedInfo>
5) Sign the digest value of the <SignedInfo> and that is our <SignatureValue>
I'm trying to duplicate this on the HPNS OpenSSL, first using the command line tool and then eventually we'll use the API if we can figure out how to do this.
What I have figure out so far (not much):
From steps 1&2, I have managed to canonicalize, using a Java program, the <Body> from the request. I was not able to do it without first removing comments and leading white spaces from the request within SoapUI. Repeating...the ONLY way I could get a digest value match in openssl is to have SoapUI generate it's security header with no leading whitespace or comments in the request. The Java program then provided some direction one how namespace and other properties are re-arranged.
First question: how do I canonicalize the request directly in OpenSSL? I cannot find this anywhere other than references to a libxml2 library on a *nix system
After I got a matching digest I have been fruitless trying to get a signature match using variations of openssl commands: dgst, rsautl and pkeyutl. I have tried using the same canonicalizatoin of the <SignedInfo> block and digesting that then signing...no match.
Not sure if this will help but this is the WS-Security header generated by SoapUI that we are trying to duplicate (with lengthy signature removed and customer info removed):
<wsse:Security xmlns:wsse="redacted" xmlns:wsu="redacted">
<ds:Signature Id="SIG-7175F72748C072A4761529013840614108" xmlns:ds="
http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="
http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces PrefixList="soapenv v1 v11 v2" xmlns:ec="
http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="
http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#id-CE0A4571D7DB69D8CE152339585717529">
<ds:Transforms>
<ds:Transform Algorithm="
http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces PrefixList="v1 v11 v2" xmlns:ec="
http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="
http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>redacted</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>removed for brevity</ds:SignatureValue>
<ds:KeyInfo Id="redacted">
<wsse:SecurityTokenReference wsu:Id="redacted">
<ds:X509Data>
<ds:X509IssuerSerial>
<ds:X509IssuerName>CN=Symantec Class...</ds:X509IssuerName>
<ds:X509SerialNumber>redacted</ds:X509SerialNumber>
</ds:X509IssuerSerial>
</ds:X509Data>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>