src/OpenSSL/crypto.py
def add_cert(self, cert):
        """
        Adds a trusted certificate to this store.

        Adding a certificate with this method adds this certificate as a
        *trusted* certificate.

        :param X509 cert: The certificate to add to this store.

        :raises TypeError: If the certificate is not an :class:`X509`.

        :raises OpenSSL.crypto.Error: If OpenSSL was unhappy with your
            certificate.

        :return: ``None`` if the certificate was added successfully.
        """
        if not isinstance(cert, X509):
            raise TypeError()

        # As of OpenSSL 1.1.0i adding the same cert to the store more than
        # once doesn't cause an error. Accordingly, this code now silences
        # the error for OpenSSL < 1.1.0i as well.
        if _lib.X509_STORE_add_cert(self._store, cert._x509) == 0:
            code = _lib.ERR_peek_error()
            err_reason = _lib.ERR_GET_REASON(code)
            _openssl_assert(
                err_reason == _lib.X509_R_CERT_ALREADY_IN_HASH_TABLE
            )
            _lib.ERR_clear_error()
def add_cert(self, cert):
        """
        Adds a trusted certificate to this store.

        Adding a certificate with this method adds this certificate as a
        *trusted* certificate.

        :param X509 cert: The certificate to add to this store.

        :raises TypeError: If the certificate is not an :class:`X509`.

        :raises OpenSSL.crypto.Error: If OpenSSL was unhappy with your
            certificate.

        :return: ``None`` if the certificate was added successfully.
        """
        if not isinstance(cert, X509):
            raise TypeError()

        # As of OpenSSL 1.1.0i adding the same cert to the store more than
        # once doesn't cause an error. Accordingly, this code now silences
        # the error for OpenSSL < 1.1.0i as well.
        if _lib.X509_STORE_add_cert(self._store, cert._x509) == 0:
            code = _lib.ERR_peek_error()
            err_reason = _lib.ERR_GET_REASON(code)
            _openssl_assert(
                err_reason == _lib.X509_R_CERT_ALREADY_IN_HASH_TABLE
            )
            _lib.ERR_clear_error()
Adds a trusted certificate to this store.

        Adding a certificate with this method adds this certificate as a
        *trusted* certificate.

        :param X509 cert: The certificate to add to this store.

        :raises TypeError: If the certificate is not an :class:`X509`.

        :raises OpenSSL.crypto.Error: If OpenSSL was unhappy with your
            certificate.

        :return: ``None`` if the certificate was added successfully.