public function generateSignature(DOMNode $xml)
    {
        $message = $this->c14n($xml);

        $key = openssl_get_privatekey('file://'.$this->getPrivateKeyPath(), $this->getPrivateKeyPassphrase());
        if ($key && openssl_sign($message, $signature, $key, OPENSSL_ALGO_SHA256)) {
            openssl_free_key($key);

            return base64_encode($signature);
        }

        $error = 'Invalid private key.';
        while ($msg = openssl_error_string()) {
            $error .= ' '.$msg;
        }

        throw new InvalidRequestException($error);
    }