Skip to content

Commit 0eac6ad

Browse files
SvenLierndmh3ro
andauthored
Add domain-offensive as dns-01 challenge (#122)
* add domain-offensive as dns-01 challenge * Fix ansible lint for dns01: domain-offensive * Update docs/dns-challenge/domain-offensive.md --------- Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
1 parent 41d2a26 commit 0eac6ad

File tree

5 files changed

+149
-0
lines changed

5 files changed

+149
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ Here we list ways to manually test the dns-providers if you have access:
4242
ansible-playbook tests/integration/targets/acme_letsencrypt/dns-challenge-hetzner.yml -e acme_hetzner_auth_token=YOUR_AUTH_TOKEN -e hetzner_domain_name="example.com" -e hetzner_zone="example.com"
4343
```
4444
45+
* Domain-Offensive
46+
47+
```
48+
ansible-playbook tests/integration/targets/acme_letsencrypt/dns-challenge-domain-offensive.yml -e acme_dns_password=YOUR_DO_AUTH_TOKEN -e domain_offensive_zone="example.com" -e domain_offensive_domain_name="example.com"
49+
```
50+
4551
## License
4652
4753
GPLv3
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Variables for Domain Offensive dns-challenge
2+
3+
| Variable | Required | Default | Description
4+
|-------------------------|----------|---------|------------
5+
| acme_dns_password | yes | | Let's Encrypt API-Token, you can get here: [do.de](https://my.do.de/settings/domains/general)
6+
7+
## Usage
8+
9+
### wildcard certificate
10+
11+
```yaml
12+
- name: create the certificate for *.example.com
13+
hosts: localhost
14+
collections:
15+
- telekom_mms.acme
16+
roles:
17+
- acme
18+
vars:
19+
acme_domain:
20+
certificate_name: "wildcard.example.com"
21+
zone: "example.com"
22+
email_address: "ssl-admin@example.com"
23+
subject_alt_name:
24+
- "*.example.com"
25+
acme_challenge_provider: domain-offensive
26+
acme_use_live_directory: false
27+
acme_account_email: "ssl-admin@example.com"
28+
acme_dns_password: !vault |
29+
$ANSIBLE_VAULT;1.1;AES256
30+
...
31+
```
32+
33+
### SAN certificate
34+
35+
```yaml
36+
- name: create the certificate for example.com
37+
hosts: localhost
38+
collections:
39+
- telekom_mms.acme
40+
roles:
41+
- acme
42+
vars:
43+
acme_domain:
44+
certificate_name: "wildcard.example.com"
45+
zone: "example.com"
46+
email_address: "ssl-admin@example.com"
47+
subject_alt_name:
48+
- "example.com"
49+
- "domain1.example.com"
50+
- "domain2.example.com"
51+
acme_challenge_provider: domain-offensive
52+
acme_use_live_directory: false
53+
acme_account_email: "ssl-admin@example.com"
54+
acme_dns_password: !vault |
55+
$ANSIBLE_VAULT;1.1;AES256
56+
...
57+
```

docs/role-acme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Feel free to contribute more DNS or HTTP APIs :)
1414
* DNS-01
1515
* [AutoDNS](/docs/dns-challenge/autodns.md)
1616
* [Azure](/docs/dns-challenge/azure.md)
17+
* [Domain Offensive](/docs/dns-challenge/domain-offensive.md)
1718
* [hetzner](/docs/dns-challenge/hetzner.md)
1819
* [openstack](/docs/dns-challenge/openstack.md)
1920
* [pebble](/docs/dns-challenge/pebble.md)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
### include/role 3 - validate challenge
3+
- name: Validate challenge only if it is created or changed # noqa no-handler
4+
when: acme_challenge is changed
5+
block:
6+
- name: Add a new TXT record to the SAN domains
7+
ansible.builtin.uri:
8+
url: "https://my.do.de/api/letsencrypt"
9+
body_format: form-multipart
10+
body:
11+
token: "{{ acme_dns_password }}"
12+
domain: "_acme-challenge.{{ item | replace('*.', '') }}"
13+
value: "{{ acme_challenge['challenge_data'][item]['dns-01']['resource_value'] }}"
14+
ttl: "120"
15+
method: POST
16+
loop: "{{ acme_domain.subject_alt_name }}"
17+
when:
18+
- acme_domain.subject_alt_name is defined
19+
# only runs if the challenge is run the first time, because then there is challenge_data
20+
- acme_challenge['challenge_data'][item] is defined
21+
22+
- name: Let the challenge be validated and retrieve the cert and intermediate certificate
23+
community.crypto.acme_certificate:
24+
account_key_src: "{{ acme_account_key_path }}"
25+
account_email: "{{ acme_account_email }}"
26+
csr: "{{ acme_csr_path }}"
27+
cert: "{{ acme_cert_path }}"
28+
fullchain: "{{ acme_fullchain_path }}"
29+
chain: "{{ acme_intermediate_path }}"
30+
challenge: dns-01
31+
force: "{{ acme_force_renewal | default(false) }}"
32+
acme_directory: "{{ acme_directory }}"
33+
acme_version: 2
34+
terms_agreed: true
35+
remaining_days: "{{ acme_remaining_days }}"
36+
data: "{{ acme_challenge }}"
37+
38+
always:
39+
- name: Remove created SAN TXT records to keep DNS zone clean
40+
ansible.builtin.uri:
41+
url: "https://my.do.de/api/letsencrypt"
42+
body_format: form-multipart
43+
body:
44+
token: "{{ acme_dns_password }}"
45+
domain: "_acme-challenge.{{ item | replace('*.', '') }}"
46+
value: "{{ acme_challenge['challenge_data'][item]['dns-01']['resource_value'] }}"
47+
action: delete
48+
method: POST
49+
loop: "{{ acme_domain.subject_alt_name }}"
50+
when:
51+
- acme_domain.subject_alt_name is defined
52+
# only runs if the challenge is run the first time, because then there is challenge_data
53+
- acme_challenge['challenge_data'][item] is defined
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
- name: Create a test certificate for domain-offensive
3+
hosts: localhost
4+
roles:
5+
- telekom_mms.acme.acme
6+
vars:
7+
acme_challenge_provider: domain-offensive
8+
acme_use_live_directory: false
9+
acme_account_email: ssl-admin@example.de
10+
acme_force_renewal: true
11+
acme_domain:
12+
email_address: ssl-admin@example.de
13+
certificate_name: "{{ domain_offensive_zone }}"
14+
zone: "{{ domain_offensive_zone }}"
15+
subject_alt_name:
16+
- "{{ domain_offensive_domain_name }}"
17+
post_tasks:
18+
- name: Validate certs
19+
community.crypto.x509_certificate_info:
20+
path: "{{ acme_cert_path }}"
21+
register: result
22+
23+
- name: Print the certificate
24+
ansible.builtin.debug:
25+
msg: "{{ result }}"
26+
27+
- name: Check if the certificate has correct data
28+
ansible.builtin.assert:
29+
that:
30+
- result.subject.commonName == "{{ acme_domain.certificate_name }}"
31+
- "'DNS:{{ acme_domain.certificate_name }}' in result.subject_alt_name"
32+
- "'(STAGING) Artificial Apricot R3' in result.issuer.commonName"

0 commit comments

Comments
 (0)