Skip to content

Commit 4e8095f

Browse files
avalor1Andreas HeringAndreas Heringrndmh3roschurzi
authored
Add ECC key creation support (#95)
* Trigger tests * Trigger more tests * Add ecc key support and set as default * Linting: var-naming[no-role-prefix] - Prefix variable names with role_name - Make registered variables naming more clear with the result suffix * Adjust challenge variable naming for every challenge provider * Add key curve variable to documentation * Apply suggestions from code review Set 4096bit default keysize in case RSA is used Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com> Co-authored-by: schurzi <Martin.Schurz@t-systems.com> * Fix "intendation" for pipes * Remove unused variable registration * Fix variable naming --------- Co-authored-by: Andreas Hering <andreas.hering@t-systems.com> Co-authored-by: Andreas Hering <andreas.hering@telekom.de> Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com> Co-authored-by: schurzi <Martin.Schurz@t-systems.com>
1 parent 12c72ae commit 4e8095f

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

docs/role-acme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,17 @@ If you are running this role in a temporary environment such as a CI runner and
7171
| acme_staging_directory | no | acme-staging-v02.api.letsencrypt.org | Acme directory which will be used for certificate challenge
7272
| acme_live_directory | no | acme-v02.api.letsencrypt.org | Acme directory which will be used for certificate challenge
7373
| acme_account_key_path | no | $acme_conf_dir | Path for account key
74+
| acme_account_key_size | no | 4096 | Account key size
75+
| acme_account_key_type | no | ECC | Account key type
76+
| acme_account_key_curve | no | secp384r1 | Account key curve used
7477
| acme_csr_path | no | $acme_conf_dir/certs | Path for csr which is created for challenge
7578
| acme_cert_path | no | $acme_conf_dir/certs | Path for issued certificate
7679
| acme_intermediate_path | no | $acme_conf_dir/certs | Path for intermediate chain
7780
| acme_fullchain_path | no | $acme_conf_dir/certs | Path for full chain file (certificate + intermediate)
7881
| acme_private_key_path | no | $acme_conf_dir/certs | Path for private key
82+
| acme_private_key_size | no | 4096 | Private key size
83+
| acme_private_key_type | no | ECC | Private key type
84+
| acme_private_key_curve | no | secp384r1 | Private key curve used
7985
| acme_remaining_days | no | 30 | Min days remaining before certificate will be renewed
8086
| acme_convert_cert_to | no | | Format to convert the certificate to: `pfx`
8187
| acme_validate_certs | no | | Only used in integration tests with pebble server

roles/acme/defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ acme_staging_directory: https://acme-staging-v02.api.letsencrypt.org/directory
99
acme_live_directory: https://acme-v02.api.letsencrypt.org/directory
1010
acme_use_live_directory: false
1111
acme_account_key_path: "{{ acme_conf_dir }}/letsencrypt_account.pem"
12+
acme_account_key_size: "4096"
13+
acme_account_key_type: "ECC"
14+
acme_account_key_curve: "secp384r1"
1215
acme_csr_path: "{{ acme_cert_dir }}/{{ acme_domain.certificate_name }}.csr"
1316
acme_cert_path: "{{ acme_cert_dir }}/{{ acme_domain.certificate_name }}.pem"
1417
acme_pfx_cert_path: "{{ acme_cert_dir }}/{{ acme_domain.certificate_name }}.pfx"
1518
acme_intermediate_path: "{{ acme_cert_dir }}/{{ acme_domain.certificate_name }}_intermediate.pem"
1619
acme_fullchain_path: "{{ acme_cert_dir }}/{{ acme_domain.certificate_name }}_fullchain.pem"
1720
acme_private_key_path: "{{ acme_cert_dir }}/{{ acme_domain.certificate_name }}.key"
21+
acme_private_key_size: "4096"
22+
acme_private_key_type: "ECC"
23+
acme_private_key_curve: "secp384r1"
1824
acme_remaining_days: "30"
1925

2026
### provider specific config

roles/acme/tasks/challenge/dns-01/autodns.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
method: POST
1010
body_format: json
1111
body: { context: "4", user: "{{ acme_dns_user }}", password: "{{ acme_dns_password }}" }
12-
register: login
12+
register: acme_login
1313

1414
- name: Add a new TXT record to the SAN domains
1515
ansible.builtin.uri:
@@ -33,7 +33,7 @@
3333
]
3434
}
3535
headers:
36-
Cookie: "{{ login.set_cookie }}"
36+
Cookie: "{{ acme_login.set_cookie }}"
3737
loop: "{{ acme_domain.subject_alt_name }}"
3838
when:
3939
- acme_domain.subject_alt_name is defined
@@ -75,7 +75,7 @@
7575
]
7676
}
7777
headers:
78-
Cookie: "{{ login.set_cookie }}"
78+
Cookie: "{{ acme_login.set_cookie }}"
7979
loop: "{{ acme_domain.subject_alt_name }}"
8080
when:
8181
- acme_domain.subject_alt_name is defined

