-
Notifications
You must be signed in to change notification settings - Fork 47
Support self signed certificate chain #989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This change does not affect functionality yet (apart from slightly changing the error messages if --gcp-ca-parent is not provided): it's just refactoring to enable future work. Most importantly naming of certificates and keys in the fetchCertificateChain method is now consistent: * "leaf" refers to the actual timestamp signing key/cert * "parent" is the key/cert that signs "leaf": it may be a self-signed certicifate or an intermediate signed by CA * "root" is a real CA certificate that signs "parent" (if a CA is used) Signed-off-by: Jussi Kukkonen <[email protected]>
It is now possible to create a certificate chain that does not use a real CA but instead has a self-signed signing certificate as the parent of of the timestamp signing certificate. This is a little experimental (e.g. cert lifetime is just hard coded now). Signed-off-by: Jussi Kukkonen <[email protected]>
This is useful mostly for the self signed case Signed-off-by: Jussi Kukkonen <[email protected]>
703833a
to
8fbdbc8
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #989 +/- ##
==========================================
- Coverage 52.85% 44.13% -8.73%
==========================================
Files 20 55 +35
Lines 1209 3707 +2498
==========================================
+ Hits 639 1636 +997
- Misses 509 1931 +1422
- Partials 61 140 +79 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
These are needed to get BasicConstraints in the cert. Signed-off-by: Jussi Kukkonen <[email protected]>
fa8b71d
to
8db16a1
Compare
This is what the self-signed CA looks like now:
|
func fetchCertificateChain(ctx context.Context, root, parentKMSKey, leafKMSKey, tinkKeysetPath, tinkKmsKey string, | ||
client *privateca.CertificateAuthorityClient) ([]*x509.Certificate, error) { | ||
intermediateKMSSigner, err := kms.Get(ctx, intermediateKMSKey, crypto.SHA256) | ||
parentKMSSigner, err := kms.Get(ctx, parentKMSKey, crypto.SHA256) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make the hash configurable via a flag? I believe this will err out if the hash func doesn't match what the KMS provider supports, e.g. ecdsa-p384 needs sha-384. We can default to sha256.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few options. The method call is a bit unwieldy now (with so many options) but I resisted urge to do more cleanup in the same PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scratch that: I tried to do this by just providing other values to kms.Get()
and the signature algorithm in the certificate does not change (206b419)...
- This makes sense when you consider that the (GCP) KMS signing key has the hash function baked in: I don't think you can change it like this
- I'm not quite sure why
kms.Get()
has a hash function as an argument?
In any case implementing this may not be the 15 min job I imagined: I would rather not include this somewhat unrelated change in the PR. Let's file an issue if the feature is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sigh, sorry for making you go down this rabbit hole. Only the hashivault KMS provider uses the hash. I thought all did to determine which hash to use when computing the digest to sign...oh well. Crypto agility is fun.
Root cert LGTM! |
Signed-off-by: Jussi Kukkonen <[email protected]>
This changes one option that existed before this PR: "--intermediate-kms-resource" is now "--parent-kms-resource". The idea is that now this works in boths cases: * parent is used as intermediate if a CA is provided * parent is used as a self signed root if a CA is not provided This also sorts the options the same way everywhere: leaf options, then parent options, then CA root options, finally output options. Signed-off-by: Jussi Kukkonen <[email protected]>
Signed-off-by: Jussi Kukkonen <[email protected]>
Signed-off-by: Jussi Kukkonen <[email protected]>
206b419
to
4669b9f
Compare
This makes
fetch_tsa_certs.go
support a self-signed certificate chain as well:--gcp-ca-parent
is given, tool works like before (creates a chain with root, intermediate and leaf). If it is not given, the chain will contain a selfsigned root and leaf instead--parent-validity=DAYS
was added since we can no longer rely on CA to set this in the self signing case--intermediate-kms-resource
was renamed--parent-kms-resource
so it works for both the intermediate case and self-signed caseFixes #988