# Buggy code
def _create_vhost(self, path):
    """Used by get_virtual_hosts to create vhost objects

    :param str path: Augeas path to virtual host

    :returns: newly created vhost
    :rtype: :class:`~certbot_apache.obj.VirtualHost`

    """
    addrs = set()
    try:
        args = self.aug.match(path + "/arg")
    except RuntimeError:
        logger.warning("Encountered a problem while parsing file: %s, skipping", path)
        return None
    for arg in args:
        addrs.add(obj.Addr.fromstring(self.parser.get_arg(arg)))
    is_ssl = False

    if self.parser.find_dir("SSLEngine", "on", start=path, exclude=False):
        is_ssl = True

    # "SSLEngine on" might be set outside of <VirtualHost>
    # Treat vhosts with port 443 as ssl vhosts
    for addr in addrs:
        if addr.get_port() == "443":
            is_ssl = True

    filename = get_file_path(self.aug.get("/augeas/files%s/path" % get_file_path(path)))
    if filename is None:
        return None

    if self.conf("handle-sites"):
        is_enabled = self.is_site_enabled(filename)
    else:
        is_enabled = True

    macro = False
    if "/macro/" in path.lower():
        macro = True

    vhost = obj.VirtualHost(filename, path, addrs, is_ssl, is_enabled, modmacro=macro)
    self._add_servernames(vhost)
    return vhost


# 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 _create_vhost(self, path):
    """Used by get_virtual_hosts to create vhost objects

    :param str path: Augeas path to virtual host

    :returns: newly created vhost
    :rtype: :class:`~certbot_apache.obj.VirtualHost`

    """
    addrs = set()
    try:
        args = self.aug.match(path + "/arg")
    except RuntimeError:
        logger.warning("Encountered a problem while parsing file: %s, skipping", path)
        return None
    for arg in args:
        addrs.add(obj.Addr.fromstring(self.parser.get_arg(arg)))
    is_ssl = False

    if self.parser.find_dir("SSLEngine", "on", start=path, exclude=False):
        is_ssl = True

    # "SSLEngine on" might be set outside of <VirtualHost>
    # Treat vhosts with port 443 as ssl vhosts
    for addr in addrs:
        if addr.get_port() == "443":
            is_ssl = True

    filename = get_file_path(self.aug.get("/augeas/files%s/path" % get_file_path(path)))
    if filename is None:
        return None

    macro = False
    if "/macro/" in path.lower():
        macro = True

    vhost_enabled = self.parser.parsed_in_original(filename)

    vhost = obj.VirtualHost(
        filename, path, addrs, is_ssl, vhost_enabled, modmacro=macro
    )
    self._add_servernames(vhost)
    return vhost