certbot-dns-hosttech 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- certbot_dns_hosttech/__init__.py +1 -0
- certbot_dns_hosttech/_internal/__init__.py +1 -0
- certbot_dns_hosttech/_internal/dns_hosttech.py +204 -0
- certbot_dns_hosttech-0.1.0.dist-info/METADATA +253 -0
- certbot_dns_hosttech-0.1.0.dist-info/RECORD +9 -0
- certbot_dns_hosttech-0.1.0.dist-info/WHEEL +5 -0
- certbot_dns_hosttech-0.1.0.dist-info/entry_points.txt +2 -0
- certbot_dns_hosttech-0.1.0.dist-info/licenses/LICENSE +202 -0
- certbot_dns_hosttech-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Hosttech DNS authenticator for Certbot."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Private implementation of the Hosttech DNS authenticator."""
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"""Solve DNS-01 challenges with the Hosttech DNS API v1."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from collections.abc import Callable
|
|
5
|
+
from typing import Any, cast
|
|
6
|
+
|
|
7
|
+
import requests
|
|
8
|
+
from certbot import achallenges, configuration, errors
|
|
9
|
+
from certbot.plugins import dns_common
|
|
10
|
+
|
|
11
|
+
API_URL = "https://api.ns1.hosttech.eu/api/user/v1"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _redact_credential_errors(record: logging.LogRecord) -> bool:
|
|
15
|
+
# Certbot's INI parser includes malformed lines (potentially the token) in DEBUG tracebacks.
|
|
16
|
+
if str(record.msg).startswith("Error parsing credentials configuration"):
|
|
17
|
+
record.msg = "Error parsing credentials configuration; check the Hosttech INI file syntax."
|
|
18
|
+
record.args = ()
|
|
19
|
+
record.exc_info = None
|
|
20
|
+
record.exc_text = None
|
|
21
|
+
return True
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Authenticator(dns_common.DNSAuthenticator):
|
|
25
|
+
"""Create independent TXT records and remove only their returned IDs."""
|
|
26
|
+
|
|
27
|
+
description = "Obtain certificates using DNS TXT records hosted by Hosttech."
|
|
28
|
+
ttl = 600
|
|
29
|
+
|
|
30
|
+
def __init__(self, config: configuration.NamespaceConfig, name: str) -> None:
|
|
31
|
+
super().__init__(config, name)
|
|
32
|
+
self.credentials: dns_common.CredentialsConfiguration | None = None
|
|
33
|
+
self._client: _HosttechClient | None = None
|
|
34
|
+
self._records: dict[tuple[str, str], tuple[int, int]] = {}
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def add_parser_arguments(cls, add: Callable[..., None], default_propagation_seconds: int = 600) -> None:
|
|
38
|
+
super().add_parser_arguments(add, default_propagation_seconds)
|
|
39
|
+
add("credentials", help="Hosttech credentials INI file.")
|
|
40
|
+
|
|
41
|
+
def more_info(self) -> str:
|
|
42
|
+
return "This plugin creates DNS TXT records through the Hosttech DNS API to respond to DNS-01 challenges."
|
|
43
|
+
|
|
44
|
+
def _setup_credentials(self) -> None:
|
|
45
|
+
if self.conf("propagation-seconds") < 0:
|
|
46
|
+
raise errors.PluginError("--dns-hosttech-propagation-seconds must be non-negative.")
|
|
47
|
+
credentials_logger = logging.getLogger(dns_common.__name__)
|
|
48
|
+
credentials_logger.addFilter(_redact_credential_errors)
|
|
49
|
+
try:
|
|
50
|
+
self.credentials = self._configure_credentials(
|
|
51
|
+
"credentials",
|
|
52
|
+
"Hosttech credentials INI file",
|
|
53
|
+
{"api-token": "Hosttech DNS API bearer token"},
|
|
54
|
+
self._validate_credentials,
|
|
55
|
+
)
|
|
56
|
+
except OSError:
|
|
57
|
+
raise errors.PluginError("Cannot read Hosttech credentials; check the file path and read permissions for the Certbot user.") from None
|
|
58
|
+
except (errors.PluginError, UnicodeError, LookupError) as error:
|
|
59
|
+
# ConfigObj's BOM decoder can raise a bare LookupError for an unsupported codec alias.
|
|
60
|
+
if isinstance(error, UnicodeError) or type(error) is LookupError or str(error).startswith("Error parsing credentials configuration"):
|
|
61
|
+
raise errors.PluginError(
|
|
62
|
+
"Cannot parse Hosttech credentials; use a sectionless INI file containing dns_hosttech_api_token = YOUR_TOKEN."
|
|
63
|
+
) from None
|
|
64
|
+
raise
|
|
65
|
+
finally:
|
|
66
|
+
credentials_logger.removeFilter(_redact_credential_errors)
|
|
67
|
+
if self._client is None:
|
|
68
|
+
self._client = _HosttechClient(cast(str, self.credentials.conf("api-token")))
|
|
69
|
+
|
|
70
|
+
@staticmethod
|
|
71
|
+
def _validate_credentials(credentials: dns_common.CredentialsConfiguration) -> None:
|
|
72
|
+
token = credentials.conf("api-token")
|
|
73
|
+
if not isinstance(token, str) or not token or any(ord(char) < 33 or ord(char) > 126 for char in token):
|
|
74
|
+
raise errors.PluginError("dns_hosttech_api_token must be a single non-empty ASCII token without whitespace.")
|
|
75
|
+
|
|
76
|
+
def _perform(self, domain: str, validation_name: str, validation: str) -> None:
|
|
77
|
+
if self._client is None:
|
|
78
|
+
raise errors.PluginError("Hosttech credentials have not been configured.")
|
|
79
|
+
key = (validation_name.lower().rstrip("."), validation)
|
|
80
|
+
if key not in self._records:
|
|
81
|
+
self._records[key] = self._client.add_txt_record(validation_name, validation, self.ttl)
|
|
82
|
+
|
|
83
|
+
def _cleanup(self, domain: str, validation_name: str, validation: str) -> None:
|
|
84
|
+
key = (validation_name.lower().rstrip("."), validation)
|
|
85
|
+
record = self._records.get(key)
|
|
86
|
+
if record is not None:
|
|
87
|
+
assert self._client is not None
|
|
88
|
+
self._client.delete_record(*record)
|
|
89
|
+
del self._records[key]
|
|
90
|
+
|
|
91
|
+
def cleanup(self, achalls: list[achallenges.AnnotatedChallenge]) -> None:
|
|
92
|
+
failures = []
|
|
93
|
+
for achall in achalls:
|
|
94
|
+
try:
|
|
95
|
+
super().cleanup([achall])
|
|
96
|
+
except errors.PluginError as error:
|
|
97
|
+
failures.append(str(error))
|
|
98
|
+
if failures:
|
|
99
|
+
raise errors.PluginError("Hosttech cleanup incomplete: " + "; ".join(failures))
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class _HosttechClient:
|
|
103
|
+
"""Minimal API client; untrusted response bodies never enter diagnostics."""
|
|
104
|
+
|
|
105
|
+
def __init__(self, token: str) -> None:
|
|
106
|
+
self._token = token
|
|
107
|
+
self._zones: list[tuple[int, str]] | None = None
|
|
108
|
+
|
|
109
|
+
def _authenticate(self, request: requests.PreparedRequest) -> requests.PreparedRequest:
|
|
110
|
+
# Explicit auth takes precedence over unrelated credentials in the operator's .netrc.
|
|
111
|
+
request.headers["Authorization"] = "Bearer " + self._token
|
|
112
|
+
return request
|
|
113
|
+
|
|
114
|
+
def _request(self, method: str, path: str, **kwargs: Any) -> Any:
|
|
115
|
+
try:
|
|
116
|
+
response = requests.request(
|
|
117
|
+
method,
|
|
118
|
+
API_URL + path,
|
|
119
|
+
headers={"Accept": "application/json"},
|
|
120
|
+
auth=self._authenticate,
|
|
121
|
+
timeout=30,
|
|
122
|
+
allow_redirects=False,
|
|
123
|
+
**kwargs,
|
|
124
|
+
)
|
|
125
|
+
except requests.RequestException:
|
|
126
|
+
raise errors.PluginError(
|
|
127
|
+
f"Hosttech API {method} failed: check network access, proxy settings and trusted TLS certificates. "
|
|
128
|
+
"If creating a TXT record, check the DNS Editor for a leftover before retrying."
|
|
129
|
+
) from None
|
|
130
|
+
|
|
131
|
+
status = response.status_code
|
|
132
|
+
expected = {"GET": (200,), "POST": (201,), "DELETE": (204, 404)}[method]
|
|
133
|
+
if status not in expected:
|
|
134
|
+
if status == 401:
|
|
135
|
+
hint = "Authentication failed; replace or correct dns_hosttech_api_token in the credentials file."
|
|
136
|
+
elif status == 403:
|
|
137
|
+
hint = "Access denied; check the token's zone access and DNS read/write permissions with Hosttech."
|
|
138
|
+
elif status == 404:
|
|
139
|
+
hint = "Zone or record not found; check that the zone still exists in this Hosttech account."
|
|
140
|
+
elif status in (419, 429):
|
|
141
|
+
hint = "Hosttech rate limit reached; wait for the limit to reset, then retry."
|
|
142
|
+
elif status in (400, 422):
|
|
143
|
+
hint = "Record rejected; check the zone, TXT name/value and TTL in the Hosttech DNS Editor."
|
|
144
|
+
elif status >= 500:
|
|
145
|
+
hint = "Hosttech is unavailable; retry later or contact Hosttech support."
|
|
146
|
+
else:
|
|
147
|
+
hint = "Unexpected response; check Hosttech service status and contact support."
|
|
148
|
+
raise errors.PluginError(f"Hosttech API {method} failed (HTTP {status}). {hint}")
|
|
149
|
+
|
|
150
|
+
if method == "DELETE":
|
|
151
|
+
return None
|
|
152
|
+
try:
|
|
153
|
+
payload = response.json()
|
|
154
|
+
except ValueError:
|
|
155
|
+
raise errors.PluginError("Hosttech API returned an invalid JSON response. Check the DNS Editor for leftover TXT records before retrying.") from None
|
|
156
|
+
if not isinstance(payload, dict) or "data" not in payload:
|
|
157
|
+
raise errors.PluginError("Hosttech API returned an unexpected response. Check the DNS Editor for leftover TXT records before retrying.")
|
|
158
|
+
return payload["data"]
|
|
159
|
+
|
|
160
|
+
def find_zone(self, validation_name: str) -> tuple[int, str]:
|
|
161
|
+
"""Find the most specific accessible zone, including delegated challenge zones."""
|
|
162
|
+
if self._zones is None:
|
|
163
|
+
zones = []
|
|
164
|
+
zone_ids = set()
|
|
165
|
+
offset = 0
|
|
166
|
+
while True:
|
|
167
|
+
page = self._request("GET", "/zones", params={"limit": 100, "offset": offset})
|
|
168
|
+
if not isinstance(page, list):
|
|
169
|
+
raise errors.PluginError("Hosttech API returned an invalid zone list response.")
|
|
170
|
+
for zone in page:
|
|
171
|
+
if (
|
|
172
|
+
not isinstance(zone, dict)
|
|
173
|
+
or type(zone.get("id")) is not int
|
|
174
|
+
or zone["id"] <= 0
|
|
175
|
+
or not isinstance(zone.get("name"), str)
|
|
176
|
+
or not zone["name"].rstrip(".")
|
|
177
|
+
):
|
|
178
|
+
raise errors.PluginError("Hosttech API returned an invalid zone response.")
|
|
179
|
+
if zone["id"] in zone_ids:
|
|
180
|
+
raise errors.PluginError("Hosttech zone pagination repeated a zone ID; contact Hosttech support before retrying.")
|
|
181
|
+
zone_ids.add(zone["id"])
|
|
182
|
+
zones.append((zone["id"], zone["name"].lower().rstrip(".")))
|
|
183
|
+
if len(page) < 100:
|
|
184
|
+
break
|
|
185
|
+
offset += len(page)
|
|
186
|
+
self._zones = zones
|
|
187
|
+
|
|
188
|
+
name = validation_name.lower().rstrip(".")
|
|
189
|
+
matches = [zone for zone in self._zones if name == zone[1] or name.endswith("." + zone[1])]
|
|
190
|
+
if not matches:
|
|
191
|
+
raise errors.PluginError(f"No matching Hosttech zone for {name}; check the account, zone delegation and token access.")
|
|
192
|
+
return max(matches, key=lambda zone: len(zone[1]))
|
|
193
|
+
|
|
194
|
+
def add_txt_record(self, validation_name: str, validation: str, ttl: int) -> tuple[int, int]:
|
|
195
|
+
name = validation_name.lower().rstrip(".")
|
|
196
|
+
zone_id, zone_name = self.find_zone(name)
|
|
197
|
+
relative_name = "" if name == zone_name else name[: -(len(zone_name) + 1)]
|
|
198
|
+
record = self._request("POST", f"/zones/{zone_id}/records", json={"type": "TXT", "name": relative_name, "text": validation, "ttl": ttl})
|
|
199
|
+
if not isinstance(record, dict) or type(record.get("id")) is not int or record["id"] <= 0:
|
|
200
|
+
raise errors.PluginError("Hosttech API returned no valid created record ID; check the DNS Editor for a leftover TXT record before retrying.")
|
|
201
|
+
return zone_id, record["id"]
|
|
202
|
+
|
|
203
|
+
def delete_record(self, zone_id: int, record_id: int) -> None:
|
|
204
|
+
self._request("DELETE", f"/zones/{zone_id}/records/{record_id}")
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: certbot-dns-hosttech
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Hosttech DNS authenticator plugin for Certbot
|
|
5
|
+
Author: Bunkerity
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/bunkerity/certbot-dns-hosttech
|
|
8
|
+
Project-URL: Source, https://github.com/bunkerity/certbot-dns-hosttech
|
|
9
|
+
Project-URL: Issues, https://github.com/bunkerity/certbot-dns-hosttech/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/bunkerity/certbot-dns-hosttech/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: certbot,letsencrypt,acme,dns-01,hosttech
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Plugins
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Internet :: Name Service (DNS)
|
|
22
|
+
Classifier: Topic :: Security
|
|
23
|
+
Classifier: Topic :: System :: Networking
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: certbot<6,>=5.9.0
|
|
28
|
+
Requires-Dist: requests<3,>=2.31.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-cov>=5; extra == "dev"
|
|
32
|
+
Requires-Dist: black>=24; extra == "dev"
|
|
33
|
+
Requires-Dist: ruff>=0.9; extra == "dev"
|
|
34
|
+
Requires-Dist: mypy>=1.14; extra == "dev"
|
|
35
|
+
Requires-Dist: types-requests; extra == "dev"
|
|
36
|
+
Requires-Dist: build; extra == "dev"
|
|
37
|
+
Requires-Dist: twine; extra == "dev"
|
|
38
|
+
Requires-Dist: setuptools>=77; extra == "dev"
|
|
39
|
+
Requires-Dist: atheris==3.1.0; (python_version >= "3.12" and python_version < "3.15" and sys_platform == "linux" and platform_machine == "x86_64") and extra == "dev"
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
# certbot-dns-hosttech
|
|
43
|
+
|
|
44
|
+
[](https://github.com/bunkerity/certbot-dns-hosttech/actions/workflows/tests.yml)
|
|
45
|
+
[](https://app.codecov.io/gh/bunkerity/certbot-dns-hosttech)
|
|
46
|
+
[](https://securityscorecards.dev/viewer/?uri=github.com/bunkerity/certbot-dns-hosttech)
|
|
47
|
+
[](https://score.getplumber.io/github.com/bunkerity/certbot-dns-hosttech)
|
|
48
|
+
[](https://github.com/bunkerity/certbot-dns-hosttech/blob/main/LICENSE)
|
|
49
|
+
|
|
50
|
+
<!-- After registering the project at bestpractices.dev, replace PROJECT_ID and uncomment:
|
|
51
|
+
[](https://www.bestpractices.dev/projects/PROJECT_ID)
|
|
52
|
+
Only claim the level actually awarded; the project has not registered yet.
|
|
53
|
+
-->
|
|
54
|
+
|
|
55
|
+
[Certbot](https://certbot.eff.org/) DNS-01 authenticator for the [Hosttech DNS API](https://api.ns1.hosttech.eu/api/documentation/).
|
|
56
|
+
Supports apex names, subdomains and wildcards, including two TXT values at the same challenge name.
|
|
57
|
+
|
|
58
|
+
| At a glance | Value |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| Plugin name | `dns-hosttech` |
|
|
61
|
+
| Requires | Python 3.11 or newer and Certbot 5.9.x (dependency range `>=5.9.0,<6`) |
|
|
62
|
+
| Supported Python | 3.11–3.14 |
|
|
63
|
+
| Runtime dependencies | Certbot and requests |
|
|
64
|
+
| Credentials | Hosttech REST API bearer token in a sectionless INI file |
|
|
65
|
+
| License | Apache-2.0 |
|
|
66
|
+
|
|
67
|
+
> **Read before you run it**
|
|
68
|
+
>
|
|
69
|
+
> - `--dry-run` uses Let's Encrypt staging and still creates/deletes real DNS records through Hosttech.
|
|
70
|
+
> - If the process is killed or the network fails mid-run, a TXT record may remain. [Remove it by hand](#interrupted-runs-and-leftover-records).
|
|
71
|
+
> - The 600-second propagation wait is a conservative starting value, not a measured Hosttech guarantee. Live Hosttech access and DNS propagation have not been tested without a real token.
|
|
72
|
+
|
|
73
|
+
## Quickstart
|
|
74
|
+
|
|
75
|
+
### 1. Install
|
|
76
|
+
|
|
77
|
+
Install the plugin in the **same Python environment as Certbot**. A separate pip installation cannot extend a Certbot snap or another virtual environment.
|
|
78
|
+
|
|
79
|
+
Install from PyPI:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
python3 -m venv .venv
|
|
83
|
+
.venv/bin/python -m pip install certbot-dns-hosttech 'certbot==5.9.0'
|
|
84
|
+
.venv/bin/certbot plugins --text
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The plugin should appear as `dns-hosttech`.
|
|
88
|
+
|
|
89
|
+
Each [GitHub release](https://github.com/bunkerity/certbot-dns-hosttech/releases) also provides a wheel, source archive and `SHA256SUMS`. The [v0.1.0 release](https://github.com/bunkerity/certbot-dns-hosttech/releases/tag/v0.1.0) wheel installs like this:
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
python3 -m venv .venv
|
|
93
|
+
.venv/bin/python -m pip install \
|
|
94
|
+
'https://github.com/bunkerity/certbot-dns-hosttech/releases/download/v0.1.0/certbot_dns_hosttech-0.1.0-py3-none-any.whl' \
|
|
95
|
+
'certbot==5.9.0'
|
|
96
|
+
.venv/bin/certbot plugins --text
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The plugin should appear as `dns-hosttech`.
|
|
100
|
+
|
|
101
|
+
To verify provenance before installation, download the wheel with [GitHub CLI](https://cli.github.com/) and verify its attestation. Then install the verified local file:
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
gh release download v0.1.0 -R bunkerity/certbot-dns-hosttech \
|
|
105
|
+
--pattern 'certbot_dns_hosttech-0.1.0-py3-none-any.whl'
|
|
106
|
+
gh attestation verify certbot_dns_hosttech-0.1.0-py3-none-any.whl -R bunkerity/certbot-dns-hosttech
|
|
107
|
+
.venv/bin/python -m pip install ./certbot_dns_hosttech-0.1.0-py3-none-any.whl 'certbot==5.9.0'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
For development, use the locked setup below from a source checkout.
|
|
111
|
+
|
|
112
|
+
### 2. Add your token
|
|
113
|
+
|
|
114
|
+
Create a DNS API token in myhosttech.eu → DNS Editor → API. Use the REST API bearer token, not the old WSDL username/password.
|
|
115
|
+
The token must allow listing the relevant zones and creating/deleting their DNS records.
|
|
116
|
+
|
|
117
|
+
<details>
|
|
118
|
+
<summary>Token scopes</summary>
|
|
119
|
+
|
|
120
|
+
Public Hosttech documentation does not establish whether tokens support per-zone or read/write scopes; confirm available restrictions with Hosttech.
|
|
121
|
+
|
|
122
|
+
</details>
|
|
123
|
+
|
|
124
|
+
Put it in a sectionless INI file such as `/etc/letsencrypt/hosttech.ini`:
|
|
125
|
+
|
|
126
|
+
```ini
|
|
127
|
+
dns_hosttech_api_token = YOUR_HOSTTECH_DNS_API_TOKEN
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Restrict access before use:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
chmod 600 /etc/letsencrypt/hosttech.ini
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Do not pass the token on the command line. Keep this file for renewals: Certbot saves its path, not its contents, in renewal configuration. Certbot warns about unsafe file permissions; it does not reject them.
|
|
137
|
+
|
|
138
|
+
### 3. Get a staging certificate
|
|
139
|
+
|
|
140
|
+
First run a staging validation with an apex and its wildcard:
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
.venv/bin/certbot certonly \
|
|
144
|
+
--authenticator dns-hosttech \
|
|
145
|
+
--dns-hosttech-credentials /etc/letsencrypt/hosttech.ini \
|
|
146
|
+
--dns-hosttech-propagation-seconds 600 \
|
|
147
|
+
--dry-run --non-interactive --agree-tos --email admin@example.com \
|
|
148
|
+
-d example.com -d '*.example.com'
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Replace the example domains and email address. `--dry-run` uses Let's Encrypt staging and still creates/deletes real DNS records through Hosttech.
|
|
152
|
+
|
|
153
|
+
After staging succeeds, run the same command without `--dry-run` to obtain a production certificate. Standard `certbot renew` reuses the saved authenticator options.
|
|
154
|
+
|
|
155
|
+
## Reference
|
|
156
|
+
|
|
157
|
+
### Options
|
|
158
|
+
|
|
159
|
+
| Option | Meaning |
|
|
160
|
+
| --- | --- |
|
|
161
|
+
| `--dns-hosttech-credentials PATH` | Path to the credentials INI file. |
|
|
162
|
+
| `--dns-hosttech-propagation-seconds N` | Fixed wait after creating all challenges, default **600 seconds**. |
|
|
163
|
+
|
|
164
|
+
The credential file contains `dns_hosttech_api_token = TOKEN` without a section header. The token must be non-empty ASCII without whitespace; the propagation wait must be non-negative. Successful authentication creates validation TXT records and returns DNS-01 responses to Certbot. Cleanup removes only the records created by this instance. Failures become actionable Certbot `PluginError` messages; the plugin does not emit certificates or expose raw provider responses itself. Certbot handles certificate files, renewal state and command exit status.
|
|
165
|
+
|
|
166
|
+
### TTL and propagation
|
|
167
|
+
|
|
168
|
+
TXT TTL is **600 seconds**, matching [Hosttech's published minimum](https://en.support.hosttech.ch/knowledge-base/what-modules-are-available-for-whmcs/).
|
|
169
|
+
Propagation wait is a conservative initial choice, not a measured Hosttech publication guarantee. TTL and propagation delay describe different things. Increase the wait if staging validation shows it is insufficient.
|
|
170
|
+
|
|
171
|
+
<details>
|
|
172
|
+
<summary>What Hosttech says about timing</summary>
|
|
173
|
+
|
|
174
|
+
[Hosttech's general guidance](https://en.support.hosttech.ch/knowledge-base/how-can-i-set-change-dns-records/) allows up to six hours for DNS changes to become active; it gives no API-to-authoritative-server SLA.
|
|
175
|
+
|
|
176
|
+
</details>
|
|
177
|
+
|
|
178
|
+
### How it behaves
|
|
179
|
+
|
|
180
|
+
**Zones and names**
|
|
181
|
+
|
|
182
|
+
- Finds the most specific accessible Hosttech zone matching the validation name, including delegated `_acme-challenge` zones. Zone listing is paginated. No SOA lookup is needed, so local split DNS and future A/AAAA cutovers do not affect zone discovery.
|
|
183
|
+
- ACME must still be able to resolve the validation TXT records through **public authoritative DNS**. Private-only zones cannot validate with Let's Encrypt.
|
|
184
|
+
- Does not follow CNAMEs itself. Standard Certbot creates at its supplied validation name; CNAME delegation needs separate Certbot configuration/integration support. This plugin does not discover a hidden child zone when a token only exposes its parent.
|
|
185
|
+
|
|
186
|
+
**Records and cleanup**
|
|
187
|
+
|
|
188
|
+
- Creates separate TXT records and tracks their returned IDs. Cleanup deletes only IDs created by this authenticator instance, preserving other TXT records at the same name, even with identical content. It never replaces a zone or RRset.
|
|
189
|
+
- Repeating the same challenge within one instance reuses its created record. Different apex/wildcard values remain separate.
|
|
190
|
+
- Cleanup attempts all challenges and reports deletion failures. Failed record IDs remain available for a retry in the same process. After process exit, remove any leftovers manually.
|
|
191
|
+
|
|
192
|
+
<details>
|
|
193
|
+
<summary>Errors, transport and security</summary>
|
|
194
|
+
|
|
195
|
+
- Maps authentication, permission, missing-zone, validation, rate-limit (419/429), network/TLS and server failures to `PluginError` with remediation. Raw API response bodies and request exception text are not logged.
|
|
196
|
+
- HTTP redirects are rejected; TLS verification stays enabled; each request has a 30-second timeout. Explicit Bearer authentication takes precedence over unrelated `.netrc` credentials.
|
|
197
|
+
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
<details>
|
|
201
|
+
<summary>Not documented or not tested</summary>
|
|
202
|
+
|
|
203
|
+
Public API documentation does not publish a numerical rate quota, TXT TTL maximum or token-scope contract. Live Hosttech access and DNS propagation have not been tested without a real token.
|
|
204
|
+
|
|
205
|
+
</details>
|
|
206
|
+
|
|
207
|
+
### Interrupted runs and leftover records
|
|
208
|
+
|
|
209
|
+
IDs are tracked in memory. If the process is killed, the network fails after a successful create, or Hosttech returns an unusable create response, a record may remain. Inspect the DNS Editor and remove only the challenge record from that interrupted attempt before retrying. Automatic POST retries are deliberately avoided because creation may already have succeeded.
|
|
210
|
+
|
|
211
|
+
## Development
|
|
212
|
+
|
|
213
|
+
<details>
|
|
214
|
+
<summary>Setup, checks and CI</summary>
|
|
215
|
+
|
|
216
|
+
```sh
|
|
217
|
+
python3 -m venv .venv
|
|
218
|
+
.venv/bin/python -m pip install --require-hashes -r requirements-dev.txt
|
|
219
|
+
.venv/bin/python -m pip install --no-deps --no-build-isolation -e .
|
|
220
|
+
.venv/bin/python -m pip check
|
|
221
|
+
.venv/bin/python -m black --check --workers 1 .
|
|
222
|
+
.venv/bin/python -m ruff check .
|
|
223
|
+
.venv/bin/python -m mypy
|
|
224
|
+
.venv/bin/python -m pytest -vv --cov --cov-branch --cov-report=term-missing
|
|
225
|
+
.venv/bin/python -m build --no-isolation
|
|
226
|
+
.venv/bin/python -m twine check dist/*
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Tests mock Hosttech or use an HTTP fake bound to localhost. No provider token is needed. The interface test discovers the installed entry point and calls Certbot `perform`/`cleanup` with real DNS-01 challenges for an apex and wildcard in one batch. It asserts that both values coexist and existing records survive cleanup. This tests the plugin interface and HTTP contract, not issuance by a real ACME server.
|
|
230
|
+
|
|
231
|
+
CI runs lint, strict typing, 100% branch coverage and packaging checks across Python 3.11–3.14. Development dependencies are pinned with hashes in `requirements-dev.txt`; runtime package metadata retains compatible version ranges. Weekly Dependabot updates cover Python dependencies and GitHub Actions. SHA-pinned Plumber, CodeQL and OpenSSF Scorecard workflows follow the [OSS security workflow notes](https://github.com/bunkerity/certbot-dns-hosttech/blob/main/.github/plumber/README.md). Score publishing is enabled only for public repositories.
|
|
232
|
+
|
|
233
|
+
Offline Atheris fuzzing exercises zone selection across pages, credential parsing and diagnostic redaction, and API response handling. CI runs each target for 60 seconds through the test workflow and 300 seconds weekly. It blocks socket creation and needs no token. Atheris 3.1.0 wheels are available for Linux x86_64 on Python 3.12–3.14; ordinary tests still cover Python 3.11.
|
|
234
|
+
|
|
235
|
+
For a local fuzz session on a supported platform, use the development environment above. Run from the source checkout, use a writable temporary corpus first, and retain any crash input for investigation:
|
|
236
|
+
|
|
237
|
+
```sh
|
|
238
|
+
mkdir -p /tmp/hosttech-fuzz-corpus /tmp/hosttech-fuzz-findings
|
|
239
|
+
.venv/bin/python -m fuzz.fuzz_hosttech zones /tmp/hosttech-fuzz-corpus fuzz/corpus/zones \
|
|
240
|
+
-max_total_time=60 -max_len=4096 -timeout=10 -artifact_prefix=/tmp/hosttech-fuzz-findings/
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Replace `zones` and its seed path with `credentials` or `api` for the other targets. Fuzzing is a separate check and does not replace the coverage gate. Regenerate the universal development lock with `uv pip compile pyproject.toml --extra dev --universal --python-version 3.11 --generate-hashes --output-file requirements-dev.txt` so the host interpreter does not narrow the supported Python range.
|
|
244
|
+
|
|
245
|
+
Releases export `provenance.intoto.jsonl` (the signed in-toto DSSE envelope) and `provenance.sigstore.json` (the full Sigstore verification bundle). Verify the downloaded distribution against the bundle with `gh attestation verify <distribution> --bundle provenance.sigstore.json -R bunkerity/certbot-dns-hosttech`. The envelope alone omits the certificate and transparency evidence; retain the bundle. Stable releases and prereleases upload every asset to a draft before publication, which supports immutable GitHub releases when maintainers enable that setting.
|
|
246
|
+
|
|
247
|
+
Report bugs and enhancement requests through [GitHub issues](https://github.com/bunkerity/certbot-dns-hosttech/issues), contribute through [reviewed pull requests](https://github.com/bunkerity/certbot-dns-hosttech/blob/main/.github/CONTRIBUTING.md), and report vulnerabilities through the [private security process](https://github.com/bunkerity/certbot-dns-hosttech/blob/main/.github/SECURITY.md).
|
|
248
|
+
|
|
249
|
+
</details>
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
Apache-2.0. See [LICENSE](https://github.com/bunkerity/certbot-dns-hosttech/blob/main/LICENSE).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
certbot_dns_hosttech/__init__.py,sha256=tEzUnpDQZuhcgPU-g3b8J7wzCXBj9w_YEffMFy4lgjg,46
|
|
2
|
+
certbot_dns_hosttech/_internal/__init__.py,sha256=gf_k4lWPsZeS4_D5yfC7ZyJ4hbpVX-y1pdKDImqVlAM,64
|
|
3
|
+
certbot_dns_hosttech/_internal/dns_hosttech.py,sha256=IPsFD95g3otwfJj-NFhvZiUq7ZD3SoCkZllVPFbiDBE,10378
|
|
4
|
+
certbot_dns_hosttech-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
5
|
+
certbot_dns_hosttech-0.1.0.dist-info/METADATA,sha256=HCvPbBBmCzi2zc_gCY808rGoZ0oPbP3F3jZVzm26rIY,14917
|
|
6
|
+
certbot_dns_hosttech-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
7
|
+
certbot_dns_hosttech-0.1.0.dist-info/entry_points.txt,sha256=aN-rtpSrQIZac8w20gRxGajcPi50miqW3aVExsY4Gxc,91
|
|
8
|
+
certbot_dns_hosttech-0.1.0.dist-info/top_level.txt,sha256=3Tcec6w1Uhj6cdgqAtgfWqn-aFRoVquPyqcwpYtnA8g,21
|
|
9
|
+
certbot_dns_hosttech-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
certbot_dns_hosttech
|