certbot-dns-dnsmgr 1.0.0__tar.gz

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.
@@ -0,0 +1,16 @@
1
+ # Credentials
2
+ *.ini
3
+
4
+ # Python
5
+ __pycache__/
6
+ *.py[cod]
7
+ *.egg-info/
8
+ build/
9
+ dist/
10
+ .venv/
11
+ venv/
12
+
13
+ # IDE
14
+ .idea/
15
+ .vscode/
16
+ .DS_Store
@@ -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,162 @@
1
+ Metadata-Version: 2.5
2
+ Name: certbot-dns-dnsmgr
3
+ Version: 1.0.0
4
+ Summary: DNSmanager (ISPsystem) DNS Authenticator plugin for Certbot
5
+ Project-URL: Homepage, https://github.com/everestmx/certbot-dns-dnsmgr
6
+ Project-URL: Source, https://github.com/everestmx/certbot-dns-dnsmgr
7
+ Project-URL: Issues, https://github.com/everestmx/certbot-dns-dnsmgr/issues
8
+ Author-email: Dmitry Sergeev <everestmx@gmail.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: acme,authenticator,certbot,dns,dns-01,dnsmanager,dnsmgr,ispsystem,letsencrypt,plugin
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Plugins
14
+ Classifier: Intended Audience :: System Administrators
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Topic :: Internet :: Name Service (DNS)
26
+ Classifier: Topic :: Security
27
+ Classifier: Topic :: System :: Installation/Setup
28
+ Classifier: Topic :: System :: Networking
29
+ Classifier: Topic :: System :: Systems Administration
30
+ Classifier: Topic :: Utilities
31
+ Requires-Python: >=3.9
32
+ Requires-Dist: acme>=2.11.0
33
+ Requires-Dist: certbot>=2.11.0
34
+ Requires-Dist: requests
35
+ Description-Content-Type: text/markdown
36
+
37
+ # certbot-dns-dnsmgr
38
+
39
+ Плагин-аутентификатор для [Certbot](https://certbot.eff.org/), работающий с DNS через [DNSmanager](https://www.ispsystem.com/dnsmanager) от ISPsystem.
40
+
41
+ Плагин автоматизирует прохождение проверки `dns-01`: создаёт TXT-запись через API DNSmanager, а после проверки удаляет её.
42
+
43
+ ## Настройка DNSmanager
44
+
45
+ Пользователь, от имени которого работает API, должен видеть список доменов (зон) и уметь управлять их ресурсными записями. Плагин сам выбирает в DNSmanager самую длинную зону, подходящую под проверяемый домен, поэтому работают и зоны вида `example.com`, и `example.co.uk`.
46
+
47
+ ## Установка
48
+
49
+ Плагин нужно ставить в то же Python-окружение, в котором установлен Certbot:
50
+
51
+ ```bash
52
+ pip install certbot-dns-dnsmgr
53
+ ```
54
+
55
+ Certbot, установленный через snap, не видит плагины из PyPI. В этом случае используйте Certbot, установленный через pip или пакетный менеджер, или Docker (см. ниже).
56
+
57
+ Проверить, что Certbot видит плагин:
58
+
59
+ ```bash
60
+ certbot plugins
61
+ ```
62
+
63
+ ## Аргументы командной строки
64
+
65
+ Чтобы Certbot проходил DNS-проверку через DNSmanager, передайте ему следующие аргументы:
66
+
67
+ | Аргумент | Описание |
68
+ | -------- | -------- |
69
+ | `--authenticator dns-dnsmgr` | Выбрать этот плагин (обязательно). |
70
+ | `--dns-dnsmgr-credentials` | INI-файл с учётными данными API DNSmanager. Обязателен, если учётные данные не переданы в командной строке. |
71
+ | `--dns-dnsmgr-username` | Имя пользователя DNSmanager (вместо INI-файла). |
72
+ | `--dns-dnsmgr-password` | Пароль DNSmanager (вместо INI-файла). |
73
+ | `--dns-dnsmgr-endpoint` | URL API DNSmanager, например `https://dns.example.com:1500/dnsmgr` (вместо INI-файла). |
74
+ | `--dns-dnsmgr-insecure` | Не проверять TLS-сертификат API DNSmanager (для самоподписанных сертификатов). |
75
+ | `--dns-dnsmgr-propagation-seconds` | Сколько секунд ждать распространения DNS, прежде чем просить ACME-сервер проверить запись. По умолчанию 10. |
76
+
77
+ ## Учётные данные
78
+
79
+ Пример файла `credentials.ini`:
80
+
81
+ ```ini
82
+ dns_dnsmgr_username = admin
83
+ dns_dnsmgr_password = mysecretpassword
84
+ dns_dnsmgr_endpoint = https://dns.example.com:1500/dnsmgr
85
+ # Раскомментируйте, если у панели самоподписанный сертификат
86
+ # dns_dnsmgr_insecure = true
87
+ ```
88
+
89
+ Если endpoint не заканчивается на `/dnsmgr`, суффикс добавляется автоматически.
90
+
91
+ Путь к файлу можно ввести интерактивно или передать аргументом `--dns-dnsmgr-credentials`. Certbot запоминает путь к файлу, чтобы использовать его при продлении, но содержимое файла не сохраняет.
92
+
93
+ Если файл доступен другим пользователям системы, Certbot выводит предупреждение «Unsafe permissions on credentials configuration file» с путём к файлу. Оно появляется при каждом использовании файла, в том числе при продлении. Убрать его можно только исправив права доступа, например командой `chmod 600`.
94
+
95
+ ## Примеры
96
+
97
+ Получить один сертификат на `example.com` и `*.example.com` с ожиданием распространения DNS 90 секунд:
98
+
99
+ ```bash
100
+ certbot certonly \
101
+ --authenticator dns-dnsmgr \
102
+ --dns-dnsmgr-credentials /etc/letsencrypt/.secrets/domain.tld.ini \
103
+ --dns-dnsmgr-propagation-seconds 90 \
104
+ --server https://acme-v02.api.letsencrypt.org/directory \
105
+ --agree-tos \
106
+ --rsa-key-size 4096 \
107
+ -d 'example.com' \
108
+ -d '*.example.com'
109
+ ```
110
+
111
+ Получить сертификат, передав учётные данные прямо в командной строке. Для скриптов так проще, но менее безопасно, если скрипт не защищён:
112
+
113
+ ```bash
114
+ certbot certonly \
115
+ --authenticator dns-dnsmgr \
116
+ --dns-dnsmgr-username admin \
117
+ --dns-dnsmgr-password mysecretpassword \
118
+ --dns-dnsmgr-endpoint https://dns.example.com:1500/dnsmgr \
119
+ --dns-dnsmgr-propagation-seconds 900 \
120
+ -d example.com
121
+ ```
122
+
123
+ ## Docker
124
+
125
+ Чтобы собрать Docker-образ с плагином, создайте в пустом каталоге такой `Dockerfile`:
126
+
127
+ ```dockerfile
128
+ FROM certbot/certbot
129
+ RUN pip install certbot-dns-dnsmgr
130
+ ```
131
+
132
+ Соберите образ:
133
+
134
+ ```bash
135
+ docker build -t certbot/dns-dnsmgr .
136
+ ```
137
+
138
+ После сборки запускайте так:
139
+
140
+ ```bash
141
+ docker run --rm \
142
+ -v /var/lib/letsencrypt:/var/lib/letsencrypt \
143
+ -v /etc/letsencrypt:/etc/letsencrypt \
144
+ --cap-drop=all \
145
+ certbot/dns-dnsmgr certonly \
146
+ --authenticator dns-dnsmgr \
147
+ --dns-dnsmgr-propagation-seconds 900 \
148
+ --dns-dnsmgr-credentials \
149
+ /etc/letsencrypt/.secrets/domain.tld.ini \
150
+ --no-self-upgrade \
151
+ --keep-until-expiring --non-interactive --expand \
152
+ --server https://acme-v02.api.letsencrypt.org/directory \
153
+ -d example.com -d '*.example.com'
154
+ ```
155
+
156
+ Каталог с секретами рекомендуется защитить:
157
+
158
+ ```bash
159
+ chown root:root /etc/letsencrypt/.secrets
160
+ chmod 700 /etc/letsencrypt/.secrets
161
+ chmod 600 /etc/letsencrypt/.secrets/*.ini
162
+ ```
@@ -0,0 +1,126 @@
1
+ # certbot-dns-dnsmgr
2
+
3
+ Плагин-аутентификатор для [Certbot](https://certbot.eff.org/), работающий с DNS через [DNSmanager](https://www.ispsystem.com/dnsmanager) от ISPsystem.
4
+
5
+ Плагин автоматизирует прохождение проверки `dns-01`: создаёт TXT-запись через API DNSmanager, а после проверки удаляет её.
6
+
7
+ ## Настройка DNSmanager
8
+
9
+ Пользователь, от имени которого работает API, должен видеть список доменов (зон) и уметь управлять их ресурсными записями. Плагин сам выбирает в DNSmanager самую длинную зону, подходящую под проверяемый домен, поэтому работают и зоны вида `example.com`, и `example.co.uk`.
10
+
11
+ ## Установка
12
+
13
+ Плагин нужно ставить в то же Python-окружение, в котором установлен Certbot:
14
+
15
+ ```bash
16
+ pip install certbot-dns-dnsmgr
17
+ ```
18
+
19
+ Certbot, установленный через snap, не видит плагины из PyPI. В этом случае используйте Certbot, установленный через pip или пакетный менеджер, или Docker (см. ниже).
20
+
21
+ Проверить, что Certbot видит плагин:
22
+
23
+ ```bash
24
+ certbot plugins
25
+ ```
26
+
27
+ ## Аргументы командной строки
28
+
29
+ Чтобы Certbot проходил DNS-проверку через DNSmanager, передайте ему следующие аргументы:
30
+
31
+ | Аргумент | Описание |
32
+ | -------- | -------- |
33
+ | `--authenticator dns-dnsmgr` | Выбрать этот плагин (обязательно). |
34
+ | `--dns-dnsmgr-credentials` | INI-файл с учётными данными API DNSmanager. Обязателен, если учётные данные не переданы в командной строке. |
35
+ | `--dns-dnsmgr-username` | Имя пользователя DNSmanager (вместо INI-файла). |
36
+ | `--dns-dnsmgr-password` | Пароль DNSmanager (вместо INI-файла). |
37
+ | `--dns-dnsmgr-endpoint` | URL API DNSmanager, например `https://dns.example.com:1500/dnsmgr` (вместо INI-файла). |
38
+ | `--dns-dnsmgr-insecure` | Не проверять TLS-сертификат API DNSmanager (для самоподписанных сертификатов). |
39
+ | `--dns-dnsmgr-propagation-seconds` | Сколько секунд ждать распространения DNS, прежде чем просить ACME-сервер проверить запись. По умолчанию 10. |
40
+
41
+ ## Учётные данные
42
+
43
+ Пример файла `credentials.ini`:
44
+
45
+ ```ini
46
+ dns_dnsmgr_username = admin
47
+ dns_dnsmgr_password = mysecretpassword
48
+ dns_dnsmgr_endpoint = https://dns.example.com:1500/dnsmgr
49
+ # Раскомментируйте, если у панели самоподписанный сертификат
50
+ # dns_dnsmgr_insecure = true
51
+ ```
52
+
53
+ Если endpoint не заканчивается на `/dnsmgr`, суффикс добавляется автоматически.
54
+
55
+ Путь к файлу можно ввести интерактивно или передать аргументом `--dns-dnsmgr-credentials`. Certbot запоминает путь к файлу, чтобы использовать его при продлении, но содержимое файла не сохраняет.
56
+
57
+ Если файл доступен другим пользователям системы, Certbot выводит предупреждение «Unsafe permissions on credentials configuration file» с путём к файлу. Оно появляется при каждом использовании файла, в том числе при продлении. Убрать его можно только исправив права доступа, например командой `chmod 600`.
58
+
59
+ ## Примеры
60
+
61
+ Получить один сертификат на `example.com` и `*.example.com` с ожиданием распространения DNS 90 секунд:
62
+
63
+ ```bash
64
+ certbot certonly \
65
+ --authenticator dns-dnsmgr \
66
+ --dns-dnsmgr-credentials /etc/letsencrypt/.secrets/domain.tld.ini \
67
+ --dns-dnsmgr-propagation-seconds 90 \
68
+ --server https://acme-v02.api.letsencrypt.org/directory \
69
+ --agree-tos \
70
+ --rsa-key-size 4096 \
71
+ -d 'example.com' \
72
+ -d '*.example.com'
73
+ ```
74
+
75
+ Получить сертификат, передав учётные данные прямо в командной строке. Для скриптов так проще, но менее безопасно, если скрипт не защищён:
76
+
77
+ ```bash
78
+ certbot certonly \
79
+ --authenticator dns-dnsmgr \
80
+ --dns-dnsmgr-username admin \
81
+ --dns-dnsmgr-password mysecretpassword \
82
+ --dns-dnsmgr-endpoint https://dns.example.com:1500/dnsmgr \
83
+ --dns-dnsmgr-propagation-seconds 900 \
84
+ -d example.com
85
+ ```
86
+
87
+ ## Docker
88
+
89
+ Чтобы собрать Docker-образ с плагином, создайте в пустом каталоге такой `Dockerfile`:
90
+
91
+ ```dockerfile
92
+ FROM certbot/certbot
93
+ RUN pip install certbot-dns-dnsmgr
94
+ ```
95
+
96
+ Соберите образ:
97
+
98
+ ```bash
99
+ docker build -t certbot/dns-dnsmgr .
100
+ ```
101
+
102
+ После сборки запускайте так:
103
+
104
+ ```bash
105
+ docker run --rm \
106
+ -v /var/lib/letsencrypt:/var/lib/letsencrypt \
107
+ -v /etc/letsencrypt:/etc/letsencrypt \
108
+ --cap-drop=all \
109
+ certbot/dns-dnsmgr certonly \
110
+ --authenticator dns-dnsmgr \
111
+ --dns-dnsmgr-propagation-seconds 900 \
112
+ --dns-dnsmgr-credentials \
113
+ /etc/letsencrypt/.secrets/domain.tld.ini \
114
+ --no-self-upgrade \
115
+ --keep-until-expiring --non-interactive --expand \
116
+ --server https://acme-v02.api.letsencrypt.org/directory \
117
+ -d example.com -d '*.example.com'
118
+ ```
119
+
120
+ Каталог с секретами рекомендуется защитить:
121
+
122
+ ```bash
123
+ chown root:root /etc/letsencrypt/.secrets
124
+ chmod 700 /etc/letsencrypt/.secrets
125
+ chmod 600 /etc/letsencrypt/.secrets/*.ini
126
+ ```
@@ -0,0 +1,94 @@
1
+ """
2
+ The `~certbot_dns_dnsmgr.dns_dnsmgr` plugin automates the process of
3
+ completing a ``dns-01`` challenge (`~acme.challenges.DNS01`) by creating, and
4
+ subsequently removing, TXT records using the DNSmanager API.
5
+
6
+
7
+ Named Arguments
8
+ ---------------
9
+
10
+ ======================================== =====================================
11
+ ``--dns-dnsmgr-credentials`` DNSmanager API credentials_
12
+ INI file. (Required unless the
13
+ username, password and endpoint are
14
+ given on the command line)
15
+ ``--dns-dnsmgr-username`` DNSmanager username.
16
+ ``--dns-dnsmgr-password`` DNSmanager password.
17
+ ``--dns-dnsmgr-endpoint`` DNSmanager API URL.
18
+ ``--dns-dnsmgr-insecure`` Do not verify the TLS certificate of
19
+ the DNSmanager API.
20
+ ``--dns-dnsmgr-propagation-seconds`` The number of seconds to wait for DNS
21
+ to propagate before asking the ACME
22
+ server to verify the DNS record.
23
+ (Default: 10)
24
+ ======================================== =====================================
25
+
26
+
27
+ Credentials
28
+ -----------
29
+
30
+ Use of this plugin requires a configuration file containing DNSmanager API
31
+ credentials (login and password of a user that can manage the domains).
32
+
33
+ .. code-block:: ini
34
+ :name: credentials.ini
35
+ :caption: Example credentials file:
36
+
37
+ # DNSmanager API credentials used by Certbot
38
+ dns_dnsmgr_username = admin
39
+ dns_dnsmgr_password = mysecretpassword
40
+ dns_dnsmgr_endpoint = https://dns.example.com:1500/dnsmgr
41
+ # Uncomment if the panel uses a self-signed certificate
42
+ # dns_dnsmgr_insecure = true
43
+
44
+ The path to this file can be provided interactively or using the
45
+ ``--dns-dnsmgr-credentials`` command-line argument. Certbot records the path
46
+ to this file for use during renewal, but does not store the file's contents.
47
+
48
+ .. caution::
49
+ You should protect these API credentials as you would a password. Users who
50
+ can read this file can use these credentials to issue arbitrary API calls on
51
+ your behalf. Users who can cause Certbot to run using these credentials can
52
+ complete a ``dns-01`` challenge to acquire new certificates or revoke
53
+ existing certificates for associated domains, even if those domains aren't
54
+ being managed by this server.
55
+
56
+ Certbot will emit a warning if it detects that the credentials file can be
57
+ accessed by other users on your system. The warning reads "Unsafe permissions
58
+ on credentials configuration file", followed by the path to the credentials
59
+ file. This warning will be emitted each time Certbot uses the credentials file,
60
+ including for renewal, and cannot be silenced except by addressing the issue
61
+ (e.g., by using a command like ``chmod 600`` to restrict access to the file).
62
+
63
+ Examples
64
+ --------
65
+
66
+ .. code-block:: bash
67
+ :caption: To acquire a certificate for ``example.com``
68
+
69
+ certbot certonly \\
70
+ --authenticator dns-dnsmgr \\
71
+ --dns-dnsmgr-credentials ~/.secrets/certbot/dnsmgr.ini \\
72
+ -d example.com
73
+
74
+ .. code-block:: bash
75
+ :caption: To acquire a single certificate for both ``example.com`` and
76
+ ``*.example.com``
77
+
78
+ certbot certonly \\
79
+ --authenticator dns-dnsmgr \\
80
+ --dns-dnsmgr-credentials ~/.secrets/certbot/dnsmgr.ini \\
81
+ -d example.com \\
82
+ -d '*.example.com'
83
+
84
+ .. code-block:: bash
85
+ :caption: To acquire a certificate for ``example.com``, waiting 240 seconds
86
+ for DNS propagation
87
+
88
+ certbot certonly \\
89
+ --authenticator dns-dnsmgr \\
90
+ --dns-dnsmgr-credentials ~/.secrets/certbot/dnsmgr.ini \\
91
+ --dns-dnsmgr-propagation-seconds 240 \\
92
+ -d example.com
93
+
94
+ """
@@ -0,0 +1,199 @@
1
+ """DNS Authenticator for DNSmanager."""
2
+ import logging
3
+ import warnings
4
+ import xml.etree.ElementTree as ET
5
+
6
+ import requests
7
+ import urllib3
8
+
9
+ from certbot import errors
10
+ from certbot.plugins import dns_common
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+ TRUE_VALUES = ("1", "true", "yes", "on")
15
+
16
+ class Authenticator(dns_common.DNSAuthenticator):
17
+ """DNS Authenticator for DNSmanager
18
+
19
+ This Authenticator uses the DNSmanager API to fulfill a dns-01 challenge.
20
+ """
21
+
22
+ description = "Obtain certificates using a DNS TXT record (if you are using DNSmanager for DNS)."
23
+ ttl = 60
24
+
25
+ def __init__(self, *args, **kwargs):
26
+ super().__init__(*args, **kwargs)
27
+ self.credentials = None
28
+
29
+ @classmethod
30
+ def add_parser_arguments(cls, add): # pylint: disable=arguments-differ
31
+ super().add_parser_arguments(add, default_propagation_seconds=10)
32
+ add("credentials", help="DNSmanager API credentials INI file.")
33
+ add("username", help="Username for DNSmanager API (can be used instead of INI file).")
34
+ add("password", help="Password for DNSmanager API (can be used instead of INI file).")
35
+ add("endpoint", help="URL of the DNSmanager API (can be used instead of INI file).")
36
+ add(
37
+ "insecure",
38
+ action="store_true",
39
+ default=False,
40
+ help="Do not verify the TLS certificate of the DNSmanager API.",
41
+ )
42
+
43
+ def more_info(self): # pylint: disable=missing-docstring
44
+ return (
45
+ "This plugin configures a DNS TXT record to respond to a dns-01 challenge using "
46
+ "the DNSmanager API."
47
+ )
48
+
49
+ def _setup_credentials(self):
50
+ if self.conf("username") and self.conf("password") and self.conf("endpoint"):
51
+ self.credentials = None
52
+ else:
53
+ self.credentials = self._configure_credentials(
54
+ "credentials",
55
+ "DNSmanager credentials INI file",
56
+ {
57
+ "endpoint": "URL of the DNSmanager API (e.g., https://example.com:1500/dnsmgr).",
58
+ "username": "Username for DNSmanager API.",
59
+ "password": "Password for DNSmanager API.",
60
+ },
61
+ )
62
+
63
+ def _perform(self, domain, validation_name, validation):
64
+ self._get_dnsmgr_client().add_txt_record(domain, validation_name, validation)
65
+
66
+ def _cleanup(self, domain, validation_name, validation):
67
+ self._get_dnsmgr_client().del_txt_record(domain, validation_name, validation)
68
+
69
+ def _get_dnsmgr_client(self):
70
+ insecure = bool(self.conf("insecure"))
71
+ if self.credentials is None:
72
+ endpoint = self.conf("endpoint")
73
+ username = self.conf("username")
74
+ password = self.conf("password")
75
+ else:
76
+ endpoint = self.credentials.conf("endpoint")
77
+ username = self.credentials.conf("username")
78
+ password = self.credentials.conf("password")
79
+ insecure = insecure or (self.credentials.conf("insecure") or "").strip().lower() in TRUE_VALUES
80
+
81
+ return _DNSmanagerClient(endpoint, username, password, self.ttl, verify=not insecure)
82
+
83
+
84
+ class _DNSmanagerClient:
85
+ """
86
+ Encapsulates all communication with the DNSmanager API.
87
+ """
88
+
89
+ def __init__(self, endpoint, username, password, ttl, verify=True):
90
+ self.endpoint = endpoint.rstrip("/")
91
+ if not self.endpoint.endswith("/dnsmgr"):
92
+ self.endpoint += "/dnsmgr"
93
+ self.authinfo = f"{username}:{password}"
94
+ self.ttl = ttl
95
+ self.verify = verify
96
+ self.session = requests.Session()
97
+
98
+ def _request(self, func, **params):
99
+ """
100
+ Call a DNSmanager API function and return the parsed XML document.
101
+ """
102
+ logger.debug("DNSmanager API request %s with params %s", func, params)
103
+ data = {"authinfo": self.authinfo, "out": "xml", "func": func}
104
+ data.update(params)
105
+
106
+ try:
107
+ with warnings.catch_warnings():
108
+ if not self.verify:
109
+ warnings.simplefilter("ignore", urllib3.exceptions.InsecureRequestWarning)
110
+ resp = self.session.post(self.endpoint, data=data, verify=self.verify, timeout=30)
111
+ resp.raise_for_status()
112
+ except requests.exceptions.RequestException as e:
113
+ raise errors.PluginError(f"Error communicating with the DNSmanager API: {e}")
114
+
115
+ try:
116
+ doc = ET.fromstring(resp.content)
117
+ except ET.ParseError:
118
+ raise errors.PluginError(f"DNSmanager API returned a non-XML response: {resp.text[:500]}")
119
+
120
+ error = doc.find("error")
121
+ if error is not None:
122
+ message = error.findtext("msg") or error.get("type") or "unknown error"
123
+ raise errors.PluginError(f"DNSmanager API error in {func}: {message}")
124
+
125
+ return doc
126
+
127
+ @staticmethod
128
+ def _elems(doc):
129
+ """
130
+ Convert the <elem> children of a list response into dicts.
131
+ """
132
+ return [
133
+ {child.tag: (child.text or "") for child in elem}
134
+ for elem in doc.findall("elem")
135
+ ]
136
+
137
+ def _find_zone(self, domain):
138
+ """
139
+ Find the DNSmanager zone the domain belongs to (the longest matching one).
140
+ """
141
+ zones = {
142
+ elem.get("name", "").rstrip(".").lower()
143
+ for elem in self._elems(self._request("domain"))
144
+ }
145
+ for guess in dns_common.base_domain_name_guesses(domain):
146
+ if guess.lower() in zones:
147
+ logger.debug("Using DNSmanager zone %s for %s", guess, domain)
148
+ return guess.lower()
149
+ raise errors.PluginError(f"Unable to find DNSmanager zone for {domain}")
150
+
151
+ def add_txt_record(self, domain, record_name, record_content):
152
+ """
153
+ Add a TXT record.
154
+ """
155
+ zone = self._find_zone(domain)
156
+ fqdn = record_name.rstrip(".") + "."
157
+ self._request(
158
+ "domain.record.edit",
159
+ plid=zone,
160
+ name=fqdn,
161
+ rtype="txt",
162
+ value=record_content,
163
+ ttl=self.ttl,
164
+ sok="ok",
165
+ )
166
+ logger.info("Added TXT record %s to zone %s", fqdn, zone)
167
+
168
+ def del_txt_record(self, domain, record_name, record_content):
169
+ """
170
+ Delete the TXT record with the given name and content.
171
+
172
+ Failures are logged, not raised: cleanup must not break certificate issuance.
173
+ """
174
+ try:
175
+ zone = self._find_zone(domain)
176
+ fqdn = record_name.rstrip(".").lower()
177
+ records = self._elems(self._request("domain.record", elid=zone))
178
+
179
+ deleted = 0
180
+ for record in records:
181
+ if record.get("rtype", "").upper() != "TXT":
182
+ continue
183
+ if record.get("value", "").strip('"') != record_content:
184
+ continue
185
+ name = record.get("name", "").rstrip(".").lower()
186
+ if name != fqdn and f"{name}.{zone}" != fqdn:
187
+ continue
188
+ rkey = record.get("rkey")
189
+ if not rkey:
190
+ logger.warning("TXT record %s has no rkey, cannot delete it", fqdn)
191
+ continue
192
+ self._request("domain.record.delete", plid=zone, elid=rkey)
193
+ logger.info("Deleted TXT record %s from zone %s", fqdn, zone)
194
+ deleted += 1
195
+
196
+ if deleted == 0:
197
+ logger.debug("No TXT record %s with the given content found to delete", fqdn)
198
+ except errors.PluginError as e:
199
+ logger.warning("Unable to delete TXT record %s: %s", record_name, e)
@@ -0,0 +1,60 @@
1
+ [project]
2
+ name = "certbot-dns-dnsmgr"
3
+ version = "1.0.0"
4
+ description = "DNSmanager (ISPsystem) DNS Authenticator plugin for Certbot"
5
+ authors = [
6
+ { name = "Dmitry Sergeev", email = "everestmx@gmail.com" }
7
+ ]
8
+ license = "Apache-2.0"
9
+ license-files = ["LICENSE"]
10
+ readme = "README.md"
11
+ requires-python = ">=3.9"
12
+ keywords = ["certbot", "dns", "dnsmanager", "dnsmgr", "ispsystem", "letsencrypt", "acme", "dns-01", "authenticator", "plugin"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Environment :: Plugins",
16
+ "Intended Audience :: System Administrators",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Topic :: Internet :: Name Service (DNS)",
28
+ "Topic :: Security",
29
+ "Topic :: System :: Installation/Setup",
30
+ "Topic :: System :: Networking",
31
+ "Topic :: System :: Systems Administration",
32
+ "Topic :: Utilities",
33
+ ]
34
+ dependencies = [
35
+ "acme>=2.11.0",
36
+ "certbot>=2.11.0",
37
+ "requests",
38
+ ]
39
+
40
+ [project.urls]
41
+ Homepage = "https://github.com/everestmx/certbot-dns-dnsmgr"
42
+ Source = "https://github.com/everestmx/certbot-dns-dnsmgr"
43
+ Issues = "https://github.com/everestmx/certbot-dns-dnsmgr/issues"
44
+
45
+ [project.entry-points."certbot.plugins"]
46
+ dns-dnsmgr = "certbot_dns_dnsmgr.dns_dnsmgr:Authenticator"
47
+
48
+ [build-system]
49
+ requires = ["hatchling>=1.27"]
50
+ build-backend = "hatchling.build"
51
+
52
+ # Only ship the package and docs: the project root may contain real
53
+ # credentials (e.g. dnsmgr.ini) and IDE files.
54
+ [tool.hatch.build.targets.sdist]
55
+ only-include = ["certbot_dns_dnsmgr", "README.md", "LICENSE", "pyproject.toml"]
56
+ exclude = ["__pycache__", "*.pyc"]
57
+
58
+ [tool.hatch.build.targets.wheel]
59
+ packages = ["certbot_dns_dnsmgr"]
60
+ exclude = ["__pycache__", "*.pyc"]