Skip to content

Commit ed3ede4

Browse files
committed
Add cname support for certificates
Signed-off-by: Eric D. Helms <[email protected]>
1 parent e9d0c35 commit ed3ede4

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

docs/certificates.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,19 @@ 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-
### Current Limitations
54+
### CNAME Support
5555

56-
- Only supports single hostname (no multiple DNS names)
57-
- Cannot provide custom certificate files during deployment
58-
- Fixed 20-year certificate validity period
59-
- Limited certificate customization options
56+
foremanctl supports Subject Alternative Names (SANs) for multi-domain certificates:
6057

61-
---
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.
6267

6368
## Internal Design
6469

@@ -89,7 +94,8 @@ src/roles/certificates/
8994

9095
2. **Host Certificate Issuance** (for each hostname in `certificates_hostnames`):
9196
- Generate 4096-bit RSA private key
92-
- Create certificate signing request (CSR)
97+
- Create certificate signing request (CSR) with Subject Alternative Names
98+
- Include primary hostname and any additional CNAMEs from `certificate_cname`
9399
- Sign certificate with CA (includes serverAuth/clientAuth extensions)
94100
- Generate both server and client certificates per hostname
95101

@@ -146,5 +152,6 @@ The `certificate_checks` role uses `foreman-certificate-check` binary to validat
146152
147153
**OpenSSL Configuration:**
148154
- 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
155+
- Multiple DNS entries supported: `subjectAltName = DNS:{{ certificates_hostname }}{% for cname in certificate_cname %},DNS:{{ cname }}{% endfor %}`
156+
- Uses OpenSSL's `req` and `ca` commands for generation and signing
157+
- CNAMEs configured via `certificate_cname` variable (list of additional DNS names)

docs/parameters.md

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

5959
| Parameter | Description | foreman-installer Parameter |
6060
| ----------| ----------- | --------------------------- |
61+
| `--certificate-cname` | Allows defining CNAME for default certificates | --certs-cname |
6162

6263
##### Unmapped
6364

@@ -76,7 +77,6 @@ There are multiple use cases from the users perspective that dictate what parame
7677
| `--foreman-plugin-tasks-cron-line` | | foreman::plugin::tasks | cron_line |
7778
| `--foreman-plugin-tasks-automatic-cleanup` | | foreman::plugin::tasks | automatic_cleanup |
7879
| `--tuning` | Sets the tuning profile | foreman-installer | |
79-
| `--certs-cname` | | certs | cname |
8080
| `--certs-tar` | | certs | tar |
8181
| `--certs-tar-file` | | certs | tar |
8282
| `--certs-server-cert` | | certs | server_cert |

src/playbooks/deploy/metadata.obsah.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ variables:
1111
help: Number of workers for Puma.
1212
pulp_worker_count:
1313
help: Number of Pulp workers. Defaults to 8 or the number of CPU cores, whichever is smaller.
14+
certificates_cnames:
15+
help: Additional DNS name to include in Subject Alternative Names for certificates. Can be specified multiple times.
16+
action: append
17+
parameter: --certificate-cname
1418

1519
include:
1620
- _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)