pax_global_header00006660000000000000000000000064150760261360014520gustar00rootroot0000000000000052 comment=c82ebf311f815b9924be54e2ef44bb2c426ce9d6 coldfix-certbot-dns-netcup-c82ebf3/000077500000000000000000000000001507602613600173645ustar00rootroot00000000000000coldfix-certbot-dns-netcup-c82ebf3/.dockerignore000066400000000000000000000004371507602613600220440ustar00rootroot00000000000000# Python binaries *.py[cod] CHANGES # C extensions *.so # Packages *.egg *.egg-info dist build eggs parts bin var sdist develop-eggs .installed.cfg lib lib64 __pycache__ MANIFEST # Installer logs pip-log.txt # Unit test / coverage reports .coverage .tox nosetests.xml .git workdir coldfix-certbot-dns-netcup-c82ebf3/.github/000077500000000000000000000000001507602613600207245ustar00rootroot00000000000000coldfix-certbot-dns-netcup-c82ebf3/.github/dependabot.yml000066400000000000000000000003161507602613600235540ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: "pip" directory: "/" schedule: interval: "weekly" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" coldfix-certbot-dns-netcup-c82ebf3/.github/workflows/000077500000000000000000000000001507602613600227615ustar00rootroot00000000000000coldfix-certbot-dns-netcup-c82ebf3/.github/workflows/publish.yml000066400000000000000000000060711507602613600251560ustar00rootroot00000000000000name: Build and publish on: push: pull_request: jobs: build: name: Build and check package runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: actions/setup-python@v6 with: {python-version: 3.x} - run: pip install wheel twine flake8 setuptools - run: flake8 - run: python setup.py sdist bdist_wheel - run: twine check dist/* - uses: actions/upload-artifact@v4 with: {name: dist, path: dist/} pypi: name: Upload to pypi.org needs: build runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags') permissions: id-token: write steps: - uses: actions/download-artifact@v5 with: {name: dist, path: dist/} - uses: pypa/gh-action-pypi-publish@release/v1 docker: name: Upload to hub.docker.com runs-on: ubuntu-latest steps: - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 if: github.event_name != 'pull_request' with: username: coldfix password: ${{ secrets.DOCKERHUB_TOKEN }} - uses: docker/build-push-action@v6 with: platforms: linux/amd64 build-args: FROM=certbot/certbot:latest load: true tags: | coldfix/certbot-dns-netcup:amd64-latest coldfix/certbot-dns-netcup:amd64-${{ github.ref_name }} - uses: docker/build-push-action@v6 with: platforms: linux/arm64 build-args: FROM=certbot/certbot:arm64v8-latest load: true tags: | coldfix/certbot-dns-netcup:arm64-latest coldfix/certbot-dns-netcup:arm64-${{ github.ref_name }} # push multi-arch images: - run: docker push -a coldfix/certbot-dns-netcup if: startsWith(github.ref, 'refs/tags/v') - run: docker manifest create coldfix/certbot-dns-netcup:latest coldfix/certbot-dns-netcup:amd64-latest coldfix/certbot-dns-netcup:arm64-latest if: startsWith(github.ref, 'refs/tags/v') - run: docker manifest push coldfix/certbot-dns-netcup:latest if: startsWith(github.ref, 'refs/tags/v') - run: docker manifest create coldfix/certbot-dns-netcup:${{ github.ref_name }} coldfix/certbot-dns-netcup:amd64-${{ github.ref_name }} coldfix/certbot-dns-netcup:arm64-${{ github.ref_name }} if: startsWith(github.ref, 'refs/tags/v') - run: docker manifest push coldfix/certbot-dns-netcup:${{ github.ref_name }} if: startsWith(github.ref, 'refs/tags/v') snap: name: Upload to snapcraft.io runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: snapcore/action-build@v1 id: build - uses: snapcore/action-publish@v1 if: startsWith(github.ref, 'refs/tags/v') env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} with: snap: ${{ steps.build.outputs.snap }} release: stable coldfix-certbot-dns-netcup-c82ebf3/.gitignore000066400000000000000000000004301507602613600213510ustar00rootroot00000000000000# Python binaries *.py[cod] CHANGES # C extensions *.so # Packages *.egg *.egg-info dist build eggs parts bin var sdist develop-eggs .installed.cfg lib lib64 __pycache__ MANIFEST # Installer logs pip-log.txt # Unit test / coverage reports .coverage .tox nosetests.xml *.snap coldfix-certbot-dns-netcup-c82ebf3/Dockerfile000066400000000000000000000002441507602613600213560ustar00rootroot00000000000000ARG FROM=certbot/certbot FROM ${FROM} COPY . src/certbot-dns-netcup RUN pip install --no-cache-dir --editable src/certbot-dns-netcup ENTRYPOINT ["/usr/bin/env"] coldfix-certbot-dns-netcup-c82ebf3/LICENSE.txt000066400000000000000000000250421507602613600212120ustar00rootroot00000000000000 Copyright 2015 Electronic Frontier Foundation and others 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. 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 coldfix-certbot-dns-netcup-c82ebf3/MANIFEST.in000066400000000000000000000000471507602613600211230ustar00rootroot00000000000000include LICENSE.txt include README.rst coldfix-certbot-dns-netcup-c82ebf3/README.rst000066400000000000000000000155741507602613600210670ustar00rootroot00000000000000certbot-dns-netcup ================== |Version| |License| |ImageSize| netcup_ DNS Authenticator plugin for certbot_. This plugin automates the process of completing a ``dns-01`` challenge by creating, and subsequently removing, ``TXT`` records using the netcup `CCP API`_ via nc_dnsapi_. **Note:** This plugin requires certbot ≥ v2.7. If you need support for older certbot versions, check version 1.4.X and below. .. _netcup: https://www.netcup.de/ .. _certbot: https://certbot.eff.org/ .. _CCP API: https://www.netcup-wiki.de/wiki/CCP_API .. _nc_dnsapi: https://github.com/nbuchwitz/nc_dnsapi .. _certbot-dns-cloudflare: https://certbot-dns-cloudflare.readthedocs.io/en/latest/ Installation ------------ Since this package acts as a plugin for certbot_, the installation method can vary depending on how certbot is installed. pip ~~~ If certbot is installed normally as a python package, the plugin can be installed using:: pip install certbot-dns-netcup snap ~~~~ If certbot is installed as a snap, you'll have to install this plugin as follows:: sudo snap install certbot-dns-netcup Furthermore, the following seems to be required in order to connect the plugin to certbot:: sudo snap set certbot trust-plugin-with-root=ok sudo snap connect certbot:plugin certbot-dns-netcup docker ~~~~~~ Using docker, you can pull an image that contains both certbot and a matching version of the plugin:: docker pull coldfix/certbot-dns-netcup Usage ----- To acquire a single certificate for both ``example.com`` and ``*.example.com``, waiting 1200 seconds (20min) for DNS propagation:: certbot certonly \\ --authenticator dns-netcup \\ --dns-netcup-credentials ~/.secrets/certbot/netcup.ini \\ --dns-netcup-propagation-seconds 1200 \\ --keep-until-expiring --non-interactive --expand \ --server https://acme-v02.api.letsencrypt.org/directory \ -d 'example.com' \\ -d '*.example.com' The parameters and the format of the credentials file are described below. Named Arguments --------------- To start using DNS authentication for netcup, pass the following arguments on certbot's command line: ======================================== ======================= ``--authenticator dns-netcup`` select the authenticator plugin (Required) ``--dns-netcup-credentials FILE`` netcup credentials_ INI file. (Required) ``--dns-netcup-propagation-seconds NUM`` | waiting time for DNS to propagate before asking | the ACME server to verify the DNS record. | (Default: 900, Recommended: >= 600) ``--dns-netcup-login-retries NUM`` | Number of login retry attempts in case the | netcup API client session times out. | (Default: 3, Recommended: >= 1) ``--dns-netcup-zone-name DOMAIN`` | Zone name to operate on (often TLD). | Will be determined using brute-force | requests if not specified. ======================================== ======================= **NOTE:** You may need to set an unexpectedly high propagation time (≥ 900 seconds) to give the netcup DNS time to propagate the entries! This may be annoying when calling certbot manually but should not be a problem in automated setups. In exceptional cases, 20 minutes may be required. See `#28`_. .. _#28: https://github.com/coldfix/certbot-dns-netcup/issues/28 Credentials ----------- Use of this plugin requires a configuration file containing netcup API credentials, obtained from your netcup `account page`_. See also the `CCP API`_ documentation. .. _account page: https://ccp.netcup.net/run/daten_aendern.php?sprung=api An example ``credentials.ini`` file: .. code-block:: ini dns_netcup_customer_id = 123456 dns_netcup_api_key = 0123456789abcdef0123456789abcdef01234567 dns_netcup_api_password = abcdef0123456789abcdef01234567abcdef0123 The path to this file can be provided interactively or using the ``--dns-netcup-credentials`` command-line argument. Certbot records the path to this file for use during renewal, but does not store the file's contents. **CAUTION:** You should protect these API credentials as you would the password to your netcup account. Users who can read this file can use these credentials to issue arbitrary API calls on your behalf. 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 associated domains, even if those domains aren't being managed by this server. Certbot will emit a warning if it detects that the credentials file can be accessed by other users on your system. The warning reads "Unsafe permissions on credentials configuration file", followed by the path to the credentials file. This warning will be emitted each time Certbot uses the credentials file, including for renewal, and cannot be silenced except by addressing the issue (e.g., by using a command like ``chmod 600`` to restrict access to the file). Docker ------ You can pull the latest version of the docker image directly from Docker Hub as follows:: docker pull coldfix/certbot-dns-netcup Alternatively, the docker image can be built from a local checkout and the included ``Dockerfile`` as follows:: docker build -t coldfix/certbot-dns-netcup . Once that's finished, the application can be run as follows:: docker run --rm \ -v /var/lib/letsencrypt:/var/lib/letsencrypt \ -v /etc/letsencrypt:/etc/letsencrypt \ --cap-drop=all \ coldfix/certbot-dns-netcup certbot certonly \ --authenticator dns-netcup \ --dns-netcup-propagation-seconds 900 \ --dns-netcup-credentials /var/lib/letsencrypt/netcup_credentials.ini \ --keep-until-expiring --non-interactive --expand \ --server https://acme-v02.api.letsencrypt.org/directory \ --agree-tos --email "webmaster@example.com" \ -d example.com -d '*.example.com' You may want to change the volumes ``/var/lib/letsencrypt`` and ``/etc/letsencrypt`` to local directories where the certificates and configuration should be stored. .. Badges: .. |Version| image:: https://img.shields.io/pypi/v/certbot-dns-netcup.svg :target: https://pypi.python.org/pypi/certbot-dns-netcup :alt: Version .. |License| image:: https://img.shields.io/pypi/l/certbot-dns-netcup.svg :target: https://github.com/coldfix/certbot-dns-netcup/blob/master/LICENSE.txt :alt: License: Apache .. |ImageSize| image:: https://img.shields.io/docker/image-size/coldfix/certbot-dns-netcup :target: https://hub.docker.com/repository/docker/coldfix/certbot-dns-netcup :alt: Docker image size coldfix-certbot-dns-netcup-c82ebf3/certbot_dns_netcup.py000066400000000000000000000231131507602613600236220ustar00rootroot00000000000000""" This module defines a certbot plugin to automate the process of completing a ``dns-01`` challenge (`~acme.challenges.DNS01`) by creating, and subsequently removing, TXT records using the netcup CCP API. """ # Keep metadata before any imports (for setup.py)! __version__ = '2.0.0' __url__ = 'https://github.com/coldfix/certbot-dns-netcup' __all__ = ['Authenticator'] import json import logging import requests from certbot.plugins import dns_common from certbot.errors import PluginError API_URL = 'https://www.netcup-wiki.de/wiki/CCP_API' API_ENDPOINT = "https://ccp.netcup.net/run/webservice/servers/endpoint.php?JSON" LOGGER = logging.getLogger(__name__) class Authenticator(dns_common.DNSAuthenticator): """DNS Authenticator for netcup This Authenticator uses the netcup API to fulfill a dns-01 challenge. """ description = ('Obtain certificates using a DNS TXT record (if you are ' 'using netcup for DNS).') def __init__(self, *args, **kwargs): super(Authenticator, self).__init__(*args, **kwargs) self.credentials = None self.api_session_id = None # DNSAuthenticator overrides @classmethod def add_parser_arguments(cls, add): super().add_parser_arguments(add, default_propagation_seconds=900) add('credentials', help='netcup credentials INI file.') add('login-retries', default=3, type=int, help="login retry attempts in case of session timeout") add('zone-name', help=( "zone name to operate on (often TLD). " "Will be determined using brute-force requests if not specified.")) def more_info(self): return ('This plugin configures a DNS TXT record to respond to a ' 'dns-01 challenge using the netcup API.') def _setup_credentials(self): self.credentials = self._configure_credentials( 'credentials', 'netcup credentials INI file', { 'customer-id': 'Customer ID associated with netcup account', 'api-key': 'Key for CCP API, see {}'.format(API_URL), 'api-password': 'Password for CCP API, see {}'.format(API_URL), } ) def _perform(self, domain, validation_name, validation): LOGGER.debug("add_dns_record (%s, %s)", domain, validation_name) client = self._get_netcup_client() self._determine_zone(domain, lambda domain: ( client.add_dns_record(domain, validation_name, validation))) def _cleanup(self, domain, validation_name, validation): LOGGER.debug("delete_dns_record(%s, %s)", domain, validation_name) client = self._get_netcup_client() self._determine_zone(domain, lambda domain: ( client.delete_dns_record(domain, validation_name, validation))) def _determine_zone(self, domain, func): """Find the domain_id for a given domain.""" zone_name = self.conf('zone-name') if zone_name: return func(zone_name) domain_name_guesses = dns_common.base_domain_name_guesses(domain) for domain_name in domain_name_guesses: try: return func(domain_name) except NetcupZoneError: pass raise PluginError( 'Unable to determine zone identifier for {0} using zone names: {1}' .format(domain, domain_name_guesses)) def _get_netcup_client(self): credentials = self.credentials.conf return APIClient( credentials('customer-id'), credentials('api-key'), credentials('api-password'), self.conf('login-retries')) class APIClient: def __init__(self, customer_id, api_key, api_password, login_retries): self._customer_id = customer_id self._api_key = api_key self._api_password = api_password self._api_session_id = None self._login_retries = login_retries if login_retries < 0: raise PluginError(( "Invalid value for --dns-netcup-login-retries: {}. " "Must be >= 0." ).format(login_retries)) # public interface def add_dns_record(self, domain, name, content): """Create record.""" record = _make_record(domain, name, content) self._update_records(domain, [record]) def delete_dns_record(self, domain, name, content): """Delete an existing record. If record does not exist, do nothing.""" # Note that id/type/hostname/destination are all mandatory when # deleting. We must query first to retrieve the record id. record = _make_record(domain, name, content) queried_records = self._query_records(domain, record) self._update_records(domain, [ dict(record_with_id, deleterecord=True) for record_with_id in queried_records ]) # internal helpers def _query_records(self, domain, record): """Query list of record using netcup API.""" responsedata = self._authenticate_and_call( "infoDnsRecords", domainname=domain) dnsrecords = responsedata.get("dnsrecords", []) return [ retrieved_record for retrieved_record in dnsrecords if all(retrieved_record[k] == record[k] for k in record) ] def _update_records(self, domain, records): """Insert or update a list of DNS records. The fields ``hostname``, ``type``, and ``destination`` are mandatory. The field ``id`` is mandatory when ``deleterecord=True`` """ return self._authenticate_and_call( "updateDnsRecords", domainname=domain, dnsrecordset={"dnsrecords": records}) def _authenticate(self, force=False): """Authenticate with netcup server. Must be called first.""" if force or not self._api_session_id: responsedata = _apicall("login", { "customernumber": self._customer_id, "apikey": self._api_key, "apipassword": self._api_password, }) self._api_session_id = responsedata.get("apisessionid") if not self._api_session_id: raise PluginError("Login failed due to unknown reason.") return { "customernumber": self._customer_id, "apikey": self._api_key, "apisessionid": self._api_session_id, } def _authenticate_and_call(self, action, domainname, **param): """Authenticate and then perform API call. Auto retry login if session timed out.""" param = dict(param, domainname=domainname) session_auth = self._authenticate(False) for i in range(self._login_retries): try: return _apicall(action, session_auth, **param) except NetcupSessionTimeoutError: LOGGER.warning( "Login session timed out during call %s for domain %s. " "Retrying login (attempt %d)", action, domainname, i + 1) session_auth = self._authenticate(True) return _apicall(action, session_auth, **param) def _make_record(domain, name, content): name = name.removesuffix('.' + domain) return { "type": "TXT", "hostname": name, "destination": content, } def _apicall(action, credentials, **param): """Call an API method and return response data. For more info, see: https://ccp.netcup.net/run/webservice/servers/endpoint""" LOGGER.debug("_apicall: %s(%s)", action, param.get('domainname', '')) data = { "action": action, "param": dict(param, **credentials), } response = requests.post( API_ENDPOINT, data=json.dumps(data), headers={ "Accept": "application/json", "Content-Type": "application/json", }) response.raise_for_status() data = response.json() status = data.get("status") statuscode = data.get("statuscode") shortmessage = data.get("shortmessage") longmessage = data.get("longmessage") if status == "success": # statuscode == 2000 return data.get("responsedata", {}) # This happens when the domain is not chosen properly. Full message is: # "Value in field domainname does not match requirements of type: domainname" if 'Value in field domainname does not match requirements' in longmessage: raise NetcupZoneError( action, statuscode, shortmessage, longmessage) # The session times out after roughly 30s and fails with this error: if 'The session id is not in a valid format.' in longmessage: raise NetcupSessionTimeoutError( action, statuscode, shortmessage, longmessage) # When something with the JSON format was incorrect, there is also: # "Api key missing. JSON decode failed while validating request." raise NetcupError( action, statuscode, shortmessage, longmessage) class NetcupError(PluginError): def __init__(self, action, statuscode, shortmessage, longmessage): super().__init__(self._format( action, statuscode, shortmessage, longmessage)) self.action = action self.statuscode = statuscode self.shortmessage = shortmessage self.longmessage = longmessage @classmethod def _format(cls, action, statuscode, shortmessage, longmessage): return (f'{cls.__name__} during {action}: ' f'{shortmessage} ({statuscode}) {longmessage}') class NetcupZoneError(NetcupError): pass class NetcupSessionTimeoutError(NetcupError): pass coldfix-certbot-dns-netcup-c82ebf3/setup.cfg000066400000000000000000000024161507602613600212100ustar00rootroot00000000000000[options] py_modules = certbot_dns_netcup python_requires = >=3.7 install_requires = certbot>=2.7 requests [options.entry_points] certbot.plugins = dns-netcup = certbot_dns_netcup:Authenticator [metadata] name = certbot-dns-netcup description = netcup DNS Authenticator plugin for Certbot long_description = file: README.rst author = Thomas Gläßle author_email = thomas@coldfix.de license = Apache License 2.0 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 :: 3 Topic :: Internet :: WWW/HTTP Topic :: Security Topic :: System :: Installation/Setup Topic :: System :: Networking Topic :: System :: Systems Administration Topic :: Utilities long_description_content_type = text/x-rst [bdist_wheel] universal = 1 [flake8] # codes: https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes # default: ignore = E121,E123,E126,E133,E226,E241,E242,E704,W503,W504,W505 ignore = E221,E241,E251,E402 exclude = docs,.git,build,__pycache__,dist,.eggs max-line-length = 83 max-complexity = 8 coldfix-certbot-dns-netcup-c82ebf3/setup.py000066400000000000000000000011001507602613600210660ustar00rootroot00000000000000# encoding: utf-8 from setuptools import setup def exec_file(path): """Execute a python file and return the `globals` dictionary.""" with open(path, 'rb') as f: code = compile(f.read(), path, 'exec') namespace = {} try: exec(code, namespace, namespace) except ImportError: # ignore missing dependencies at setup time pass # and return dunder-globals anyway! return namespace metadata = exec_file('certbot_dns_netcup.py') setup( version = metadata['__version__'], url = metadata['__url__'], ) coldfix-certbot-dns-netcup-c82ebf3/snap/000077500000000000000000000000001507602613600203255ustar00rootroot00000000000000coldfix-certbot-dns-netcup-c82ebf3/snap/snapcraft.yaml000066400000000000000000000030011507602613600231640ustar00rootroot00000000000000name: certbot-dns-netcup version: 2.0.0 summary: Certbot DNS Authenticator plugin for netcup description: | This plugin automates the process of completing a dns-01 challenge by creating, and subsequently removing, TXT records using the netcup CCP API via lexicon. confinement: strict grade: stable base: core24 platforms: all: build-on: amd64 build-for: all parts: certbot-dns-netcup: plugin: nil source: . build-packages: - python3-venv build-snaps: - certbot override-build: | MAJOR=$(python3 -c 'import sys; print(sys.version_info.major)') MINOR=$(python3 -c 'import sys; print(sys.version_info.minor)') SITE_PTH=lib/python$MAJOR.$MINOR/site-packages SITE_DIR=$SNAPCRAFT_PART_INSTALL/$SITE_PTH # Avoid installing packages that will already be included in the # certbot snap: mkdir -p $SITE_DIR echo /snap/certbot/current/$SITE_PTH > $SITE_DIR/certbot.pth python3 -m venv $SNAPCRAFT_PART_INSTALL VENV_BASE_PACKAGES=$(ls $SITE_DIR) $SNAPCRAFT_PART_INSTALL/bin/python -m pip install . cd $SITE_DIR # Remove our .pth file: rm -f certbot.pth # Remove presumably unneeded .so file - to keep platform independence: rm -f yaml/_yaml.*.so # Remove presumably unneeded packages of the venv base installation: rm -rf $VENV_BASE_PACKAGES prime: - lib slots: certbot: interface: content content: certbot-1 read: - $SNAP/lib/python3.12/site-packages