roles/acme/tasks/challenge/dns-01/hetzner.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
url: https://dns.hetzner.com/api/v1/zones?name={{ acme_domain.zone }}
99
headers:
1010
Auth-API-Token: "{{ acme_hetzner_auth_token }}"
11-
register: lookup_zone_id
11+
register: acme_lookup_zone_id
1212

1313
- name: Add a new TXT record to the SAN domains
1414
ansible.builtin.uri:
@@ -22,12 +22,12 @@
2222
"ttl": 60,
2323
"type": "TXT",
2424
"value": "{{ acme_challenge['challenge_data'][item]['dns-01']['resource_value'] }}",
25-
"zone_id": "{{ lookup_zone_id.json.zones[0].id }}",
25+
"zone_id": "{{ acme_lookup_zone_id.json.zones[0].id }}",
2626
}
2727
headers:
2828
Auth-API-Token: "{{ acme_hetzner_auth_token }}"
2929
loop: "{{ acme_domain.subject_alt_name }}"
30-
register: records
30+
register: acme_records
3131
when:
3232
- acme_domain.subject_alt_name is defined
3333
# only runs if the challenge is run the first time, because then there is challenge_data
@@ -59,7 +59,7 @@
5959
method: DELETE
6060
headers:
6161
Auth-API-Token: "{{ acme_hetzner_auth_token }}"
62-
loop: "{{ records | json_query('results[*].json.record.id') }}"
62+
loop: "{{ acme_records | json_query('results[*].json.record.id') }}"
6363
when:
6464
- acme_domain.subject_alt_name is defined
6565
# only runs if the challenge is run the first time, because then there is challenge_data

roles/acme/tasks/challenge/dns-01/openstack.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
name: _acme-challenge.{{ item | replace('*.', '') }}.
1515
zone: "{{ acme_domain.zone }}."
1616
loop: "{{ acme_domain.subject_alt_name }}"
17-
register: records
1817
when:
1918
- acme_domain.subject_alt_name is defined
2019
- acme_challenge['challenge_data'][item] is defined

roles/acme/tasks/create-keys.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
- name: Create RSA key to be used for acme account
2+
- name: Create key to be used for acme account
33
community.crypto.openssl_privatekey:
44
path: "{{ acme_account_key_path }}"
5-
size: 4096
6-
type: RSA
5+
size: "{{ acme_account_key_size }}"
6+
type: "{{ acme_account_key_type }}"
7+
curve: "{{ acme_account_key_curve }}"
78
when:
89
- acme_account_key_content is not defined
910
no_log: true
@@ -17,9 +18,12 @@
1718
- acme_account_key_content is defined
1819
no_log: true
1920

20-
- name: Create RSA key to be used for certificate
21+
- name: Create key to be used for certificate
2122
community.crypto.openssl_privatekey:
2223
path: "{{ acme_private_key_path }}"
24+
size: "{{ acme_private_key_size }}"
25+
type: "{{ acme_private_key_type }}"
26+
curve: "{{ acme_private_key_curve }}"
2327
when:
2428
- acme_private_key_content is not defined
2529
no_log: true

0 commit comments

Comments
 (0)