public function toSignedXML() : DOMElement
    {
        $root = $this->toUnsignedXML();

        if ($this->signatureKey === null) {
            /* We don't have a key to sign it with. */

            return $root;
        }

        /* Find the position we should insert the signature node at. */
        if ($this->issuer !== null) {
            /*
             * We have an issuer node. The signature node should come
             * after the issuer node.
             */
            $issuerNode = $root->firstChild;
            $insertBefore = $issuerNode->nextSibling;
        } else {
            /* No issuer node - the signature element should be the first element. */
            $insertBefore = $root->firstChild;
        }

        Utils::insertSignature($this->signatureKey, $this->certificates, $root, $insertBefore);

        return $root;
    }
public function toSignedXML() : DOMElement
    {
        $root = $this->toUnsignedXML();

        if ($this->signatureKey === null) {
            /* We don't have a key to sign it with. */

            return $root;
        }

        /* Find the position we should insert the signature node at. */
        if ($this->issuer !== null) {
            /*
             * We have an issuer node. The signature node should come
             * after the issuer node.
             */
            $issuerNode = $root->firstChild;
            $insertBefore = $issuerNode->nextSibling;
        } else {
            /* No issuer node - the signature element should be the first element. */
            $insertBefore = $root->firstChild;
        }

        Utils::insertSignature($this->signatureKey, $this->certificates, $root, $insertBefore);

        return $root;
    }
public function toSignedXML ( ) : DOMElement { $ root = $ this -> toUnsignedXML ( ) ; if ( $ this -> signatureKey === null ) { /* We don't have a key to sign it with. */ return $ root ; } /* Find the position we should insert the signature node at. */ if ( $ this -> issuer !== null ) { /*
             * We have an issuer node. The signature node should come
             * after the issuer node.
             */ $ issuerNode = $ root -> firstChild ; $ insertBefore = $ issuerNode -> nextSibling ; } else { /* No issuer node - the signature element should be the first element. */ $ insertBefore = $ root -> firstChild ; } Utils :: insertSignature ( $ this -> signatureKey , $ this -> certificates , $ root , $ insertBefore ) ; return $ root ; }
Convert this message to a signed XML document.
This method sign the resulting XML document if the private key for
the signature is set.

@return \DOMElement The root element of the DOM tree
Convert this message to a signed XML document . This method sign the resulting XML document if the private key for the signature is set .