How to use the certbot.interfaces function in certbot

To help you get started, we’ve selected a few certbot 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 EFForg / starttls-everywhere / certbot / certbot-compatibility-test / certbot_compatibility_test / validator.py View on Github external
"""Validators to determine the current webserver configuration"""
import logging
import socket
import requests
import zope.interface

from acme import crypto_util
from acme import errors as acme_errors
from certbot import interfaces


logger = logging.getLogger(__name__)


@zope.interface.implementer(interfaces.IValidator)
class Validator(object):
    # pylint: disable=no-self-use
    """Collection of functions to test a live webserver's configuration"""

    def certificate(self, cert, name, alt_host=None, port=443):
        """Verifies the certificate presented at name is cert"""
        host = alt_host if alt_host else socket.gethostbyname(name)
        try:
            presented_cert = crypto_util.probe_sni(name, host, port)
        except acme_errors.Error as error:
            logger.exception(error)
            return False

        return presented_cert.digest("sha256") == cert.digest("sha256")

    def redirect(self, name, port=80, headers=None):
github greenhost / certbot-haproxy / certbot_haproxy / configurator.py View on Github external
from acme import challenges

from certbot import errors
from certbot import interfaces
from certbot import util
from certbot import reverter

from certbot.plugins import common
# from certbot.plugins.util import path_surgery

from certbot_haproxy import constants

logger = logging.getLogger(__name__)  # pylint:disable=invalid-name


