How to use the letsencrypt.le_util.run_script 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-apache / letsencrypt_apache / configurator.py View on Github external
def config_test(self):  # pylint: disable=no-self-use
        """Check the configuration of Apache for errors.

        :raises .errors.MisconfigurationError: If config_test fails

        """
        try:
            le_util.run_script(constants.os_constant("conftest_cmd"))
        except errors.SubprocessError as err:
            raise errors.MisconfigurationError(str(err))
github certbot / certbot / letsencrypt-apache / letsencrypt_apache / configurator.py View on Github external
def get_version(self):
        """Return version of Apache Server.

        Version is returned as tuple. (ie. 2.4.7 = (2, 4, 7))

        :returns: version
        :rtype: tuple

        :raises .PluginError: if unable to find Apache version

        """
        try:
            stdout, _ = le_util.run_script(
                constants.os_constant("version_cmd"))
        except errors.SubprocessError:
            raise errors.PluginError(
                "Unable to run %s -v" %
                constants.os_constant("version_cmd"))

        regex = re.compile(r"Apache/([0-9\.]*)", re.IGNORECASE)
        matches = regex.findall(stdout)

        if len(matches) != 1:
            raise errors.PluginError("Unable to find Apache version")

        return tuple([int(i) for i in matches[0].split(".")])
github certbot / certbot / letsencrypt-apache / letsencrypt_apache / configurator.py View on Github external
def _enable_mod_debian(self, mod_name, temp):
        """Assumes mods-available, mods-enabled layout."""
        # Generate reversal command.
        # Try to be safe here... check that we can probably reverse before
        # applying enmod command
        if not le_util.exe_exists(self.conf("dismod")):
            raise errors.MisconfigurationError(
                "Unable to find a2dismod, please make sure a2enmod and "
                "a2dismod are configured correctly for letsencrypt.")

        self.reverter.register_undo_command(
            temp, [self.conf("dismod"), mod_name])
        le_util.run_script([self.conf("enmod"), mod_name])
github certbot / certbot / letsencrypt / cert_manager.py View on Github external
def revoked_status(cert_path, chain_path):
    """Get revoked status for a particular cert version.

    .. todo:: Make this a non-blocking call

    :param str cert_path: Path to certificate
    :param str chain_path: Path to chain certificate

    """
    url, _ = le_util.run_script(
        ["openssl", "x509", "-in", cert_path, "-noout", "-ocsp_uri"])

    url = url.rstrip()
    host = url.partition("://")[2].rstrip("/")
    if not host:
        raise errors.Error(
            "Unable to get OCSP host from cert, url - %s", url)

    # This was a PITA...
    # Thanks to "Bulletproof SSL and TLS - Ivan Ristic" for helping me out
    try:
        output, _ = le_util.run_script(
            ["openssl", "ocsp",
            "-no_nonce", "-header", "Host", host,
            "-issuer", chain_path,
            "-cert", cert_path,
github certbot / certbot / letsencrypt-apache / letsencrypt_apache / configurator.py View on Github external
def _reload(self):
        """Reloads the Apache server.

        :raises .errors.MisconfigurationError: If reload fails

        """
        try:
            le_util.run_script(constants.os_constant("restart_cmd"))
        except errors.SubprocessError as err:
            raise errors.MisconfigurationError(str(err))