Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F10011489
D743.id1861.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D743.id1861.diff
View Options
Index: __init__.py
===================================================================
--- /dev/null
+++ __init__.py
@@ -0,0 +1 @@
+""" Deploying certificates to jails plugin """
Index: plugin.py
===================================================================
--- /dev/null
+++ plugin.py
@@ -0,0 +1,168 @@
+"""
+Propagate a Let's encrypt certificate to Mumble
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+Project: Nasqueron
+Created: 2016-05-21
+License: Trivial work, not eligible to copyright
+Dependencies: OpenSSL
+--------------------------------------------------------------
+"""
+
+from certbot import interfaces
+from certbot.plugins import common
+
+""" Common imports """
+import os
+import shutil
+import subprocess
+
+
+logger = logging.getLogger(__name__)
+
+
+@zope.interface.implementer(self, interfaces.IInstaller)
+@zope.interface.provider(self, interfaces.IPluginFactory)
+class Installer(common.Plugin):
+ """Generic Certbot Installer Interface.
+ Represents any server that an X509 certificate can be placed.
+ It is assumed that :func:`save` is the only method that finalizes a
+ checkpoint. This is important to ensure that checkpoints are
+ restored in a consistent manner if requested by the user or in case
+ of an error.
+ Using :class:`certbot.reverter.Reverter` to implement checkpoints,
+ rollback, and recovery can dramatically simplify plugin development.
+ """
+ description = "Copy the certificate to a given path, without keeping permissiosn"
+
+ def __init__(self, path):
+ deploy_cert("", "", path, "", path)
+
+ def get_certdir_path(self):
+ """Full absolute path to SSL configuration file."""
+ return self.config.config_dir
+
+ def prepare(self):
+ """Prepare the plugin.
+ Finish up any additional initialization.
+ :raises .PluginError:
+ when full initialization cannot be completed.
+ :raises .MisconfigurationError:
+ when full initialization cannot be completed. Plugin will
+ be displayed on a list of available plugins.
+ :raises .NoInstallationError:
+ when the necessary programs/files cannot be located. Plugin
+ will NOT be displayed on a list of available plugins.
+ :raises .NotSupportedError:
+ gwhen the installation is recognized, but the version is not
+ currently supported.
+ """
+ pass
+
+ def more_info(self):
+ """Human-readable string to help the user.
+ Should describe the steps taken and any relevant info to help the user
+ decide which plugin to use.
+ :rtype str:
+ """
+ pass
+
+ def get_all_names(self):
+ """Returns all names that may be authenticated.
+ :rtype: `list` of `str`
+ """
+ pass
+
+ @classmethod
+ def add_parser_arguments(cls, add):
+ add("server_root", default=constants.CLI_DEFAULTS["server_root"], help="Path to the service deployed")
+
+ def deploy_cert(self, domain, cert_path, key_path, chain_path, fullchain_path):
+ """Deploy certificate.
+ :param str domain: domain to deploy certificate file
+ :param str cert_path: absolute path to the certificate file
+ :param str key_path: absolute path to the private key file
+ :param str chain_path: absolute path to the certificate chain file
+ :param str fullchain_path: absolute path to the certificate fullchain file (cert plus chain)
+ :raises .PluginError: when cert cannot be deployed
+ """
+ try:
+ copyfile(fullchain_path,self.conf("server_root"))
+ copyfile(key_path,self.conf("server_root"))
+ except (shutil.Error, IOError) as e:
+ print("Cannot deploy certificate:" + str(e))
+ pass
+
+ def enhance(self, domain, enhancement, options=None):
+ """Perform a configuration enhancement.
+ :param str domain: domain for which to provide enhancement
+ :param str enhancement: An enhancement as defined in
+ :const:`~certbot.constants.ENHANCEMENTS`
+ :param options: Flexible options parameter for enhancement.
+ Check documentation of
+ :const:`~certbot.constants.ENHANCEMENTS`
+ for expected options for each enhancement.
+ :raises .PluginError: If Enhancement is not supported, or if
+ an error occurs during the enhancement.
+ """
+ pass
+
+ def supported_enhancements(self):
+ """Returns a list of supported enhancements.
+ :returns: supported enhancements which should be a subset of
+ :const:`~certbot.constants.ENHANCEMENTS`
+ :rtype: :class:`list` of :class:`str`
+ """
+ return "Copy the to the target destination, useful for lxc containers or FreeBSD jails"
+
+ def save(self, title=None, temporary=False):
+ """Saves all changes to the configuration files.
+ Both title and temporary are needed because a save may be
+ intended to be permanent, but the save is not ready to be a full
+ checkpoint.
+ It is assumed that at most one checkpoint is finalized by this
+ method. Additionally, if an exception is raised, it is assumed a
+ new checkpoint was not finalized.
+ :param str title: The title of the save. If a title is given, the
+ configuration will be saved as a new checkpoint and put in a
+ timestamped directory. `title` has no effect if temporary is true.
+ :param bool temporary: Indicates whether the changes made will
+ be quickly reversed in the future (challenges)
+ :raises .PluginError: when save is unsuccessful
+ """
+ pass
+
+ def rollback_checkpoints(self, rollback=1):
+ """Revert `rollback` number of configuration checkpoints.
+ :raises .PluginError: when configuration cannot be fully reverted
+ """
+ pass
+
+ def recovery_routine(self):
+ """Revert configuration to most recent finalized checkpoint.
+ Remove all changes (temporary and permanent) that have not been
+ finalized. This is useful to protect against crashes and other
+ execution interruptions.
+ :raises .errors.PluginError: If unable to recover the configuration
+ """
+ pass
+
+ def view_config_changes(self):
+ """Display all of the LE config changes.
+ :raises .PluginError: when config changes cannot be parsed
+ """
+ pass
+
+ def config_test(self):
+ """Make sure the configuration is valid.
+ :raises .MisconfigurationError: when the config is not in a usable state
+ """
+ pass
+
+ def restart(self):
+ """Restart or refresh the server content.
+ :raises .PluginError: when server cannot be restarted
+ """
+ try:
+ subprocess.call(['service', 'mumble-server', 'restart' ])
+ except OSError as e:
+ print("Restart failed: " + str(e))
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jun 18, 15:28 (19 h, 58 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2744497
Default Alt Text
D743.id1861.diff (6 KB)
Attached To
Mode
D743: Plugin to deploy certificates to an additional path
Attached
Detach File
Event Timeline
Log In to Comment