src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Impl/OpenSslVerifySignature.php
public function verifySignatureIsCorrect($data, $signature, $certificatePath)
    {
        $cert = $this->_getCertificateFromCertifcatePath($certificatePath);

        $certKey = openssl_get_publickey($cert);

        if ($certKey === False) {
            throw new OffAmazonPaymentsNotifications_InvalidMessageException(
                "Unable to extract public key from cert " . $cert);
        }

        $result = -1;
        try {
            $result = openssl_verify($data, $signature, $certKey, OPENSSL_ALGO_SHA1);
        } catch (Exception $ex) {
            throw new OffAmazonPaymentsNotifications_InvalidMessageException(
                "Unable to verify signature - error with the verification algorithm",
                null, $ex
            );
        }

        return ($result > 0);
    }
public function verifySignatureIsCorrect($data, $signature, $certificatePath)
    {
        $cert = $this->_getCertificateFromCertifcatePath($certificatePath);

        $certKey = openssl_get_publickey($cert);

        if ($certKey === False) {
            throw new OffAmazonPaymentsNotifications_InvalidMessageException(
                "Unable to extract public key from cert " . $cert);
        }

        $result = -1;
        try {
            $result = openssl_verify($data, $signature, $certKey, OPENSSL_ALGO_SHA1);
        } catch (Exception $ex) {
            throw new OffAmazonPaymentsNotifications_InvalidMessageException(
                "Unable to verify signature - error with the verification algorithm",
                null, $ex
            );
        }

        return ($result > 0);
    }
public function verifySignatureIsCorrect ( $ data , $ signature , $ certificatePath ) { $ cert = $ this -> _getCertificateFromCertifcatePath ( $ certificatePath ) ; $ certKey = openssl_get_publickey ( $ cert ) ; if ( $ certKey === False ) { throw new OffAmazonPaymentsNotifications_InvalidMessageException ( "Unable to extract public key from cert " . $ cert ) ; } $ result = - 1 ; try { $ result = openssl_verify ( $ data , $ signature , $ certKey , OPENSSL_ALGO_SHA1 ) ; } catch ( Exception $ ex ) { throw new OffAmazonPaymentsNotifications_InvalidMessageException ( "Unable to verify signature - error with the verification algorithm" , null , $ ex ) ; } return ( $ result > 0 ) ; }
Verify that the signature is correct for the given data and
public key

@param string $data            data to validate
@param string $signature       decoded signature to compare against
@param string $certificatePath path to certificate, can be file or url

@throws OffAmazonPaymentsNotifications_InvalidMessageException if there
is an error
with the call

@return bool true if valid
Verify that the signature is correct for the given data and public key