Skip to content
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

adds tsa cert chain check for env var or tuf targets. #3600

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ianhundere
Copy link

@ianhundere ianhundere commented Mar 15, 2024

closes #3563

Summary

Creates parity between Cosign / TSA (e.g. TSA values are handled similarly to ctlog, fulcio, and rekor creds now) since sigstore/sigstore TUF client was recently updated to support the "TSA" usage type.

Currently, the TSA cert chain is required via Cosign's cli flag, though, as per #3563, Cosign can support reading the cert chain from either an environment or the TUF targets, similar to Fulcio certs, Rekor keys or the CTLog public key that can be provided on verification. I looked at RekorPubKeys and GetCTLogPubs as an example.

Release Note

  • Checks for TSA cert-chain in environment variable, SIGSTORE_TSA_CERTIFICATE_FILE, and TUF targets

Documentation

@ianhundere ianhundere marked this pull request as draft March 15, 2024 17:57
Signed-off-by: ianhundere <138915+ianhundere@users.noreply.github.com>
@ianhundere ianhundere marked this pull request as ready for review March 18, 2024 13:28
Signed-off-by: ian hundere <138915+ianhundere@users.noreply.github.com>
Copy link
Contributor

@cmurphy cmurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good to me, though I'm not a TSA or TUF expert.

It looks like the merge commit accidentally pulled in an unused import so this doesn't build.

This will need some tests.

Comment on lines +15 to +17
var tsaLeafCertStr = `tsa_leaf.crt.pem`
var tsaRootCertStr = `tsa_root.crt.pem`
var tsaIntermediateCertStrPattern = `tsa_intermediate_%d.crt.pem`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) these could be consts

@@ -0,0 +1,75 @@
package cosign
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need a copyright header

Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, sorry for the delay. Just a couple comments.

+1 to tests.

// By default, the certificates come from TUF, but you can override this for test
// purposes by using an env variable `SIGSTORE_TSA_CERTIFICATE_FILE`. If using
// an alternate, the file should be in PEM format.
func GetTSACerts(ctx context.Context) (leaves [][]byte, intermediates [][]byte, roots [][]byte, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to support reading the chain from a provided file path specified in TSACertChainPath, to avoid making this a breaking client change.

// By default, the certificates come from TUF, but you can override this for test
// purposes by using an env variable `SIGSTORE_TSA_CERTIFICATE_FILE`. If using
// an alternate, the file should be in PEM format.
func GetTSACerts(ctx context.Context) (leaves [][]byte, intermediates [][]byte, roots [][]byte, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we return x509.Certificate structs instead of byte arrays? This will cut down on repetition in the verify files if you handle unmarshalling from PEM in this function.

@ianhundere
Copy link
Author

thanks for the feedback/comments, will try to implement in the new few weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch TSA certificates from TUF targets when available
3 participants