# Buggy code
def prepare(self):
    """Prepare the authenticator/installer.

    :raises .errors.NoInstallationError: If Apache configs cannot be found
    :raises .errors.MisconfigurationError: If Apache is misconfigured
    :raises .errors.NotSupportedError: If Apache version is not supported
    :raises .errors.PluginError: If there is any other error

    """
    # Perform the actual Augeas initialization to be able to react
    try:
        self.init_augeas()
    except ImportError:
        raise errors.NoInstallationError("Problem in Augeas installation")

    # Verify Apache is installed
    restart_cmd = constants.os_constant("restart_cmd")[0]
    if not util.exe_exists(restart_cmd):
        if not path_surgery(restart_cmd):
            raise errors.NoInstallationError(
                "Cannot find Apache control command {0}".format(restart_cmd)
            )

    # Make sure configuration is valid
    self.config_test()

    # Set Version
    if self.version is None:
        self.version = self.get_version()
        logger.debug("Apache version is %s", ".".join(str(i) for i in self.version))
    if self.version < (2, 2):
        raise errors.NotSupportedError(
            "Apache Version %s not supported.", str(self.version)
        )

    if not self._check_aug_version():
        raise errors.NotSupportedError(
            "Apache plugin support requires libaugeas0 and augeas-lenses "
            "version 1.2.0 or higher, please make sure you have you have "
            "those installed."
        )

    self.parser = parser.ApacheParser(
        self.aug, self.conf("server-root"), self.conf("vhost-root"), self.version
    )
    # Check for errors in parsing files with Augeas
    self.check_parsing_errors("httpd.aug")

    # Get all of the available vhosts
    self.vhosts = self.get_virtual_hosts()

    install_ssl_options_conf(self.mod_ssl_conf, self.updated_mod_ssl_conf_digest)

    # Prevent two Apache plugins from modifying a config at once
    try:
        util.lock_dir_until_exit(self.conf("server-root"))
    except (OSError, errors.LockError):
        logger.debug("Encountered error:", exc_info=True)
        raise errors.PluginError("Unable to lock %s", self.conf("server-root"))


# Traceback (PluginError)
Cannot find a cert or key directive in /files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost. VirtualHost was not modified
Encountered exception:
Traceback (most recent call last):
File "/home/bmw/src/certbot/certbot/client.py", line 439, in deploy_certificate
fullchain_path=fullchain_path)
File "/home/bmw/src/certbot/certbot-apache/certbot_apache/configurator.py", line 269, in deploy_cert
"Unable to find cert and/or key directives")
PluginError: Unable to find cert and/or key directives

Calling registered functions
Reporting to user: Unable to install the certificate
Exiting abnormally:
Traceback (most recent call last):
File "/usr/local/bin/certbot", line 11, in <module>
load_entry_point('certbot', 'console_scripts', 'certbot')()
File "/home/bmw/src/certbot/certbot/main.py", line 743, in main
return config.func(config, plugins)
File "/home/bmw/src/certbot/certbot/main.py", line 604, in run
_install_cert(config, le_client, domains, new_lineage)
File "/home/bmw/src/certbot/certbot/main.py", line 469, in _install_cert
path_provider.cert_path, path_provider.chain_path, path_provider.fullchain_path)
File "/home/bmw/src/certbot/certbot/client.py", line 439, in deploy_certificate
fullchain_path=fullchain_path)
File "/home/bmw/src/certbot/certbot-apache/certbot_apache/configurator.py", line 269, in deploy_cert
"Unable to find cert and/or key directives")
PluginError: Unable to find cert and/or key directives

# Fixed code
def prepare(self):
    """Prepare the authenticator/installer.

    :raises .errors.NoInstallationError: If Apache configs cannot be found
    :raises .errors.MisconfigurationError: If Apache is misconfigured
    :raises .errors.NotSupportedError: If Apache version is not supported
    :raises .errors.PluginError: If there is any other error

    """
    # Perform the actual Augeas initialization to be able to react
    try:
        self.init_augeas()
    except ImportError:
        raise errors.NoInstallationError("Problem in Augeas installation")

    # Verify Apache is installed
    restart_cmd = constants.os_constant("restart_cmd")[0]
    if not util.exe_exists(restart_cmd):
        if not path_surgery(restart_cmd):
            raise errors.NoInstallationError(
                "Cannot find Apache control command {0}".format(restart_cmd)
            )

    # Make sure configuration is valid
    self.config_test()

    # Set Version
    if self.version is None:
        self.version = self.get_version()
        logger.debug("Apache version is %s", ".".join(str(i) for i in self.version))
    if self.version < (2, 2):
        raise errors.NotSupportedError(
            "Apache Version %s not supported.", str(self.version)
        )

    if not self._check_aug_version():
        raise errors.NotSupportedError(
            "Apache plugin support requires libaugeas0 and augeas-lenses "
            "version 1.2.0 or higher, please make sure you have you have "
            "those installed."
        )

    # Parse vhost-root if defined on cli
    if not self.conf("vhost-root"):
        self.vhostroot = constants.os_constant("vhost_root")
    else:
        self.vhostroot = os.path.abspath(self.conf("vhost-root"))

    self.parser = parser.ApacheParser(
        self.aug,
        self.conf("server-root"),
        self.conf("vhost-root"),
        self.version,
        configurator=self,
    )
    # Check for errors in parsing files with Augeas
    self.check_parsing_errors("httpd.aug")

    # Get all of the available vhosts
    self.vhosts = self.get_virtual_hosts()

    install_ssl_options_conf(self.mod_ssl_conf, self.updated_mod_ssl_conf_digest)

    # Prevent two Apache plugins from modifying a config at once
    try:
        util.lock_dir_until_exit(self.conf("server-root"))
    except (OSError, errors.LockError):
        logger.debug("Encountered error:", exc_info=True)
        raise errors.PluginError("Unable to lock %s", self.conf("server-root"))