How to use the letsencrypt.interfaces function in letsencrypt

To help you get started, we’ve selected a few letsencrypt 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 certbot / certbot / letsencrypt / cli.py View on Github external
def _tos_cb(regr):
                if args.tos:
                    return True
                msg = ("Please read the Terms of Service at {0}. You "
                       "must agree in order to register with the ACME "
                       "server at {1}".format(
                           regr.terms_of_service, config.server))
                return zope.component.getUtility(interfaces.IDisplay).yesno(
                    msg, "Agree", "Cancel")
github sjerdo / letsencrypt-directadmin / letsencrypt_directadmin / configurator.py View on Github external
from acme import challenges

from letsencrypt import interfaces
from letsencrypt.plugins import common
from letsencrypt.errors import PluginError

import directadmin
from letsencrypt_directadmin import challenge, deployer
from urlparse import urlsplit


class Configurator(common.Plugin):
    """DirectAdmin API Configurator."""
    zope.interface.implements(interfaces.IAuthenticator, interfaces.IInstaller)
    zope.interface.classProvides(interfaces.IPluginFactory)

    description = "DirectAdminAPI Configurator"

    MORE_INFO = """\
Configurator plugin that performs http-01 challenge by saving
necessary validation resources to appropriate paths on a server
using the DirectAdmin API. It expects that correct API credentials
are given in commandline or in GUI. Certificates will be installed
automatically. """

    def more_info(self):  # pylint: disable=missing-docstring,no-self-use
        return self.MORE_INFO

    @classmethod
    def add_parser_arguments(cls, add):
        add("server", default=os.getenv('DA_SERVER'),
github certbot / certbot / letsencrypt / configuration.py View on Github external
:attr:`~letsencrypt.interfaces.IConfig.work_dir` and relative
    paths defined in :py:mod:`letsencrypt.constants`:

      - `accounts_dir`
      - `csr_dir`
      - `in_progress_dir`
      - `key_dir`
      - `renewer_config_file`
      - `temp_checkpoint_dir`

    :ivar namespace: Namespace typically produced by
        :meth:`argparse.ArgumentParser.parse_args`.
    :type namespace: :class:`argparse.Namespace`

    """
    zope.interface.implements(interfaces.IConfig)

    def __init__(self, namespace):
        self.namespace = namespace

        if self.simple_http_port == self.dvsni_port:
            raise errors.Error(
                "Trying to run SimpleHTTP and DVSNI "
                "on the same port ({0})".format(self.dvsni_port))

    def __getattr__(self, name):
        return getattr(self.namespace, name)

    @property
    def server_path(self):
        """File path based on ``server``."""
        parsed = urlparse.urlparse(self.namespace.server)
github certbot / certbot / letsencrypt / plugins / webroot.py View on Github external
import zope.interface

from acme import challenges

from letsencrypt import errors
from letsencrypt import interfaces
from letsencrypt.plugins import common


logger = logging.getLogger(__name__)


class Authenticator(common.Plugin):
    """Webroot Authenticator."""
    zope.interface.implements(interfaces.IAuthenticator)
    zope.interface.classProvides(interfaces.IPluginFactory)

    description = "Webroot Authenticator"

    MORE_INFO = """\
Authenticator plugin that performs SimpleHTTP challenge by saving
necessary validation resources to appropriate paths on the file
system. It expects that there is some other HTTP server configured
to serve all files under specified web root ({0})."""

    def more_info(self):  # pylint: disable=missing-docstring,no-self-use
        return self.MORE_INFO.format(self.conf("path"))

    @classmethod
    def add_parser_arguments(cls, add):
        add("path", help="public_html / webroot path")
github certbot / certbot / letsencrypt / plugins / standalone / authenticator.py View on Github external
listeners = [conn.pid for conn in net_connections
                     if conn.status == 'LISTEN' and
                     conn.type == socket.SOCK_STREAM and
                     conn.laddr[1] == port]

        try:
            if listeners and listeners[0] is not None:
                # conn.pid may be None if the current process doesn't have
                # permission to identify the listening process!  Additionally,
                # listeners may have more than one element if separate
                # sockets have bound the same port on separate interfaces.
                # We currently only have UI to notify the user about one
                # of them at a time.
                pid = listeners[0]
                name = psutil.Process(pid).name()
                display = zope.component.getUtility(interfaces.IDisplay)
                display.notification(
                    "The program {0} (process ID {1}) is already listening "
                    "on TCP port {2}. This will prevent us from binding to "
                    "that port. Please stop the {0} program temporarily "
                    "and then try again.".format(name, pid, port))
                return True
        except (psutil.NoSuchProcess, psutil.AccessDenied):
            # Perhaps the result of a race where the process could have
            # exited or relinquished the port (NoSuchProcess), or the result
            # of an OS policy where we're not allowed to look up the process
            # name (AccessDenied).
            pass
        return False
github certbot / certbot / letsencrypt / plugins / standalone / authenticator.py View on Github external
class StandaloneAuthenticator(common.Plugin):
    # pylint: disable=too-many-instance-attributes
    """Standalone authenticator.

    This authenticator creates its own ephemeral TCP listener on the
    specified port in order to respond to incoming DVSNI challenges from
    the certificate authority. Therefore, it does not rely on any
    existing server program.

    :param OpenSSL.crypto.PKey private_key: DVSNI challenge certificate
        key.
    :param sni_names: Mapping from z_domain (`bytes`) to PEM-encoded
        certificate (`bytes`).

    """
    zope.interface.implements(interfaces.IAuthenticator)
    zope.interface.classProvides(interfaces.IPluginFactory)

    description = "Standalone Authenticator"

    def __init__(self, *args, **kwargs):
        super(StandaloneAuthenticator, self).__init__(*args, **kwargs)
        self.child_pid = None
        self.parent_pid = os.getpid()
        self.subproc_state = None
        self.tasks = {}
        self.sni_names = {}
        self.sock = None
        self.connection = None
        self.key_pem = crypto_util.make_key(bits=2048)
        self.private_key = OpenSSL.crypto.load_privatekey(
            OpenSSL.crypto.FILETYPE_PEM, self.key_pem)
github certbot / certbot / letsencrypt / cli.py View on Github external
helpful.add("auth",
                "--csr", type=read_file,
                help="Path to a Certificate Signing Request (CSR) in DER format.")
    helpful.add("rollback",
                "--checkpoints", type=int, metavar="N",
                default=flag_default("rollback_checkpoints"),
                help="Revert configuration N number of checkpoints.")

    helpful.add("plugins",
                "--init", action="store_true", help="Initialize plugins.")
    helpful.add("plugins",
                "--prepare", action="store_true", help="Initialize and prepare plugins.")
    helpful.add("plugins",
                "--authenticators", action="append_const", dest="ifaces",
                const=interfaces.IAuthenticator, help="Limit to authenticator plugins only.")
    helpful.add("plugins",
                "--installers", action="append_const", dest="ifaces",
                const=interfaces.IInstaller, help="Limit to installer plugins only.")
github certbot / certbot / letsencrypt / client.py View on Github external
def _recovery_routine_with_msg(self, success_msg):
        """Calls the installer's recovery routine and prints success_msg

        :param str success_msg: message to show on successful recovery

        """
        self.installer.recovery_routine()
        reporter = zope.component.getUtility(interfaces.IReporter)
        reporter.add_message(success_msg, reporter.HIGH_PRIORITY)