我有一个证书(.cer文件)及其公钥。我需要使用这个密钥和肥皂消息体创建一个签名,还需要在soap消息的标题部分添加这个生成的签名。像
<?php
if($errorMsg == ''){
//Make the message.
$message ="
First Name: ".$fname.".\n
Last Name: ".$lname."\n
Website: ".$website."\n
Did They Like the Site? ".$likedsite."\n
How They Found Us. ".$findoption."\n
Question/Comments:\n
".$comments." ";
$message = wordwrap($message, 70);
$headers = "From: $email";
mail("me@gmail.com", $subject, $message, $headers);
}else{
// Show $errorMsg
}
?>
基本上我需要在标题部分中添加<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-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" SOAP-ENV:mustUnderstand="1">
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SIG-3">
<ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="SOAP-ENV"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1"/>
<ds:Reference URI="#id-2"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList=""/>
</ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>EjzOmzoHrDq0U17/15G4ROWuLBM=</ds:DigestValue></ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>jisobLxDo3AKD+CFgamH/7vuLkVNqZN18Xh65ZlajNODlvh2wPJEyg==</ds:SignatureValue>
<ds:KeyInfo Id="KI-0E3A8F2C1EE953718314449294173862">
<wsse:SecurityTokenReference wsu:Id="STR-0E3A8F2C1EE953718314449294173883">
<ds:X509Data<ds:X509IssuerSerial><ds:X509IssuerName>CN=Sujit Arungundram,OU=NB,O=SFG,L=Chicago,ST=IL,C=US
</ds:X509IssuerName><ds:X509SerialNumber>1790402324</ds:X509SerialNumber></ds:X509IssuerSerial></ds:X509Data>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
<wsu:Timestamp wsu:Id="TS-1"><wsu:Created>2015-10-15T17:16:57.309Z</wsu:Created>
<wsu:Expires>2015-10-15T17:21:57.309Z</wsu:Expires></wsu:Timestamp>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-2"><ns2:TransactionRequest xmlns="http://schema.ACORD.csc.com/Standard/Life/2" xmlns:ns2="http://com/sfg/spcltymkts/webservices/csctxlife">
Body content
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
。