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

feat(notation): sign artifacts using notation #341

Merged
merged 18 commits into from
Feb 26, 2024

Conversation

JasonTheDeveloper
Copy link
Contributor

This PR is associated with feat(notation): add support for notation in HelmChart and OCIRepository configuration and includes notation configuration used to sign artifacts and updated to the release workflow.

I have included my public cert used by others who want to validate the artifact they're deploying was signed by me, but you would need to generate your own and associated private cert.

Prep

To help with that, you can use the following cnf:

[ req ]
default_bits           = 2048
default_keyfile        = privatekey.pem
distinguished_name     = req_distinguished_name
req_extensions         = v3_req
prompt                 = no
                       
[ req_distinguished_name ]
C                      = US
ST                     = WA
L                      = Seattle
O                      = Notary
CN                     = fluxcd.io

[ v3_req ]
keyUsage               = critical,digitalSignature
extendedKeyUsage       = critical,codeSigning
#subjectKeyIdentifier  = hash

Change the req_distinguished_name block if you like but just keep in mind, you'll also need to update trustedIdentities in .notation/trustpolicy.json to match.

Save that to a file, something like codesign.cnf for example.

Use the following commands to generate a new cert for signing and verifying:

openssl genrsa -out flux.key 2048
openssl req -new -key flux.key -out flux.csr -config codesign.cnf

# Up to you how long you want the cert to last for. The below command uses 365 days
openssl x509 -req -days 365 -in flux.csr -signkey flux.key -out flux.crt -extensions v3_req -extfile codesign.cnf

Take the resulting flux.key and copy the contents to a new secret in GitHub named NOTATION_SIGNING_KEY. Replace .notation/notation.crt with the contents of flux.crt.

That's it! You should be golden.

@stefanprodan
Copy link
Owner

Hey @JasonTheDeveloper thank you for this, I've been on a work trip this week but Monday I'll follow the steps and do a release for podinfo.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Jason <jagoodse@microsoft.com>
Copy link
Owner

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @JasonTheDeveloper 🏅

@stefanprodan stefanprodan merged commit b1207aa into stefanprodan:master Feb 26, 2024
3 checks passed
@stefanprodan
Copy link
Owner

This crashed the release Error: failed to push signature to registry with error: failed to push manifest: PUT "https://registry-1.docker.io/v2/***/podinfo/manifests/sha256:f53fce2c3056c62205025f4f9b1bb2af4df4eb648d8677c8bb14d6fc47afb47c": response status code 404: notfound: not found

@JasonTheDeveloper
Copy link
Contributor Author

This crashed the release Error: failed to push signature to registry with error: failed to push manifest: PUT "https://registry-1.docker.io/v2/***/podinfo/manifests/sha256:f53fce2c3056c62205025f4f9b1bb2af4df4eb648d8677c8bb14d6fc47afb47c": response status code 404: notfound: not found

I noticed that. Looking into it now. In my original testing I had not pushed the container to docker hub, only ghcr. Gimme a sec.

@stefanprodan
Copy link
Owner

I can remove the Docker Signing and try again if it should work on GHCR.

@JasonTheDeveloper
Copy link
Contributor Author

JasonTheDeveloper commented Feb 26, 2024

I can remove the Docker Signing and try again if it should work on GHCR.

I was about to suggest that. Do you want me to push a new commit?

Looking through docs I believe the issue may be with Docker Hub itself. I thought Docker Hub supported OCI v1.1 as you can now push helm charts and SBOMs but I can't seem to find any actual information explicitly stating Docker Hub indeed supports the 1.1 spec. There was talk of adding backwards compatible in notation but that feature looks to be abandoned.

@stefanprodan
Copy link
Owner

Docker Hub is on 1.0 spec as far as I know.

@stefanprodan
Copy link
Owner

@JasonTheDeveloper I have removed the Docker Hub signing, and now 6.6.0 is out. Can you please test it our if the signatures for thr GHCR container image, chart and manifest artifacts are Ok?

@JasonTheDeveloper
Copy link
Contributor Author

@JasonTheDeveloper I have removed the Docker Hub signing, and now 6.6.0 is out. Can you please test it our if the signatures for thr GHCR container image, chart and manifest artifacts are Ok?

@stefanprodan I've made the changes to the e2e test. I've tested it locally to ensure switching to your build still work. They appear to work which is great! Just pushed and now I'm letting the pipeline run in my fork.

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.

None yet

2 participants