def verifyCertSig(id_cert, cert_to_verify, algo='sha1'):
    cert_to_verify_ASN1 = OpenSSL.crypto.dump_certificate(
                                OpenSSL.crypto.FILETYPE_ASN1, cert_to_verify)

    der = asn1.DerSequence()
    der.decode(cert_to_verify_ASN1)
    cert_to_verify_DER = der[0]
    cert_to_verify_ALGO = der[1]
    cert_to_verify_SIG = der[2]

    sig_DER = asn1.DerObject()
    sig_DER.decode(cert_to_verify_SIG)

    sig = sig_DER.payload

    # first byte is number of unused bytes. should be zero
    if sig[0] != '\x00':
        return False

    sig = sig[1:]

    try:
        OpenSSL.crypto.verify(id_cert, sig, cert_to_verify_DER, algo)
        return True
    except OpenSSL.crypto.Error:
        return False


# XXX should we check that the time is not later than the current time?
See github issue #142 where the duplicate line messup the undo stack
dataset/ETHPy150Open nskinkel/oppy/oppy/crypto/util.py/verifyCertSig--crossover with--dataset/ETHPy150Open pyQode/pyqode.core/test/test_api/test_code_edit.py/test_bug_duplicate_line_undo_stack