Refactor certificates role to normalize server and client certificate…#89
Conversation
67f6872 to
d68d99a
Compare
ca0e6fb to
b41d1f9
Compare
|
Again, this also makes me think about how we could implement an ACME client to get what we used to call custom certificates |
I am more focused on the "input", the interface for providing certificates and so think of this certificate role as a reference implementation. |
|
I often feel Ansible with all of its variables doesn't make a clear distinction between (user) input and (intermediate) output. It's late so I'm not going to thoroughly review it now, but perhaps it's already something to think about |
b41d1f9 to
f801daf
Compare
Oh I have :) But baby steps.. first this re-factor, then my take on that part as this helps pave the way. |
07b9334 to
d16c3fe
Compare
ekohl
left a comment
There was a problem hiding this comment.
This may be taking it a step too far in this PR, but I'd be tempted to work towards getting rid of the separate server and client certs. In vanilla Foreman we (by default) always used the same certificates to be the server and the client.
In other words, stop generating separate server certs and make server_certificate and server_key default to client_certificate and client_key. If a user provides server certs, they are expected to already be signed by some CA.
This will be an issue for services that we run on localhost today because no respected CA should ever sign a certificate for localhost, but that's the general direction I'd like to move to.
| -config "{{ certificates_ca_directory }}/openssl.cnf" | ||
| -key "{{ certificates_ca_directory_keys }}/{{ certificates_hostname }}.key" | ||
| -subj "/CN={{ certificates_hostname }}" | ||
| -addext "subjectAltName = DNS:{{ certificates_hostname }}" |
There was a problem hiding this comment.
I have a recollection that by default the extension isn't copied over when calling openssl ca. https://stackoverflow.com/questions/33989190/subject-alternative-name-is-not-copied-to-signed-certificate mentions you should use -copy_extensions copyall when signing
I think this is a fair design goal that we can work to support. The current certificates implementation for upgrades will be the The place I'd like to end up with is to have the following:
Then for example, we can document it was a client certificate is needed here and a server certificate need there. You the user can choose to have a single certificate for both, that has both client and server purpose. Or you can choose to split them into dedicated purposes if you want that level of separation of concern. |
|
I was wondering how to verify this. Could we somehow run |
I think adding some tests to ensure this role does what we expect and vets the generated certificates against This started as a re-factor to better be in service of I'll look at adding some tests and verification. |
104be95 to
72da991
Compare
|
I added a role to run certificate check using katello-certs-check. And, for this iteration, pulled out the certificate variables generated into a vars fie. This draws the line between user input and "internal" input parameters. @evgeni I am thinking then for the installer split work, instead of defining them directly (f425856) you can provide a vars file that defines the certificates coming from |
4c98c80 to
f6116f6
Compare
d9a82a0 to
ec884a8
Compare
… creation Signed-off-by: Eric D. Helms <[email protected]>
ec884a8 to
ff352bd
Compare
| creates: "{{ certificates_ca_directory_certs }}/{{ certificates_client }}.crt" | ||
| - name: 'Generate CA certificate' | ||
| ansible.builtin.include_tasks: ca.yml | ||
| when: certificates_ca |
There was a problem hiding this comment.
Under which circumstances would this be false?
There was a problem hiding this comment.
When generating a certificate bundle for use on proxies - https://github.com/theforeman/foreman-quadlet/pull/90/files#diff-b1491adbed08c8b00b570245e695c525e8dbf2a9ef94181d292272ffae52b5a5R6
There was a problem hiding this comment.
Ah, so you ran this once with certificates_ca: true to create a CA, and then you run it with false (on the same machine) to create the bundle (with a new hostname -- for a different machine) without regenerating the CA?
Does that imply ca.yml is not idempotent? Or is that pure speed optimization?
(Reading the playbook I think it's idempotent?)
There was a problem hiding this comment.
Speed and safety optimization I suppose. I was also not sure how the design would fall out where something else provided the certificates yet (e.g. puppet-certs). I am still not 100% and this will get re-factored as we iterate.
|
I like this, especially as it makes my "use puppet-certs certs with quadlet" frankenstein easier. And tests are also passing, so 🎉 |
ekohl
left a comment
There was a problem hiding this comment.
I like the change where a lot of the fields on the cert become optional. It always bothered me we had those weird defaults that probably nobody changed and served no purpose.
Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
… creation