How to use the certbot.plugins.common 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-apache / certbot_apache / configurator.py View on Github external
def get_name_from_ip(self, addr):  # pylint: disable=no-self-use
        """Returns a reverse dns name if available.

        :param addr: IP Address
        :type addr: ~.common.Addr

        :returns: name or empty string if name cannot be determined
        :rtype: str

        """
        # If it isn't a private IP, do a reverse DNS lookup
        if not common.private_ips_regex.match(addr.get_addr()):
            try:
                socket.inet_aton(addr.get_addr())
                return socket.gethostbyaddr(addr.get_addr())[0]
            except (socket.error, socket.herror, socket.timeout):
                pass

        return ""
github certbot / certbot / certbot-nginx / certbot_nginx / obj.py View on Github external
"""Module contains classes used by the Nginx Configurator."""
import re

import six

from certbot.plugins import common

REDIRECT_DIRECTIVES = ['return', 'rewrite']

class Addr(common.Addr):
    r"""Represents an Nginx address, i.e. what comes after the 'listen'
    directive.

    According to the `documentation`_, this may be address[:port], port,
    or unix:path. The latter is ignored here.

    The default value if no directive is specified is \*:80 (superuser)
    or \*:8000 (otherwise). If no port is specified, the default is
    80. If no address is specified, listen on all addresses.

    .. _documentation:
       http://nginx.org/en/docs/http/ngx_http_core_module.html#listen

    .. todo:: Old-style nginx configs define SSL vhosts in a separate
              block instead of using 'ssl' in the listen directive.
github certbot / certbot / certbot-apache / certbot_apache / obj.py View on Github external
"""Module contains classes used by the Apache Configurator."""
import re

from certbot.plugins import common


class Addr(common.Addr):
    """Represents an Apache address."""

    def __eq__(self, other):
        """This is defined as equalivalent within Apache.

        ip_addr:* == ip_addr

        """
        if isinstance(other, self.__class__):
            return ((self.tup == other.tup) or
                    (self.tup[0] == other.tup[0] and
                     self.is_wildcard() and other.is_wildcard()))
        return False

    def __ne__(self, other):
        return not self.__eq__(other)
github certbot / certbot / certbot-apache / certbot_apache / _internal / configurator.py View on Github external
def get_name_from_ip(self, addr):  # pylint: disable=no-self-use
        """Returns a reverse dns name if available.

        :param addr: IP Address
        :type addr: ~.common.Addr

        :returns: name or empty string if name cannot be determined
        :rtype: str

        """
        # If it isn't a private IP, do a reverse DNS lookup
        if not common.private_ips_regex.match(addr.get_addr()):
            try:
                socket.inet_aton(addr.get_addr())
                return socket.gethostbyaddr(addr.get_addr())[0]
            except (socket.error, socket.herror, socket.timeout):
                pass

        return ""
github certbot / certbot / certbot-apache / certbot_apache / obj.py View on Github external
"""Module contains classes used by the Apache Configurator."""
import re

from certbot.plugins import common


class Addr(common.Addr):
    """Represents an Apache address."""

    def __eq__(self, other):
        """This is defined as equivalent within Apache.

        ip_addr:* == ip_addr

        """
        if isinstance(other, self.__class__):
            return ((self.tup == other.tup) or
                    (self.tup[0] == other.tup[0] and
                     self.is_wildcard() and other.is_wildcard()))
        return False

    def __ne__(self, other):
        return not self.__eq__(other)
github certbot / certbot / certbot-sendmail / certbot_sendmail / configurator.py View on Github external
with open(diff_file, "w") as f:
                f.write(diff)
            message = ("The appropriate diff has been written to {diff_file}.\n"
                "Review these changes, then apply them with:\n\n"
                "    patch -b {tls_file} -i {diff_file}\n\n"
                "This should also create a backup of the original file at {tls_file}.orig\n").format(
                diff_file=diff_file, tls_file=self._filepath)
        else:
            message = ("Review and apply the following diff to {tls_file}."
                "Continue when finished:\n\n{content}\n\n".format(
                tls_file=self._filepath, content=diff))
        zope.component.getUtility(interfaces.IDisplay).notification(message, pause=True)

@zope.interface.implementer(interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class SendmailConfigurator(common.Installer):
    # pylint: disable=too-many-instance-attributes,too-many-public-methods
    """Sendmail configurator.

    .. todo:: Add proper support for comments in the config. Currently,
        config files modified by the configurator will lose all their comments.

    :ivar config: Configuration.
    :type config: :class:`~certbot.interfaces.IConfig`

    :ivar str save_notes: Human-readable config change notes

    :ivar reverter: saves and reverts checkpoints
    :type reverter: :class:`certbot.reverter.Reverter`

    """
github certbot / certbot / certbot-nginx / certbot_nginx / configurator.py View on Github external
from acme.magic_typing import List, Dict, Set # pylint: disable=unused-import, no-name-in-module


NAME_RANK = 0
START_WILDCARD_RANK = 1
END_WILDCARD_RANK = 2
REGEX_RANK = 3
NO_SSL_MODIFIER = 4


logger = logging.getLogger(__name__)


@zope.interface.implementer(interfaces.IAuthenticator, interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class NginxConfigurator(common.Installer):
    # pylint: disable=too-many-instance-attributes,too-many-public-methods
    """Nginx configurator.

    .. todo:: Add proper support for comments in the config. Currently,
        config files modified by the configurator will lose all their comments.

    :ivar config: Configuration.
    :type config: :class:`~certbot.interfaces.IConfig`

    :ivar parser: Handles low level parsing
    :type parser: :class:`~certbot_nginx.parser`

    :ivar str save_notes: Human-readable config change notes

    :ivar reverter: saves and reverts checkpoints
    :type reverter: :class:`certbot.reverter.Reverter`
github dlapiduz / certbot-s3front / certbot_s3front / installer.py View on Github external
import sys
import logging

import zope.component
import zope.interface

import boto3
import botocore

from certbot import interfaces
from certbot.plugins import common


logger = logging.getLogger(__name__)

class Installer(common.Plugin):
    zope.interface.implements(interfaces.IInstaller)
    zope.interface.classProvides(interfaces.IPluginFactory)

    description = "S3/CloudFront Installer"

    @classmethod
    def add_parser_arguments(cls, add):
        add("cf-distribution-id", default=os.getenv('CF_DISTRIBUTION_ID'),
            help="CloudFront distribution id")

    def __init__(self, *args, **kwargs):
        super(Installer, self).__init__(*args, **kwargs)


    def prepare(self):  # pylint: disable=missing-docstring,no-self-use
        pass  # pragma: no cover
github gboudreau / certbot-heroku / certbot_heroku / configurator.py View on Github external
from acme import challenges

from certbot import errors
from certbot import interfaces
from certbot.display import util as display_util
from certbot.plugins import common


logger = logging.getLogger(__name__)

DEV_NULL = open(os.devnull, 'w')


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

    description = "Heroku SSL"

    MORE_INFO = """\
Plugin that performs hostname validation using Heroku by
setting a config var, then installs the generated certificate with
Heroku SSL. It expects that your Heroku app is already
configured to serve the proper response when it receives the ACME
challenge request, and that the Heroku CLI is already installed
and functional. See https://github.com/gboudreau/certbot-heroku for
detailed set-up instructions."""

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