第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何將簽名添加到 XMLdocument 中的特定位置?

如何將簽名添加到 XMLdocument 中的特定位置?

PHP
楊魅力 2023-04-28 14:50:46
我有 XML 文檔:    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">    <soapenv:Header/>    <soapenv:Body>        <saml2p:ArtifactResolve xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" Version="2.0"                                IssueInstant="2020-06-01T10:25:15+02:00">            <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">TEST</saml2:Issuer>            <saml2p:Artifact>AAQAAKFbFR94fxqmioAqjJUwfHTFVHTDBTVHdBwwTW+ehcM19zsk=</saml2p:Artifact>        </saml2p:ArtifactResolve>    </soapenv:Body></soapenv:Envelope>我嘗試以這種方式執(zhí)行此操作:$results = array();$filename = 'cert.p12';$password = 'certpass';$priv_key = openssl_pkcs12_read(file_get_contents($filename), $results, $password);$doc = new DOMDocument();$doc->loadXML($xml);$xp = new DOMXPath($doc);$xp->registerNamespace('soapenv', 'http://schemas.xmlsoap.org/soap/envelope/');$xp->registerNamespace('saml2p','urn:oasis:names:tc:SAML:2.0:protocol');$xp->registerNamespace('saml2','urn:oasis:names:tc:SAML:2.0:assertion');$xp->registerNamespace('ds',XMLSecurityDSig::XMLDSIGNS);$artifactResolveNode = $xp->query('/*[local-name()=\'Envelope\']/*[local-name()=\'Body\']/*[local-name()=\'ArtifactResolve\']')->item(0);if($artifactResolveNode){    $objDSig = new XMLSecurityDSig();    $objDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);    $objDSig->addReference(        $artifactResolveNode,        XMLSecurityDSig::SHA256,        array('http://www.w3.org/2000/09/xmldsig#enveloped-signature', 'http://www.w3.org/2001/10/xml-exc-c14n#'),        array('force_uri' => true)    );    $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array('type' => 'private'));    $objKey->loadKey($results['pkey'], FALSE);    $objDSig->sign($objKey);    $objDSig->add509Cert($results['cert']);    $objDSig->appendSignature($doc->documentElement());    echo $doc->saveXML();}我想將 Signature 節(jié)點(diǎn)放在 ISSUER 和 ARTIFACT 之間。此位置對(duì)于正確發(fā)送 SOAP 信封非常重要。有可能的?
查看完整描述

1 回答

?
呼啦一陣風(fēng)

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超6個(gè)贊

我發(fā)現(xiàn)!我需要在下面添加代碼:

$artifactNode = $xp->query('/*[local-name()=\'Envelope\']/*[local-name()=\'Body\']/*[local-name()=\'ArtifactResolve\']/*[local-name()=\'Artifact\']')->item(0);

并像這樣附加簽名:

    $objDSig->insertSignature($artifactResolveNode,$artifactNode);


查看完整回答
反對(duì) 回復(fù) 2023-04-28
  • 1 回答
  • 0 關(guān)注
  • 113 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)