XML 署名 (WSDL) の DigestValue と SignatureValue を生成する方法の例をいくつか見つけようとしています。
以下は、アプリケーションのサンプル SOAP です。
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:SOAP-SEC="http://schemas.xmlsoap.org/soap/security/2000-12" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<SOAP-SEC:Signature soapenv:actor="" soapenv:mustUnderstand="0">
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#Body">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue></ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue></ds:SignatureValue>
</ds:Signature>
</SOAP-SEC:Signature>
</soapenv:Header>
<soapenv:Body Id="Body">
<SomeApplicationMethod soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<Application href="#id0"/></SomeApplicationMethod>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:NCDServices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:SomeApplicationMethod">
<param2 xsi:type="soapenc:string">123456</param2>
<param3 xsi:type="soapenc:string">someString</param3>
<param4 xsi:type="soapenc:string">string123 bla bla</param4>
<param5 xsi:type="soapenc:string">0</param5>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
アプリケーション プロバイダーからの 1 つの例があり、サンプルと同じ DigestValue と SignatureValue を生成できないようです。アプリケーションのドキュメントによると、 Body セクション全体から digestValue を作成する必要があります。
正規化、sha1、次に base64 エンコードする必要があることはわかっています。しかし、ボディセクションを正規化するにはどうすればよいですか? (sha1 および base64 エンコードは理解するのに十分簡単です)。
最初に、文字列変数を作成してみたいと思います:
$whole_body = '<soapenv:Body Id="Body"> ........stuff inside...... </soapenv:Body>';
しかし、PHPにはc14n関数のようなものがないことがわかりました(少なくともvarのような文字列、およびPHP 5.2以下ではありません。心配する必要はありません。私は5.2.6を持っています)。
xmlseclibs.php コードを調べたところ、DOMelement オブジェクトを使用して C14N 関数を取得しているようです。私はDOMelementが何であるかについてあまりよく知りません..
xmlseclibs.php を使用して XML に署名しようとしましたが、うまくいかないようで、アプリケーションから「署名が無効です」というエラーが表示されました。
誰かが初心者を啓発するのを手伝ってもらえますか (読んでください、私 :) ) ?
ご協力感謝いたします。