PHP SoapClient添加安全性

时间:2015-09-13 15:29:13

标签: php ssl cryptography digital-signature soap-client

我必须在PHP中为SoapClient标头添加签名,如下所示:

  <wsse:Security soapenv:mustUnderstand="1" 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">
     <ds:Signature Id="SIG-D27449CA8692975E751442157786088110" 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 xsd xsi" 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-D27449CA8692975E751442157786088109">
              <ds:Transforms>
                 <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                    <ec:InclusiveNamespaces PrefixList="xsd xsi" 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>6Lek0T/UtPqb4iTdm29Cnimq27U=</ds:DigestValue>
           </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>c4/VXVEju6o79ip9XAKKUOTCS0qM6eiup5PrAtqOtQk85GFHFQSEiFwtHq9wuzVqqiokWkemZjJU1j/88AGodNiv1GNxNuLaW14i4x6GTOdiXxZg7Z449wiXngyQaaZ+5hhln3TStmrlZ5rQE2Mwsi/XrJ6ef2JWDiKUA2VbFss=</ds:SignatureValue>
        <ds:KeyInfo Id="KI-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX">
           <wsse:SecurityTokenReference wsu:Id="STR-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX">
              <ds:X509Data>
                 <ds:X509IssuerSerial>
                    <ds:X509IssuerName>O=MEMEME,C=US</ds:X509IssuerName>
                    <ds:X509SerialNumber>87458885955</ds:X509SerialNumber>
                 </ds:X509IssuerSerial>
              </ds:X509Data>
           </wsse:SecurityTokenReference>
        </ds:KeyInfo>
     </ds:Signature>
  </wsse:Security>

我怎样才能做到这一点?

我的私钥位于pfx文件中。

0 个答案:

没有答案