Skip to content

Commit 96c1991

Browse files
committed
Add cname support for certificates
Signed-off-by: Eric D. Helms <ericdhelms@gmail.com>
1 parent 64a5620 commit 96c1991

5 files changed

Lines changed: 27 additions & 7 deletions

File tree

docs/certificates.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,26 @@ After deployment, certificates are available at:
5151
- Server Certificate: `/root/ssl-build/<hostname>/<hostname>-apache.crt`
5252
- Client Certificate: `/root/ssl-build/<hostname>/<hostname>-foreman-client.crt`
5353

54+
### CNAME Support
55+
56+
foremanctl supports Subject Alternative Names (SANs) for multi-domain certificates:
57+
58+
```bash
59+
# Generate certificates with multiple DNS names
60+
foremanctl deploy \
61+
--certificate-cname api.example.com \
62+
--certificate-cname foreman.example.com \
63+
--certificate-cname satellite.example.com
64+
```
65+
66+
When CNAMEs are specified, certificates will include all names in the Subject Alternative Name field, allowing the same certificate to be valid for multiple hostnames.
67+
5468
### Current Limitations
5569

56-
- Only supports single hostname (no multiple DNS names)
5770
- Cannot provide custom certificate files during deployment
5871
- Fixed 20-year certificate validity period
5972
- Limited certificate customization options
6073

61-
---
62-
6374
## Internal Design
6475

6576
### Architecture
@@ -89,7 +100,8 @@ src/roles/certificates/
89100

90101
2. **Host Certificate Issuance** (for each hostname in `certificates_hostnames`):
91102
- Generate 4096-bit RSA private key
92-
- Create certificate signing request (CSR)
103+
- Create certificate signing request (CSR) with Subject Alternative Names
104+
- Include primary hostname and any additional CNAMEs from `certificate_cname`
93105
- Sign certificate with CA (includes serverAuth/clientAuth extensions)
94106
- Generate both server and client certificates per hostname
95107

@@ -146,5 +158,6 @@ The `certificate_checks` role uses `foreman-certificate-check` binary to validat
146158
147159
**OpenSSL Configuration:**
148160
- Custom configuration template supports SAN extensions
149-
- Single DNS entry per certificate: `subjectAltName = DNS:{{ certificates_hostname }}`
150-
- Uses OpenSSL's `req` and `ca` commands for generation and signing
161+
- Multiple DNS entries supported: `subjectAltName = DNS:{{ certificates_hostname }}{% for cname in certificate_cname %},DNS:{{ cname }}{% endfor %}`
162+
- Uses OpenSSL's `req` and `ca` commands for generation and signing
163+
- CNAMEs configured via `certificate_cname` variable (list of additional DNS names)

docs/parameters.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ There are multiple use cases from the users perspective that dictate what parame
6161

6262
| Parameter | Description | foreman-installer Parameter |
6363
| ----------| ----------- | --------------------------- |
64+
| `--certificate-cname` | Allows defining CNAME for default certificates | --certs-cname |
6465

6566
##### Unmapped
6667

src/playbooks/deploy/metadata.obsah.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ variables:
1818
- ipa_with_api
1919
external_authentication_pam_service:
2020
help: Name of the PAM service to use for IPA authentication
21+
certificates_cnames:
22+
help: Additional DNS name to include in Subject Alternative Names for certificates. Can be specified multiple times.
23+
action: append_unique
24+
type: FQDN
25+
parameter: --certificate-cname
2126

2227
include:
2328
- _certificate_source

src/roles/certificates/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ certificates_ca_directory: /root/certificates # Change this to /var/lib?
44
certificates_ca_directory_keys: "{{ certificates_ca_directory }}/private"
55
certificates_ca_directory_certs: "{{ certificates_ca_directory }}/certs"
66
certificates_ca_directory_requests: "{{ certificates_ca_directory }}/requests"
7+
certificates_cnames: []

src/roles/certificates/tasks/issue.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
-config "{{ certificates_ca_directory }}/openssl.cnf"
1515
-key "{{ certificates_ca_directory_keys }}/{{ certificates_hostname }}.key"
1616
-subj "/CN={{ certificates_hostname }}"
17-
-addext "subjectAltName = DNS:{{ certificates_hostname }}"
17+
-addext "subjectAltName = DNS:{{ certificates_hostname }}{% for cname in certificates_cnames %},DNS:{{ cname }}{% endfor %}"
1818
-out "{{ certificates_ca_directory_requests }}/{{ certificates_hostname }}.csr"
1919
args:
2020
creates: "{{ certificates_ca_directory_requests }}/{{ certificates_hostname }}.csr"

0 commit comments

Comments
 (0)