protected function validateXml(DOMDocument $dom, $certificate)
    {
        $secDsig = new XMLSecurityDSig;

        // Locate the signature in the receipt XML.
        $dsig = $secDsig->locateSignature($dom);
        if ($dsig === null) {
            throw new RunTimeException('Cannot locate receipt signature');
        }

        $secDsig->canonicalizeSignedInfo();
        $secDsig->idKeys = ['wsu:Id'];
        $secDsig->idNS = [
            'wsu' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd',
        ];

        if (!$secDsig->validateReference()) {
            throw new RunTimeException('Reference validation failed');
        }

        $key = $secDsig->locateKey();
        if ($key === null) {
            throw new RunTimeException('Could not locate key in receipt');
        }

        $keyInfo = XMLSecEnc::staticLocateKeyInfo($key, $dsig);
        if (!$keyInfo->key) {
            $key->loadKey($certificate);
        }

        return $secDsig->verify($key) == 1;
    }
protected function validateXml(DOMDocument $dom, $certificate)
    {
        $secDsig = new XMLSecurityDSig;

        // Locate the signature in the receipt XML.
        $dsig = $secDsig->locateSignature($dom);
        if ($dsig === null) {
            throw new RunTimeException('Cannot locate receipt signature');
        }

        $secDsig->canonicalizeSignedInfo();
        $secDsig->idKeys = ['wsu:Id'];
        $secDsig->idNS = [
            'wsu' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd',
        ];

        if (!$secDsig->validateReference()) {
            throw new RunTimeException('Reference validation failed');
        }

        $key = $secDsig->locateKey();
        if ($key === null) {
            throw new RunTimeException('Could not locate key in receipt');
        }

        $keyInfo = XMLSecEnc::staticLocateKeyInfo($key, $dsig);
        if (!$keyInfo->key) {
            $key->loadKey($certificate);
        }

        return $secDsig->verify($key) == 1;
    }
protected function validateXml ( DOMDocument $ dom , $ certificate ) { $ secDsig = new XMLSecurityDSig ; // Locate the signature in the receipt XML. $ dsig = $ secDsig -> locateSignature ( $ dom ) ; if ( $ dsig === null ) { throw new RunTimeException ( 'Cannot locate receipt signature' ) ; } $ secDsig -> canonicalizeSignedInfo ( ) ; $ secDsig -> idKeys = [ 'wsu:Id' ] ; $ secDsig -> idNS = [ 'wsu' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' , ] ; if ( ! $ secDsig -> validateReference ( ) ) { throw new RunTimeException ( 'Reference validation failed' ) ; } $ key = $ secDsig -> locateKey ( ) ; if ( $ key === null ) { throw new RunTimeException ( 'Could not locate key in receipt' ) ; } $ keyInfo = XMLSecEnc :: staticLocateKeyInfo ( $ key , $ dsig ) ; if ( ! $ keyInfo -> key ) { $ key -> loadKey ( $ certificate ) ; } return $ secDsig -> verify ( $ key ) == 1 ; }
Validate the receipt contained in the given XML element using the
certificate provided.

@param DOMDocument $dom
@param resource $certificate

@return bool
@throws RunTimeException
Validate the receipt contained in the given XML element using the certificate provided .