How to use the letsencrypt.errors.RevokerError function in letsencrypt

To help you get started, we’ve selected a few letsencrypt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github certbot / certbot / letsencrypt / revoker.py View on Github external
def revoke_from_key(self, authkey):
        """Revoke all certificates under an authorized key.

        :param authkey: Authorized key used in previous transactions
        :type authkey: :class:`letsencrypt.le_util.Key`

        """
        certs = []
        try:
            clean_pem = OpenSSL.crypto.dump_privatekey(
                OpenSSL.crypto.FILETYPE_PEM, OpenSSL.crypto.load_privatekey(
                    OpenSSL.crypto.FILETYPE_PEM, authkey.pem))
        except OpenSSL.crypto.Error as error:
            logger.debug(error, exc_info=True)
            raise errors.RevokerError(
                "Invalid key file specified to revoke_from_key")

        with open(self.list_path, "rb") as csvfile:
            csvreader = csv.reader(csvfile)
            for row in csvreader:
                # idx, cert, key
                # Add all keys that match to marked list
                # Note: The key can be different than the pub key found in the
                #    certificate.
                _, b_k = self._row_to_backup(row)
                try:
                    test_pem = OpenSSL.crypto.dump_privatekey(
                        OpenSSL.crypto.FILETYPE_PEM, OpenSSL.crypto.load_privatekey(
                            OpenSSL.crypto.FILETYPE_PEM, open(b_k).read()))
                except OpenSSL.crypto.Error as error:
                    logger.debug(error, exc_info=True)
github certbot / certbot / letsencrypt / revoker.py View on Github external
idx = 0

        with open(self.list_path, "rb") as orgfile:
            csvreader = csv.reader(orgfile)
            with open(list_path2, "wb") as newfile:
                csvwriter = csv.writer(newfile)

                for row in csvreader:
                    if idx >= len(cert_list) or row != cert_list[idx].get_row():
                        csvwriter.writerow(row)
                    else:
                        idx += 1

        # This should never happen...
        if idx != len(cert_list):
            raise errors.RevokerError(
                "Did not find all cert_list items to remove from LIST")

        shutil.copy2(list_path2, self.list_path)
        os.remove(list_path2)
github certbot / certbot / letsencrypt / revoker.py View on Github external
:returns: TODO

        """
        # XXX | pylint: disable=unused-variable

        # pylint: disable=protected-access
        certificate = jose_util.ComparableX509(cert._cert)
        try:
            with open(cert.backup_key_path, "rU") as backup_key_file:
                key = OpenSSL.crypto.load_privatekey(
                    OpenSSL.crypto.FILETYPE_PEM, backup_key_file.read())
        # If the key file doesn't exist... or is corrupted
        except OpenSSL.crypto.Error as error:
            logger.debug(error, exc_info=True)
            raise errors.RevokerError(
                "Corrupted backup key file: %s" % cert.backup_key_path)

        return self.acme.revoke(cert=None)  # XXX
github certbot / certbot / letsencrypt / revoker.py View on Github external
:param str cert_filepath: Name of file containing certificate in
            PEM format.

        """
        try:
            with open(cert_path) as cert_file:
                cert_data = cert_file.read()
        except IOError:
            raise errors.RevokerError(
                "Error loading certificate: %s" % cert_path)

        try:
            self._cert = OpenSSL.crypto.load_certificate(
                OpenSSL.crypto.FILETYPE_PEM, cert_data)
        except OpenSSL.crypto.Error:
            raise errors.RevokerError(
                "Error loading certificate: %s" % cert_path)

        self.idx = -1

        self.orig = None
        self.orig_key = None
        self.backup_path = ""
        self.backup_key_path = ""

        self.installed = ["Unknown"]