# Buggy code
def enable_site(self, vhost):
    """Enables an available site, Apache reload required.

    .. note:: Does not make sure that the site correctly works or that all
              modules are enabled appropriately.

    .. todo:: This function should number subdomains before the domain
              vhost

    .. todo:: Make sure link is not broken...

    :param vhost: vhost to enable
    :type vhost: :class:`~certbot_apache.obj.VirtualHost`

    :raises .errors.NotSupportedError: If filesystem layout is not
        supported.

    """
    if self.is_site_enabled(vhost.filep):
        return

    if "/sites-available/" in vhost.filep:
        enabled_path = "%s/sites-enabled/%s" % (
            self.parser.root,
            os.path.basename(vhost.filep),
        )
        self.reverter.register_file_creation(False, enabled_path)
        os.symlink(vhost.filep, enabled_path)
        vhost.enabled = True
        logger.info("Enabling available site: %s", vhost.filep)
        self.save_notes += "Enabled site %s\n" % vhost.filep
    else:
        raise errors.NotSupportedError(
            "Unsupported filesystem layout. sites-available/enabled expected."
        )


# 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 enable_site(self, vhost):
    """Enables an available site, Apache reload required.

    .. note:: Does not make sure that the site correctly works or that all
              modules are enabled appropriately.

    .. todo:: This function should number subdomains before the domain
              vhost

    .. todo:: Make sure link is not broken...

    :param vhost: vhost to enable
    :type vhost: :class:`~certbot_apache.obj.VirtualHost`

    :raises .errors.NotSupportedError: If filesystem layout is not
        supported.

    """
    if vhost.enabled:
        return

    # Handle non-debian systems
    if not self.conf("handle-sites"):
        if not self.parser.parsed_in_original(vhost.filep):
            # Add direct include to root conf
            self.parser.add_include(self.parser.loc["default"], vhost.filep)
            vhost.enabled = True
        return

    enabled_path = "%s/sites-enabled/%s" % (
        self.parser.root,
        os.path.basename(vhost.filep),
    )
    self.reverter.register_file_creation(False, enabled_path)
    try:
        os.symlink(vhost.filep, enabled_path)
    except OSError as err:
        if (
            os.path.islink(enabled_path)
            and os.path.realpath(enabled_path) == vhost.filep
        ):
            # Already in shape
            vhost.enabled = True
            return
        else:
            logger.warning(
                "Could not symlink %s to %s, got error: %s",
                enabled_path,
                vhost.filep,
                err.strerror,
            )
            errstring = (
                "Encountered error while trying to enable a "
                + "newly created VirtualHost located at {0} by "
                + "linking to it from {1}"
            )
            raise errors.NotSupportedError(errstring.format(vhost.filep, enabled_path))
    vhost.enabled = True
    logger.info("Enabling available site: %s", vhost.filep)
    self.save_notes += "Enabled site %s\n" % vhost.filep