certbot-dns-route53-1.3.0/0000755000076600000240000000000013627537777015204 5ustar bmwstaff00000000000000certbot-dns-route53-1.3.0/PKG-INFO0000644000076600000240000000240713627537777016304 0ustar bmwstaff00000000000000Metadata-Version: 1.2 Name: certbot-dns-route53 Version: 1.3.0 Summary: Route53 DNS Authenticator plugin for Certbot Home-page: https://github.com/certbot/certbot Author: Certbot Project Author-email: client-dev@letsencrypt.org License: Apache License 2.0 Description: UNKNOWN Keywords: certbot,route53,aws Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Plugins Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Security Classifier: Topic :: System :: Installation/Setup Classifier: Topic :: System :: Networking Classifier: Topic :: System :: Systems Administration Classifier: Topic :: Utilities Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* certbot-dns-route53-1.3.0/tests/0000755000076600000240000000000013627537777016346 5ustar bmwstaff00000000000000certbot-dns-route53-1.3.0/tests/dns_route53_test.py0000644000076600000240000002247713627537724022135 0ustar bmwstaff00000000000000"""Tests for certbot_dns_route53._internal.dns_route53.Authenticator""" import unittest from botocore.exceptions import ClientError from botocore.exceptions import NoCredentialsError import mock from certbot import errors from certbot.compat import os from certbot.plugins import dns_test_common from certbot.plugins.dns_test_common import DOMAIN class AuthenticatorTest(unittest.TestCase, dns_test_common.BaseAuthenticatorTest): # pylint: disable=protected-access def setUp(self): from certbot_dns_route53._internal.dns_route53 import Authenticator super(AuthenticatorTest, self).setUp() self.config = mock.MagicMock() # Set up dummy credentials for testing os.environ["AWS_ACCESS_KEY_ID"] = "dummy_access_key" os.environ["AWS_SECRET_ACCESS_KEY"] = "dummy_secret_access_key" self.auth = Authenticator(self.config, "route53") def tearDown(self): # Remove the dummy credentials from env vars del os.environ["AWS_ACCESS_KEY_ID"] del os.environ["AWS_SECRET_ACCESS_KEY"] super(AuthenticatorTest, self).tearDown() def test_perform(self): self.auth._change_txt_record = mock.MagicMock() self.auth._wait_for_change = mock.MagicMock() self.auth.perform([self.achall]) self.auth._change_txt_record.assert_called_once_with("UPSERT", '_acme-challenge.' + DOMAIN, mock.ANY) self.assertEqual(self.auth._wait_for_change.call_count, 1) def test_perform_no_credentials_error(self): self.auth._change_txt_record = mock.MagicMock(side_effect=NoCredentialsError) self.assertRaises(errors.PluginError, self.auth.perform, [self.achall]) def test_perform_client_error(self): self.auth._change_txt_record = mock.MagicMock( side_effect=ClientError({"Error": {"Code": "foo"}}, "bar")) self.assertRaises(errors.PluginError, self.auth.perform, [self.achall]) def test_cleanup(self): self.auth._attempt_cleanup = True self.auth._change_txt_record = mock.MagicMock() self.auth.cleanup([self.achall]) self.auth._change_txt_record.assert_called_once_with("DELETE", '_acme-challenge.'+DOMAIN, mock.ANY) def test_cleanup_no_credentials_error(self): self.auth._attempt_cleanup = True self.auth._change_txt_record = mock.MagicMock(side_effect=NoCredentialsError) self.auth.cleanup([self.achall]) def test_cleanup_client_error(self): self.auth._attempt_cleanup = True self.auth._change_txt_record = mock.MagicMock( side_effect=ClientError({"Error": {"Code": "foo"}}, "bar")) self.auth.cleanup([self.achall]) class ClientTest(unittest.TestCase): # pylint: disable=protected-access PRIVATE_ZONE = { "Id": "BAD-PRIVATE", "Name": "example.com", "Config": { "PrivateZone": True } } EXAMPLE_NET_ZONE = { "Id": "BAD-WRONG-TLD", "Name": "example.net", "Config": { "PrivateZone": False } } EXAMPLE_COM_ZONE = { "Id": "EXAMPLE", "Name": "example.com", "Config": { "PrivateZone": False } } FOO_EXAMPLE_COM_ZONE = { "Id": "FOO", "Name": "foo.example.com", "Config": { "PrivateZone": False } } def setUp(self): from certbot_dns_route53._internal.dns_route53 import Authenticator super(ClientTest, self).setUp() self.config = mock.MagicMock() # Set up dummy credentials for testing os.environ["AWS_ACCESS_KEY_ID"] = "dummy_access_key" os.environ["AWS_SECRET_ACCESS_KEY"] = "dummy_secret_access_key" self.client = Authenticator(self.config, "route53") def tearDown(self): # Remove the dummy credentials from env vars del os.environ["AWS_ACCESS_KEY_ID"] del os.environ["AWS_SECRET_ACCESS_KEY"] super(ClientTest, self).tearDown() def test_find_zone_id_for_domain(self): self.client.r53.get_paginator = mock.MagicMock() self.client.r53.get_paginator().paginate.return_value = [ { "HostedZones": [ self.EXAMPLE_NET_ZONE, self.EXAMPLE_COM_ZONE, ] } ] result = self.client._find_zone_id_for_domain("foo.example.com") self.assertEqual(result, "EXAMPLE") def test_find_zone_id_for_domain_pagination(self): self.client.r53.get_paginator = mock.MagicMock() self.client.r53.get_paginator().paginate.return_value = [ { "HostedZones": [ self.PRIVATE_ZONE, self.EXAMPLE_COM_ZONE, ] }, { "HostedZones": [ self.PRIVATE_ZONE, self.FOO_EXAMPLE_COM_ZONE, ] } ] result = self.client._find_zone_id_for_domain("foo.example.com") self.assertEqual(result, "FOO") def test_find_zone_id_for_domain_no_results(self): self.client.r53.get_paginator = mock.MagicMock() self.client.r53.get_paginator().paginate.return_value = [] self.assertRaises(errors.PluginError, self.client._find_zone_id_for_domain, "foo.example.com") def test_find_zone_id_for_domain_no_correct_results(self): self.client.r53.get_paginator = mock.MagicMock() self.client.r53.get_paginator().paginate.return_value = [ { "HostedZones": [ self.PRIVATE_ZONE, self.EXAMPLE_NET_ZONE, ] }, ] self.assertRaises(errors.PluginError, self.client._find_zone_id_for_domain, "foo.example.com") def test_change_txt_record(self): self.client._find_zone_id_for_domain = mock.MagicMock() self.client.r53.change_resource_record_sets = mock.MagicMock( return_value={"ChangeInfo": {"Id": 1}}) self.client._change_txt_record("FOO", DOMAIN, "foo") call_count = self.client.r53.change_resource_record_sets.call_count self.assertEqual(call_count, 1) def test_change_txt_record_delete(self): self.client._find_zone_id_for_domain = mock.MagicMock() self.client.r53.change_resource_record_sets = mock.MagicMock( return_value={"ChangeInfo": {"Id": 1}}) validation = "some-value" validation_record = {"Value": '"{0}"'.format(validation)} self.client._resource_records[DOMAIN] = [validation_record] self.client._change_txt_record("DELETE", DOMAIN, validation) call_count = self.client.r53.change_resource_record_sets.call_count self.assertEqual(call_count, 1) call_args = self.client.r53.change_resource_record_sets.call_args_list[0][1] call_args_batch = call_args["ChangeBatch"]["Changes"][0] self.assertEqual(call_args_batch["Action"], "DELETE") self.assertEqual( call_args_batch["ResourceRecordSet"]["ResourceRecords"], [validation_record]) def test_change_txt_record_multirecord(self): self.client._find_zone_id_for_domain = mock.MagicMock() self.client._get_validation_rrset = mock.MagicMock() self.client._resource_records[DOMAIN] = [ {"Value": "\"pre-existing-value\""}, {"Value": "\"pre-existing-value-two\""}, ] self.client.r53.change_resource_record_sets = mock.MagicMock( return_value={"ChangeInfo": {"Id": 1}}) self.client._change_txt_record("DELETE", DOMAIN, "pre-existing-value") call_count = self.client.r53.change_resource_record_sets.call_count call_args = self.client.r53.change_resource_record_sets.call_args_list[0][1] call_args_batch = call_args["ChangeBatch"]["Changes"][0] self.assertEqual(call_args_batch["Action"], "UPSERT") self.assertEqual( call_args_batch["ResourceRecordSet"]["ResourceRecords"], [{"Value": "\"pre-existing-value-two\""}]) self.assertEqual(call_count, 1) def test_wait_for_change(self): self.client.r53.get_change = mock.MagicMock( side_effect=[{"ChangeInfo": {"Status": "PENDING"}}, {"ChangeInfo": {"Status": "INSYNC"}}]) self.client._wait_for_change(1) self.assertTrue(self.client.r53.get_change.called) if __name__ == "__main__": unittest.main() # pragma: no cover certbot-dns-route53-1.3.0/MANIFEST.in0000644000076600000240000000021213627537724016725 0ustar bmwstaff00000000000000include LICENSE.txt include README recursive-include docs * recursive-include tests * global-exclude __pycache__ global-exclude *.py[cod] certbot-dns-route53-1.3.0/docs/0000755000076600000240000000000013627537777016134 5ustar bmwstaff00000000000000certbot-dns-route53-1.3.0/docs/index.rst0000644000076600000240000000106113627537724017763 0ustar bmwstaff00000000000000.. certbot-dns-route53 documentation master file, created by sphinx-quickstart on Fri Jun 9 11:45:30 2017. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Welcome to certbot-dns-route53's documentation! =============================================== .. toctree:: :maxdepth: 2 :caption: Contents: .. automodule:: certbot_dns_route53 :members: .. toctree:: :maxdepth: 1 api Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` certbot-dns-route53-1.3.0/docs/Makefile0000644000076600000240000000115013627537724017561 0ustar bmwstaff00000000000000# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build SPHINXPROJ = certbot-dns-route53 SOURCEDIR = . BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)certbot-dns-route53-1.3.0/docs/conf.py0000644000076600000240000001325213627537724017426 0ustar bmwstaff00000000000000# -*- coding: utf-8 -*- # # certbot-dns-route53 documentation build configuration file, created by # sphinx-quickstart on Fri Jun 9 11:45:30 2017. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # import os # import sys # sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.viewcode'] autodoc_member_order = 'bysource' autodoc_default_flags = ['show-inheritance'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General information about the project. project = u'certbot-dns-route53' copyright = u'2017, Certbot Project' author = u'Certbot Project' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = u'0' # The full version, including alpha/beta/rc tags. release = u'0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] default_role = 'py:obj' # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # # http://docs.readthedocs.org/en/latest/theme.html#how-do-i-use-this-locally-and-on-read-the-docs # on_rtd is whether we are on readthedocs.org on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if not on_rtd: # only import and set the theme if we're building docs locally import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # otherwise, readthedocs.org uses their theme by default, so no need to specify it # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. htmlhelp_basename = 'certbot-dns-route53doc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'certbot-dns-route53.tex', u'certbot-dns-route53 Documentation', u'Certbot Project', 'manual'), ] # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'certbot-dns-route53', u'certbot-dns-route53 Documentation', [author], 1) ] # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'certbot-dns-route53', u'certbot-dns-route53 Documentation', author, 'certbot-dns-route53', 'One line description of project.', 'Miscellaneous'), ] # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { 'python': ('https://docs.python.org/', None), 'acme': ('https://acme-python.readthedocs.org/en/latest/', None), 'certbot': ('https://certbot.eff.org/docs/', None), } certbot-dns-route53-1.3.0/docs/make.bat0000644000076600000240000000146713627537724017541 0ustar bmwstaff00000000000000@ECHO OFF pushd %~dp0 REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set SOURCEDIR=. set BUILDDIR=_build set SPHINXPROJ=certbot-dns-route53 if "%1" == "" goto help %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% goto end :help %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% :end popd certbot-dns-route53-1.3.0/docs/.gitignore0000644000076600000240000000001113627537724020104 0ustar bmwstaff00000000000000/_build/ certbot-dns-route53-1.3.0/docs/api.rst0000644000076600000240000000022513627537724017426 0ustar bmwstaff00000000000000================= API Documentation ================= Certbot plugins implement the Certbot plugins API, and do not otherwise have an external API. certbot-dns-route53-1.3.0/README.md0000644000076600000240000000201313627537724016447 0ustar bmwstaff00000000000000## Route53 plugin for Let's Encrypt client ### Before you start It's expected that the root hosted zone for the domain in question already exists in your account. ### Setup 1. Create a virtual environment 2. Update its pip and setuptools (`VENV/bin/pip install -U setuptools pip`) to avoid problems with cryptography's dependency on setuptools>=11.3. 3. Make sure you have libssl-dev and libffi (or your regional equivalents) installed. You might have to set compiler flags to pick things up (I have to use `CPPFLAGS=-I/usr/local/opt/openssl/include LDFLAGS=-L/usr/local/opt/openssl/lib` on my macOS to pick up brew's openssl, for example). 4. Install this package. ### How to use it Make sure you have access to AWS's Route53 service, either through IAM roles or via `.aws/credentials`. Check out [sample-aws-policy.json](examples/sample-aws-policy.json) for the necessary permissions. To generate a certificate: ``` certbot certonly \ -n --agree-tos --email DEVOPS@COMPANY.COM \ --dns-route53 \ -d MY.DOMAIN.NAME ``` certbot-dns-route53-1.3.0/setup.py0000644000076600000240000000467613627537726016725 0ustar bmwstaff00000000000000import sys from setuptools import find_packages from setuptools import setup from setuptools.command.test import test as TestCommand version = '1.3.0' # Remember to update local-oldest-requirements.txt when changing the minimum # acme/certbot version. install_requires = [ 'acme>=0.29.0', 'certbot>=1.1.0', 'boto3', 'mock', 'setuptools', 'zope.interface', ] class PyTest(TestCommand): user_options = [] def initialize_options(self): TestCommand.initialize_options(self) self.pytest_args = '' def run_tests(self): import shlex # import here, cause outside the eggs aren't loaded import pytest errno = pytest.main(shlex.split(self.pytest_args)) sys.exit(errno) setup( name='certbot-dns-route53', version=version, description="Route53 DNS Authenticator plugin for Certbot", url='https://github.com/certbot/certbot', author="Certbot Project", author_email='client-dev@letsencrypt.org', license='Apache License 2.0', python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Plugins', 'Intended Audience :: System Administrators', 'License :: OSI Approved :: Apache Software License', 'Operating System :: POSIX :: Linux', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Security', 'Topic :: System :: Installation/Setup', 'Topic :: System :: Networking', 'Topic :: System :: Systems Administration', 'Topic :: Utilities', ], packages=find_packages(), include_package_data=True, install_requires=install_requires, keywords=['certbot', 'route53', 'aws'], entry_points={ 'certbot.plugins': [ 'dns-route53 = certbot_dns_route53._internal.dns_route53:Authenticator', 'certbot-route53:auth = certbot_dns_route53.authenticator:Authenticator' ], }, tests_require=["pytest"], test_suite='certbot_dns_route53', cmdclass={"test": PyTest}, ) certbot-dns-route53-1.3.0/setup.cfg0000644000076600000240000000010313627537777017017 0ustar bmwstaff00000000000000[bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 certbot-dns-route53-1.3.0/LICENSE.txt0000644000076600000240000002613513627537724017026 0ustar bmwstaff00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. certbot-dns-route53-1.3.0/certbot_dns_route53.egg-info/0000755000076600000240000000000013627537777022572 5ustar bmwstaff00000000000000certbot-dns-route53-1.3.0/certbot_dns_route53.egg-info/PKG-INFO0000644000076600000240000000240713627537777023672 0ustar bmwstaff00000000000000Metadata-Version: 1.2 Name: certbot-dns-route53 Version: 1.3.0 Summary: Route53 DNS Authenticator plugin for Certbot Home-page: https://github.com/certbot/certbot Author: Certbot Project Author-email: client-dev@letsencrypt.org License: Apache License 2.0 Description: UNKNOWN Keywords: certbot,route53,aws Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Plugins Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Security Classifier: Topic :: System :: Installation/Setup Classifier: Topic :: System :: Networking Classifier: Topic :: System :: Systems Administration Classifier: Topic :: Utilities Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.* certbot-dns-route53-1.3.0/certbot_dns_route53.egg-info/SOURCES.txt0000644000076600000240000000110313627537777024451 0ustar bmwstaff00000000000000LICENSE.txt MANIFEST.in README.md setup.cfg setup.py certbot_dns_route53/__init__.py certbot_dns_route53/authenticator.py certbot_dns_route53.egg-info/PKG-INFO certbot_dns_route53.egg-info/SOURCES.txt certbot_dns_route53.egg-info/dependency_links.txt certbot_dns_route53.egg-info/entry_points.txt certbot_dns_route53.egg-info/requires.txt certbot_dns_route53.egg-info/top_level.txt certbot_dns_route53/_internal/__init__.py certbot_dns_route53/_internal/dns_route53.py docs/.gitignore docs/Makefile docs/api.rst docs/conf.py docs/index.rst docs/make.bat tests/dns_route53_test.pycertbot-dns-route53-1.3.0/certbot_dns_route53.egg-info/entry_points.txt0000644000076600000240000000024013627537777026064 0ustar bmwstaff00000000000000[certbot.plugins] certbot-route53:auth = certbot_dns_route53.authenticator:Authenticator dns-route53 = certbot_dns_route53._internal.dns_route53:Authenticator certbot-dns-route53-1.3.0/certbot_dns_route53.egg-info/requires.txt0000644000076600000240000000010113627537777025162 0ustar bmwstaff00000000000000acme>=0.29.0 certbot>=1.1.0 boto3 mock setuptools zope.interface certbot-dns-route53-1.3.0/certbot_dns_route53.egg-info/top_level.txt0000644000076600000240000000002413627537777025320 0ustar bmwstaff00000000000000certbot_dns_route53 certbot-dns-route53-1.3.0/certbot_dns_route53.egg-info/dependency_links.txt0000644000076600000240000000000113627537777026640 0ustar bmwstaff00000000000000 certbot-dns-route53-1.3.0/certbot_dns_route53/0000755000076600000240000000000013627537777021100 5ustar bmwstaff00000000000000certbot-dns-route53-1.3.0/certbot_dns_route53/_internal/0000755000076600000240000000000013627537777023053 5ustar bmwstaff00000000000000certbot-dns-route53-1.3.0/certbot_dns_route53/_internal/dns_route53.py0000644000076600000240000001346313627537724025576 0ustar bmwstaff00000000000000"""Certbot Route53 authenticator plugin.""" import collections import logging import time import boto3 from botocore.exceptions import ClientError from botocore.exceptions import NoCredentialsError import zope.interface from acme.magic_typing import DefaultDict from acme.magic_typing import Dict from acme.magic_typing import List from certbot import errors from certbot import interfaces from certbot.plugins import dns_common logger = logging.getLogger(__name__) INSTRUCTIONS = ( "To use certbot-dns-route53, configure credentials as described at " "https://boto3.readthedocs.io/en/latest/guide/configuration.html#best-practices-for-configuring-credentials " # pylint: disable=line-too-long "and add the necessary permissions for Route53 access.") @zope.interface.implementer(interfaces.IAuthenticator) @zope.interface.provider(interfaces.IPluginFactory) class Authenticator(dns_common.DNSAuthenticator): """Route53 Authenticator This authenticator solves a DNS01 challenge by uploading the answer to AWS Route53. """ description = ("Obtain certificates using a DNS TXT record (if you are using AWS Route53 for " "DNS).") ttl = 10 def __init__(self, *args, **kwargs): super(Authenticator, self).__init__(*args, **kwargs) self.r53 = boto3.client("route53") self._resource_records = collections.defaultdict(list) # type: DefaultDict[str, List[Dict[str, str]]] def more_info(self): # pylint: disable=missing-function-docstring return "Solve a DNS01 challenge using AWS Route53" def _setup_credentials(self): pass def _perform(self, domain, validation_name, validation): pass def perform(self, achalls): self._attempt_cleanup = True try: change_ids = [ self._change_txt_record("UPSERT", achall.validation_domain_name(achall.domain), achall.validation(achall.account_key)) for achall in achalls ] for change_id in change_ids: self._wait_for_change(change_id) except (NoCredentialsError, ClientError) as e: logger.debug('Encountered error during perform: %s', e, exc_info=True) raise errors.PluginError("\n".join([str(e), INSTRUCTIONS])) return [achall.response(achall.account_key) for achall in achalls] def _cleanup(self, domain, validation_name, validation): try: self._change_txt_record("DELETE", validation_name, validation) except (NoCredentialsError, ClientError) as e: logger.debug('Encountered error during cleanup: %s', e, exc_info=True) def _find_zone_id_for_domain(self, domain): """Find the zone id responsible a given FQDN. That is, the id for the zone whose name is the longest parent of the domain. """ paginator = self.r53.get_paginator("list_hosted_zones") zones = [] target_labels = domain.rstrip(".").split(".") for page in paginator.paginate(): for zone in page["HostedZones"]: if zone["Config"]["PrivateZone"]: continue candidate_labels = zone["Name"].rstrip(".").split(".") if candidate_labels == target_labels[-len(candidate_labels):]: zones.append((zone["Name"], zone["Id"])) if not zones: raise errors.PluginError( "Unable to find a Route53 hosted zone for {0}".format(domain) ) # Order the zones that are suffixes for our desired to domain by # length, this puts them in an order like: # ["foo.bar.baz.com", "bar.baz.com", "baz.com", "com"] # And then we choose the first one, which will be the most specific. zones.sort(key=lambda z: len(z[0]), reverse=True) return zones[0][1] def _change_txt_record(self, action, validation_domain_name, validation): zone_id = self._find_zone_id_for_domain(validation_domain_name) rrecords = self._resource_records[validation_domain_name] challenge = {"Value": '"{0}"'.format(validation)} if action == "DELETE": # Remove the record being deleted from the list of tracked records rrecords.remove(challenge) if rrecords: # Need to update instead, as we're not deleting the rrset action = "UPSERT" else: # Create a new list containing the record to use with DELETE rrecords = [challenge] else: rrecords.append(challenge) response = self.r53.change_resource_record_sets( HostedZoneId=zone_id, ChangeBatch={ "Comment": "certbot-dns-route53 certificate validation " + action, "Changes": [ { "Action": action, "ResourceRecordSet": { "Name": validation_domain_name, "Type": "TXT", "TTL": self.ttl, "ResourceRecords": rrecords, } } ] } ) return response["ChangeInfo"]["Id"] def _wait_for_change(self, change_id): """Wait for a change to be propagated to all Route53 DNS servers. https://docs.aws.amazon.com/Route53/latest/APIReference/API_GetChange.html """ for unused_n in range(0, 120): response = self.r53.get_change(Id=change_id) if response["ChangeInfo"]["Status"] == "INSYNC": return time.sleep(5) raise errors.PluginError( "Timed out waiting for Route53 change. Current status: %s" % response["ChangeInfo"]["Status"]) certbot-dns-route53-1.3.0/certbot_dns_route53/_internal/__init__.py0000644000076600000240000000011413627537724025150 0ustar bmwstaff00000000000000"""Internal implementation of `~certbot_dns_route53.dns_route53` plugin.""" certbot-dns-route53-1.3.0/certbot_dns_route53/authenticator.py0000644000076600000240000000133513627537724024316 0ustar bmwstaff00000000000000"""Shim around `~certbot_dns_route53._internal.dns_route53` for backwards compatibility.""" import warnings import zope.interface from certbot import interfaces from certbot_dns_route53._internal import dns_route53 @zope.interface.implementer(interfaces.IAuthenticator) @zope.interface.provider(interfaces.IPluginFactory) class Authenticator(dns_route53.Authenticator): """Shim around `~certbot_dns_route53._internal.dns_route53.Authenticator` for backwards compatibility.""" hidden = True def __init__(self, *args, **kwargs): warnings.warn("The 'authenticator' module was renamed 'dns_route53'", DeprecationWarning) super(Authenticator, self).__init__(*args, **kwargs) certbot-dns-route53-1.3.0/certbot_dns_route53/__init__.py0000644000076600000240000001002313627537724023175 0ustar bmwstaff00000000000000""" The `~certbot_dns_route53.dns_route53` plugin automates the process of completing a ``dns-01`` challenge (`~acme.challenges.DNS01`) by creating, and subsequently removing, TXT records using the Amazon Web Services Route 53 API. Named Arguments --------------- ======================================== ===================================== ``--dns-route53-propagation-seconds`` The number of seconds to wait for DNS to propagate before asking the ACME server to verify the DNS record. (Default: 10) ======================================== ===================================== Credentials ----------- Use of this plugin requires a configuration file containing Amazon Web Sevices API credentials for an account with the following permissions: * ``route53:ListHostedZones`` * ``route53:GetChange`` * ``route53:ChangeResourceRecordSets`` These permissions can be captured in an AWS policy like the one below. Amazon provides `information about managing access `_ and `information about the required permissions `_ .. code-block:: json :name: sample-aws-policy.json :caption: Example AWS policy file: { "Version": "2012-10-17", "Id": "certbot-dns-route53 sample policy", "Statement": [ { "Effect": "Allow", "Action": [ "route53:ListHostedZones", "route53:GetChange" ], "Resource": [ "*" ] }, { "Effect" : "Allow", "Action" : [ "route53:ChangeResourceRecordSets" ], "Resource" : [ "arn:aws:route53:::hostedzone/YOURHOSTEDZONEID" ] } ] } The `access keys `_ for an account with these permissions must be supplied in one of the following ways, which are discussed in more detail in the Boto3 library's documentation about `configuring credentials `_. * Using the ``AWS_ACCESS_KEY_ID`` and ``AWS_SECRET_ACCESS_KEY`` environment variables. * Using a credentials configuration file at the default location, ``~/.aws/config``. * Using a credentials configuration file at a path supplied using the ``AWS_CONFIG_FILE`` environment variable. .. code-block:: ini :name: config.ini :caption: Example credentials config file: [default] aws_access_key_id=AKIAIOSFODNN7EXAMPLE aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY .. caution:: You should protect these API credentials as you would a password. Users who can read this file can use these credentials to issue some types of API calls on your behalf, limited by the permissions assigned to the account. Users who can cause Certbot to run using these credentials can complete a ``dns-01`` challenge to acquire new certificates or revoke existing certificates for domains these credentials are authorized to manage. Examples -------- .. code-block:: bash :caption: To acquire a certificate for ``example.com`` certbot certonly \\ --dns-route53 \\ -d example.com .. code-block:: bash :caption: To acquire a single certificate for both ``example.com`` and ``www.example.com`` certbot certonly \\ --dns-route53 \\ -d example.com \\ -d www.example.com .. code-block:: bash :caption: To acquire a certificate for ``example.com``, waiting 30 seconds for DNS propagation certbot certonly \\ --dns-route53 \\ --dns-route53-propagation-seconds 30 \\ -d example.com """