Sign xml with xmlseclibs php -


i have sign xml send in soap request. use xmlseclibs. lib sign correctly xml, not way need it.

my code sign xml:

use robrichards\xmlseclibs\xmlsecuritydsig; 

use robrichards\xmlseclibs\xmlsecuritykey;

the xmls: https://pastebin.com/qya8fmbi

function signxml($xml) {

$doc = new domdocument('1.0','utf-8'); $doc->loadxml($xml); $objdsig = new xmlsecuritydsig(''); $objdsig->setcanonicalmethod(xmlsecuritydsig::c14n);  $objdsig->addreference(     $doc,      xmlsecuritydsig::sha1,         ['http://www.w3.org/2000/09/xmldsig#enveloped-signature',     'http://www.w3.org/tr/2001/rec-xml-c14n-20010315'],     ["force_uri"=>true] ); $objkey = new xmlsecuritykey(xmlsecuritykey::rsa_sha1, array('type'=>'private')); $privkey = 'cert_pem/privkey.pem'; $objkey->loadkey($privkey, true); $objdsig->sign($objkey); $pubkey = 'cert_pem/mycert.pem'; $objdsig->add509cert(file_get_contents($pubkey)); $objdsig->appendsignature($doc->documentelement); 

;

return $doc->savexml(); 

}

please, save me!


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -