Use community.crypto for the certificates role#441
Conversation
|
@ehelms review please. This needs more testing on a prod-like setup. It worked on my dev setup, but I'd like to do more testing once you confirm it's a good direction. |
905fb90 to
e8b4ff3
Compare
|
As there are other properties that could also change, I wonder if we would be better served by switching to the https://docs.ansible.com/projects/ansible/latest/collections/community/crypto/ For example: |
e8b4ff3 to
62bcef4
Compare
62bcef4 to
30ea6d6
Compare
|
First, thanks for doing a version of this with the community collection @stejskalleos, this helps see and think about the differences. I see the community module can generate EC certificates which is good. I am thinking ahead to PQC and this will require us to rely on cryptography to support that. The trade-off on approaches as I see them: Using OpenSSL directly
Using community collection
I'd like to get more opinion on this, especially form @evgeni |
|
I think depending on python3-cryptography is an OK thing to do. |
30ea6d6 to
0ffe0c1
Compare
0ffe0c1 to
cdb5977
Compare
Candlepin can't verify the signature. Should we re-regenerate manifest? |
|
re-generate with what? that's a static manifest that should "just work". |
|
Well, according to CI, it doesn't. |
|
The Candlepin logs (which are sadly not collected by sos) say: |
evgeni
left a comment
There was a problem hiding this comment.
I thought that'd fix it (that aligns with the old config) but it did not
| key_usage: | ||
| - keyCertSign | ||
| - cRLSign | ||
| - digitalSignature |
There was a problem hiding this comment.
adding this helped, but now I am confused, the old OpenSSL config doesn't add that to the CA cert…
There was a problem hiding this comment.
I checked the original openssl.cnf, the digitalSignature is mentioned in ssl_server and ssl_client sections:
[ ssl_server ]
basicConstraints = CA:FALSE
nsCertType = server
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth, nsSGC, msSGC
nsComment = "OpenSSL Certificate for SSL Web Server"
[ ssl_client ]
basicConstraints = CA:FALSE
nsCertType = client
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth
nsComment = "OpenSSL Certificate for SSL Client"
There was a problem hiding this comment.
for comparison, this is what gets generated by the various implementations we have
old openssl code:
X509v3 extensions:
X509v3 Basic Constraints:
CA:TRUE
Netscape Cert Type:
SSL CA
X509v3 Key Usage:
Certificate Sign, CRL Sign
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
your ansible code:
X509v3 extensions:
X509v3 Key Usage: critical
Digital Signature, Certificate Sign, CRL Sign
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Basic Constraints: critical
CA:TRUE
old katello-certs-tools:
X509v3 Basic Constraints:
CA:TRUE
X509v3 Key Usage:
Digital Signature, Key Encipherment, Certificate Sign, CRL Sign
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
Netscape Cert Type:
SSL Server, SSL CA
why is key usage marked critical for your code?
There was a problem hiding this comment.
aha, I think that's what fooling us here. we need digital signature, but without the usage being marked as critical, this is actually not enforced by the consumer.
There was a problem hiding this comment.
yepp, just tried it out, dropping key_usage_critical: true "fixes" it too.
now, I'd argue that setting key_usage_critical: true as you did is more correct here, but not sure about the implications.
@ehelms opinions? should we aim at bug-for-bug compatibility with katello-certs-tools or rather not? (I'd prefer not)
There was a problem hiding this comment.
I think aiming to be "correct" for the new certificate generation code is the way to go. What I worry about is, what happens to installer-based certificates that are inherited and continue to be managed (see #421). Will this try and trigger a regeneration of the CA?
There was a problem hiding this comment.
The modules might, yes. We talked about a related issue yesterday that people should not get the CA regenerated when e.g. the expiration date changes (it is currently relative to the date the execution happens) and ended up saying that for CA-changing operations we'd require an explicit flag (something like "allow CA changes") so that the CA won't change once generated unless explicitly requested.
There was a problem hiding this comment.
Oh, docs say "not valid after" is "not used to determine whether an existing certificate should be regenerated. ", cool.
(The rest still applies, ofc)
8f50c35 to
f1f7159
Compare
1a89995 to
f167c76
Compare
We don't have a good way (today) to execute that without basically doing a "do a full deployment, ensure things work, regen certs, ensure things still work", which is rather expensive (IMHO). Therefor I'd leave the tests a bit for the future. We probably can build something similar to https://github.com/theforeman/foremanctl/blob/master/tests/unit/foreman_ceritificate_check_test.py by writing dedicated tests for the |
* Use the community.crypto module * Fix re-generating certs * --reset-certificate-cname
b8b377b to
c2f74a3
Compare
I would expect a test that will assert regeneration of certificates when critical properties are changed (like the SANs). We may also test that the certificates generated by the CA and issue roles are passing the certificate_check assertions. As you have said - it's for the future, but really needed. |
Robotello: SatelliteQE/robottelo#21309