-
Notifications
You must be signed in to change notification settings - Fork 24
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
Support skipping certificate private key check on request #475
Conversation
kms/tpmkms/tpmkms.go
Outdated
@@ -786,7 +790,7 @@ func (k *TPMKMS) storeCertificateChainToWindowsCertificateStore(req *apiv1.Store | |||
} | |||
|
|||
if err := k.windowsCertificateManager.StoreCertificate(&apiv1.StoreCertificateRequest{ | |||
Name: fmt.Sprintf("capi:sha1=%s;store-location=%s;store=%s;", fp, location, store), | |||
Name: fmt.Sprintf("capi:sha1=%s;store-location=%s;store=%s;skip-find-certificate-key=%s", fp, location, store, skipFindCertificatKey), |
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.
Are location
and store
properly encoded to work on a URI?
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.
For existing and valid values they are, as they are plain strings and those are checked in the CAPI implementation. But I can change the implementation to uv.Set
, or something similar, if preferred
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.
Fixed in 4d88201
Add support for removing certificates from TPM and CAPI KMS
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.
We're not freeing all the certHandles, and I've also added another optional suggestion.
kms/capi/capi.go
Outdated
sha1Hash = strings.TrimPrefix(sha1Hash, "0x") // Support specifying the hash as 0x like with serial | ||
|
||
sha1Bytes, err := hex.DecodeString(sha1Hash) | ||
if err != nil { | ||
return fmt.Errorf("%s must be in hex format: %w", HashArg, err) | ||
} |
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.
We can add a func (u *URI) GetHexEncoded(key string) ([]byte, error)
to the URI package we already have GetEncoded
, but it is not strict and fallback to []byte(v)
. GetEncoded could use
GetHexEncoded`.
We are using this several times in this package.
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.
Here, we could validate the number of bytes, as a SHA1 is known. It will probably fail with an obscure error later.
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.
GetHexEncoded should return an error if it is present but invalid. Nil if it is not present or empty.
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.
lgtm
To support certificates that (usually) don't have a key present,
skip-find-certificate-key=true
can now be provided to an individual call for storing a certificate (chain). This can be helpful when storing an intermediate or root certificate in a specific store / store location.