src/CfdiUtils/Certificado/Certificado.php
public function verify(string $data, string $signature, int $algorithm = OPENSSL_ALGO_SHA256): bool
    {
        $pubKey = openssl_get_publickey($this->getPubkey());
        if (false === $pubKey) {
            throw new \RuntimeException('Cannot open public key from certificate');
        }
        try {
            $verify = openssl_verify($data, $signature, $pubKey, $algorithm);
            if (-1 === $verify) {
                throw new \RuntimeException('OpenSSL Error: ' . openssl_error_string());
            }
        } finally {
            openssl_free_key($pubKey);
        }
        return (1 === $verify);
    }
public function verify(string $data, string $signature, int $algorithm = OPENSSL_ALGO_SHA256): bool
    {
        $pubKey = openssl_get_publickey($this->getPubkey());
        if (false === $pubKey) {
            throw new \RuntimeException('Cannot open public key from certificate');
        }
        try {
            $verify = openssl_verify($data, $signature, $pubKey, $algorithm);
            if (-1 === $verify) {
                throw new \RuntimeException('OpenSSL Error: ' . openssl_error_string());
            }
        } finally {
            openssl_free_key($pubKey);
        }
        return (1 === $verify);
    }
public function verify ( string $ data , string $ signature , int $ algorithm = OPENSSL_ALGO_SHA256 ) : bool { $ pubKey = openssl_get_publickey ( $ this -> getPubkey ( ) ) ; if ( false === $ pubKey ) { throw new \ RuntimeException ( 'Cannot open public key from certificate' ) ; } try { $ verify = openssl_verify ( $ data , $ signature , $ pubKey , $ algorithm ) ; if ( - 1 === $ verify ) { throw new \ RuntimeException ( 'OpenSSL Error: ' . openssl_error_string ( ) ) ; } } finally { openssl_free_key ( $ pubKey ) ; } return ( 1 === $ verify ) ; }
Verify the signature of some data

@param string $data
@param string $signature
@param int $algorithm

@return bool

@throws \RuntimeException if cannot open the public key from certificate
@throws \RuntimeException if openssl report an error
Verify the signature of some data