Exemple #1
0
def _delete_if_appropriate(config):
    """Does the user want to delete their now-revoked certs? If run in non-interactive mode,
    deleting happens automatically.

    :param config: parsed command line arguments
    :type config: interfaces.IConfig

    :returns: `None`
    :rtype: None

    :raises errors.Error: If anything goes wrong, including bad user input, if an overlapping
        archive dir is found for the specified lineage, etc ...
    """
    display = zope.component.getUtility(interfaces.IDisplay)

    attempt_deletion = config.delete_after_revoke
    if attempt_deletion is None:
        msg = (
            "Would you like to delete the cert(s) you just revoked, along with all earlier and "
            "later versions of the cert?")
        attempt_deletion = display.yesno(msg,
                                         yes_label="Yes (recommended)",
                                         no_label="No",
                                         force_interactive=True,
                                         default=True)

    if not attempt_deletion:
        return

    # config.cert_path must have been set
    # config.certname may have been set
    assert config.cert_path

    if not config.certname:
        config.certname = cert_manager.cert_path_to_lineage(config)

    # don't delete if the archive_dir is used by some other lineage
    archive_dir = storage.full_archive_path(
        configobj.ConfigObj(
            storage.renewal_file_for_certname(config, config.certname)),
        config, config.certname)
    try:
        cert_manager.match_and_check_overlaps(config, [lambda x: archive_dir],
                                              lambda x: x.archive_dir,
                                              lambda x: x)
    except errors.OverlappingMatchFound:
        logger.warning(
            "Not deleting revoked certs due to overlapping archive dirs. More than "
            "one certificate is using %s", archive_dir)
        return
    except Exception as e:
        msg = (
            'config.default_archive_dir: {0}, config.live_dir: {1}, archive_dir: {2},'
            'original exception: {3}')
        msg = msg.format(config.default_archive_dir, config.live_dir,
                         archive_dir, e)
        raise errors.Error(msg)

    cert_manager.delete(config)
Exemple #2
0
def delete(config, unused_plugins):
    """Delete a certificate

    Use the information in the config file to delete an existing
    lineage.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

    :returns: `None`
    :rtype: None

    """
    cert_manager.delete(config)
 def _call(self):
     from certbot._internal import cert_manager
     cert_manager.delete(self.config)