@zope.interface.implementer(interfaces.IAuthenticator, interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class HAProxyConfigurator(common.Plugin):
    """
        HAProxy configurator.
    """

    description = "HAProxy - Alpha"

    @classmethod
    def add_parser_arguments(cls, add):
        # TODO: This is how we add arguments, do we need any?
        # add("enmod", default=constants.os_constant("enmod"),
        #    help="Path to the Apache 'a2enmod' binary.")
        pass

    def __init__(self, *args, **kwargs):
github certbot / certbot / certbot / certbot / _internal / plugins / disco.py View on Github external
    @classmethod
    def find_all(cls):
        """Find plugins using setuptools entry points."""
        plugins = {}  # type: Dict[str, PluginEntryPoint]
        # pylint: disable=not-callable
        entry_points = itertools.chain(
            pkg_resources.iter_entry_points(
                constants.SETUPTOOLS_PLUGINS_ENTRY_POINT),
            pkg_resources.iter_entry_points(
                constants.OLD_SETUPTOOLS_PLUGINS_ENTRY_POINT),)
        for entry_point in entry_points:
            plugin_ep = PluginEntryPoint(entry_point)
            assert plugin_ep.name not in plugins, (
                "PREFIX_FREE_DISTRIBUTIONS messed up")
            # providedBy | pylint: disable=no-member
            if interfaces.IPluginFactory.providedBy(plugin_ep.plugin_cls):
                plugins[plugin_ep.name] = plugin_ep
            else:  # pragma: no cover
                logger.warning(
                    "%r does not provide IPluginFactory, skipping", plugin_ep)
        return cls(plugins)
github hsmade / certbot-dns-transip / certbot_dns_transip / dns_transip.py View on Github external
import zope.interface
from certbot import errors
from certbot import interfaces
from certbot.plugins import dns_common

__author__ = '''Wim Fournier '''
__docformat__ = 'plaintext'
__date__ = '''14-07-2017'''

LOGGER = logging.getLogger(__name__)
# There seems to be a bug with suds where it tries to access invalid attributes on logging
logging.getLogger('suds').setLevel('WARNING')


@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(dns_common.DNSAuthenticator):

    """
    DNS Authenticator for Transip.

    This Authenticator uses the Transip API to fulfill a dns-01 challenge.
    """

    description = 'Obtain certs using a DNS TXT record (if you are using Transip for DNS).'

    def __init__(self, *args, **kwargs):
        """Setup object."""
        super(Authenticator, self).__init__(*args, **kwargs)
        self.credentials = None
        self.logger = LOGGER.getChild(self.__class__.__name__)
        self.temp_file = None
github certbot / certbot / certbot / examples / plugins / certbot_example_plugins.py View on Github external
"""Example Certbot plugins.

For full examples, see `certbot.plugins`.

"""
import zope.interface

from certbot import interfaces
from certbot.plugins import common


@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(common.Plugin):
    """Example Authenticator."""

    description = "Example Authenticator plugin"

    # Implement all methods from IAuthenticator, remembering to add
    # "self" as first argument, e.g. def prepare(self)...


@zope.interface.implementer(interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class Installer(common.Plugin):
    """Example Installer."""

    description = "Example Installer plugin"
github tsuru / rpaas / rpaas / ssl_plugins / le_authenticator.py View on Github external
from acme import challenges

from certbot import interfaces
from certbot.plugins import common


logger = logging.getLogger(__name__)


class RpaasLeAuthenticator(common.Plugin):
    """RPAAS Authenticator.

    This plugin create a authentticator for Tsuru RPAAS.
    """
    zope.interface.implements(interfaces.IAuthenticator)
    zope.interface.classProvides(interfaces.IPluginFactory)
    hidden = True

    description = "Configure RPAAS HTTP server"

    CMD_TEMPLATE = """\
location /{achall.URI_ROOT_PATH}/{encoded_token} {{
    default_type text/plain;
    echo -n '{validation}';
}}
"""
    """Command template."""

    def __init__(self, instance_name, consul_manager, *args, **kwargs):
        super(RpaasLeAuthenticator, self).__init__(*args, **kwargs)
        self._root = './le'
        self._httpd = None
github certbot / certbot / certbot / certbot / _internal / plugins / selection.py View on Github external
def pick_configurator(
        config, default, plugins,
        question="How would you like to authenticate and install "
                 "certificates?"):
    """Pick configurator plugin."""
    return pick_plugin(
        config, default, plugins, question,
        (interfaces.IAuthenticator, interfaces.IInstaller))
github certbot / certbot / certbot / examples / plugins / certbot_example_plugins.py View on Github external
from certbot.plugins import common


@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(common.Plugin):
    """Example Authenticator."""

    description = "Example Authenticator plugin"

    # Implement all methods from IAuthenticator, remembering to add
    # "self" as first argument, e.g. def prepare(self)...


@zope.interface.implementer(interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class Installer(common.Plugin):
    """Example Installer."""

    description = "Example Installer plugin"
github certbot / certbot / certbot-dns-acmedns / certbot_dns_acmedns / dns_acmedns.py View on Github external
import json
import logging
import requests
import time

import zope.component
import zope.interface

from certbot import errors
from certbot import interfaces
from certbot.plugins import dns_common
from certbot.plugins import common

logger = logging.getLogger(__name__)

@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(dns_common.DNSAuthenticator):
    """DNS Authenticator for ACME-DNS

    This Authenticator uses the ACME-DNS API to fulfill a dns-01 challenge.
    """

    description = ('Obtain certificates using a DNS TXT record (if you are using '
                   'ACME-DNS to handle the validation). ')

    def __init__(self, *args, **kwargs):
        super(Authenticator, self).__init__(*args, **kwargs)
        # Override propagation delay, as it's not needed for ACME-DNS
        self.storage = common.PluginStorage(self.config, self.name)
        self.config.dns_acmedns_propagation_seconds = 0
        self.domain_map = self.storage.fetch("domain_map")
github certbot / certbot / certbot-dns-dnsimple / certbot_dns_dnsimple / _internal / dns_dnsimple.py View on Github external
import logging

from lexicon.providers import dnsimple
import zope.interface

from certbot import errors
from certbot import interfaces
from certbot.plugins import dns_common
from certbot.plugins import dns_common_lexicon

logger = logging.getLogger(__name__)

ACCOUNT_URL = 'https://dnsimple.com/user'


@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(dns_common.DNSAuthenticator):
    """DNS Authenticator for DNSimple

    This Authenticator uses the DNSimple v2 API to fulfill a dns-01 challenge.
    """

    description = 'Obtain certificates using a DNS TXT record (if you are using DNSimple for DNS).'
    ttl = 60

    def __init__(self, *args, **kwargs):
        super(Authenticator, self).__init__(*args, **kwargs)
        self.credentials = None

    @classmethod
    def add_parser_arguments(cls, add):  # pylint: disable=arguments-differ