Verify self. Supports verification on both X509 store object
        or just public issuer key
        @param store X509Store object.
        @param chain - list of X509 objects to add into verification
            context.These objects are untrusted, but can be used to
            build certificate chain up to trusted object in the store
        @param key - PKey object with open key to validate signature

        parameters store and key are mutually exclusive. If neither
        is specified, attempts to verify self as self-signed certificate

def verify(self, store=None, chain=None, key=None):
        """
        Verify self. Supports verification on both X509 store object
        or just public issuer key
        @param store X509Store object.
        @param chain - list of X509 objects to add into verification
            context.These objects are untrusted, but can be used to
            build certificate chain up to trusted object in the store
        @param key - PKey object with open key to validate signature

        parameters store and key are mutually exclusive. If neither
        is specified, attempts to verify self as self-signed certificate
        """
        if store is not None and key is not None:
            raise X509Error("key and store cannot be specified simultaneously")
        if store is not None:
            ctx = libcrypto.X509_STORE_CTX_new()
            if ctx is None:
                raise X509Error("Error allocating X509_STORE_CTX")
            if chain is not None and len(chain) > 0:
                chain_ptr = StackOfX509(chain).ptr
            else:
                chain_ptr = None
            if libcrypto.X509_STORE_CTX_init(ctx, store.store, self.cert,
                                             chain_ptr) < 0:
                raise X509Error("Error allocating X509_STORE_CTX")
            res = libcrypto.X509_verify_cert(ctx)
            libcrypto.X509_STORE_CTX_free(ctx)
            return res > 0
        else:
            if key is None:
                if self.issuer != self.subject:
                    # Not a self-signed certificate
                    return False
                key = self.pubkey
            res = libcrypto.X509_verify(self.cert, key.key)
            if res < 0:
                raise X509Error("X509_verify failed")
            return res > 0