a }|g<@sdZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZzddlmZWneyeZYn0e rddlmZGdddedZGdddedZGdddeZ GdddeZ!GdddedZ"GdddedZ#Gd d!d!edZ$Gd"d#d#eZ%Gd$d%d%eZ&Gd&d'd'e&Z'Gd(d)d)e&Z(d*S)+zCertbot client interfaces.)ABCMeta)abstractmethod)ArgumentParser)Any)Iterable)List)Optional)Type) TYPE_CHECKING)Union) Challenge)ChallengeResponse)ClientV2) configuration)AnnotatedChallenge) Interface)Accountc@sPeZdZdZeeddddZeeddddZede d d d d Z d S) AccountStoragezAccounts storage interface.rreturncCs tdS)zXFind all accounts. :returns: All found accounts. :rtype: list NNotImplementedErrorselfr6/usr/lib/python3.9/site-packages/certbot/interfaces.pyfind_allszAccountStorage.find_all) account_idrcCs tdS)zLoad an account by its id. :raises .AccountNotFound: if account could not be found :raises .AccountStorageError: if account could not be loaded :returns: The account loaded :rtype: .Account Nr)rrrrrload)s zAccountStorage.loadN)accountclientrcCs tdS)z\Save account. :raises .AccountStorageError: if account could not be saved Nr)rrr rrrsave6szAccountStorage.save) __name__ __module__ __qualname____doc__rrrstrrrr!rrrrrs  r) metaclasscseZdZUdZeZeed<eZeed<e e e j eddfdd Z e ddd d Ze edd d Zee eedd ddZZS)Plugina-Certbot plugin. Objects providing this interface will be called without satisfying any entry point "extras" (extra dependencies) you might have defined for your plugin, e.g (excerpt from ``setup.py`` script):: setup( ... entry_points={ 'certbot.plugins': [ 'name=example_project.plugin[plugin_deps]', ], }, extras_require={ 'plugin_deps': ['dep1', 'dep2'], } ) Therefore, make sure such objects are importable and usable without extras. This is necessary, because CLI does the following operations (in order): - loads an entry point, - calls `inject_parser_options`, - requires an entry point, - creates plugin instance (`__call__`). descriptionnameN)configr*rcstdS)zCreate a new `Plugin`. :param configuration.NamespaceConfig config: Configuration. :param str name: Unique plugin name. N)super__init__)rr+r* __class__rrr-dszPlugin.__init__rcCsdS)aPrepare 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: when the installation is recognized, but the version is not currently supported. NrrrrrpreparenszPlugin.preparecCsdS)zHuman-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: Nrrrrr more_infoszPlugin.more_info)parserr*rcCsdS)aInject argument parser options (flags). 1. Be nice and prepend all options and destinations with `~.common.option_namespace` and `~common.dest_namespace`. 2. Inject options (flags) only. Positional arguments are not allowed, as this would break the CLI. :param ArgumentParser parser: (Almost) top-level CLI parser. :param str name: Unique plugin name. Nr)clsr2r*rrrinject_parser_optionsszPlugin.inject_parser_options)r"r#r$r%NotImplementedr)r&__annotations__r*rrrZNamespaceConfigr-r0r1 classmethodrr4 __classcell__rrr.rr(@s     r(c@s`eZdZdZeeeeedddZ ee e e e dddZ ee e ddd d ZdS) AuthenticatorzGeneric Certbot Authenticator. Class represents all possible tools processes that have the ability to perform challenges and attain a certificate. )domainrcCsdS)aReturn `collections.Iterable` of challenge preferences. :param str domain: Domain for which challenge preferences are sought. :returns: `collections.Iterable` of challenge types (subclasses of :class:`acme.challenges.Challenge`) with the most preferred challenges first. If a type is not specified, it means the Authenticator cannot perform the challenge. :rtype: `collections.Iterable` Nr)rr:rrrget_chall_prefszAuthenticator.get_chall_pref)achallsrcCsdS)aPerform the given challenge. :param list achalls: Non-empty (guaranteed) list of :class:`~certbot.achallenges.AnnotatedChallenge` instances, such that it contains types found within :func:`get_chall_pref` only. :returns: list of ACME :class:`~acme.challenges.ChallengeResponse` instances corresponding to each provided :class:`~acme.challenges.Challenge`. :rtype: :class:`collections.List` of :class:`acme.challenges.ChallengeResponse`, where responses are required to be returned in the same order as corresponding input challenges :raises .PluginError: If some or all challenges cannot be performed Nrrr<rrrperformszAuthenticator.performNcCsdS)aRevert changes and shutdown after challenges complete. This method should be able to revert all changes made by perform, even if perform exited abnormally. :param list achalls: Non-empty (guaranteed) list of :class:`~certbot.achallenges.AnnotatedChallenge` instances, a subset of those previously passed to :func:`perform`. :raises PluginError: if original configuration cannot be restored Nrr=rrrcleanupszAuthenticator.cleanup)r"r#r$r%rr&rr r r;rrr r>r?rrrrr9s r9c@seZdZdZeeedddZeeeeeeddddZedeee e e eefdd d d Z ee edd d Z ede eeddddZededdddZeddddZeddddZeddddZdS) InstalleraGeneric 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. rcCsdS)zgReturns all names that may be authenticated. :rtype: `collections.Iterable` of `str` Nrrrrr get_all_namesszInstaller.get_all_namesN)r: cert_pathkey_path chain_pathfullchain_pathrcCsdS)aDeploy 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 Nr)rr:rBrCrDrErrr deploy_certszInstaller.deploy_cert)r: enhancementoptionsrcCsdS)aGPerform a configuration enhancement. :param str domain: domain for which to provide enhancement :param str enhancement: An enhancement as defined in :const:`~certbot.plugins.enhancements.ENHANCEMENTS` :param options: Flexible options parameter for enhancement. Check documentation of :const:`~certbot.plugins.enhancements.ENHANCEMENTS` for expected options for each enhancement. :raises .PluginError: If Enhancement is not supported, or if an error occurs during the enhancement. Nr)rr:rGrHrrrenhanceszInstaller.enhancecCsdS)a Returns a `collections.Iterable` of supported enhancements. :returns: supported enhancements which should be a subset of :const:`~certbot.plugins.enhancements.ENHANCEMENTS` :rtype: :class:`collections.Iterable` of :class:`str` Nrrrrrsupported_enhancementssz Installer.supported_enhancementsF)title temporaryrcCsdS)a1Saves 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 Nr)rrKrLrrrr!szInstaller.save)rollbackrcCsdS)zRevert `rollback` number of configuration checkpoints. :raises .PluginError: when configuration cannot be fully reverted Nr)rrNrrrrollback_checkpoints3szInstaller.rollback_checkpointscCsdS)aARevert 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 Nrrrrrrecovery_routine;szInstaller.recovery_routinecCsdS)zMake sure the configuration is valid. :raises .MisconfigurationError: when the config is not in a usable state Nrrrrr config_testGszInstaller.config_testcCsdS)zoRestart or refresh the server content. :raises .PluginError: when server cannot be restarted NrrrrrrestartOszInstaller.restart)N)NF)rM)r"r#r$r%rrr&rArFrr rrIrJboolr!intrOrPrQrRrrrrr@s0  r@c@seZdZdZeeedddZeeedddZeeedddZ eeedd d Z eeedd d Z ee edd dZ dS) RenewableCertz#Interface to a certificate lineage.rcCsdS)zs@                  $^;G