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

Switch to calling gRPC-based fulcio v2 APIs #1762

Closed
wants to merge 18 commits into from

Conversation

bobcallaway
Copy link
Member

@bobcallaway bobcallaway commented Apr 14, 2022

Waiting for fulcio gRPC to be enabled in prod

@nsmith5

Signed-off-by: Bob Callaway <bcallaway@google.com>
Signed-off-by: Bob Callaway <bcallaway@google.com>
Signed-off-by: Bob Callaway <bcallaway@google.com>
@nsmith5
Copy link
Contributor

nsmith5 commented Apr 14, 2022

Hmm it looks like you might be hitting similar code-gen issues I ran into. You'll need to run hack/update-codegen.sh I think and make want this patch for that file: https://github.com/sigstore/cosign/pull/1760/files#diff-149dfe7bb29d1191dceae3a52915e750e64b7f87257a5fb309c29d3056e2a95dL61-L65

Even after updating the codegen for cosigned I hit some CI issues... no sure what is up there

@nsmith5
Copy link
Contributor

nsmith5 commented Apr 14, 2022

If we're close to getting GRPC running in prod I'll close my PR in favour of yours as well

Signed-off-by: Bob Callaway <bcallaway@google.com>
pkg/cosign/kubernetes/webhook/validator.go Outdated Show resolved Hide resolved
cmd/cosign/cli/fulcio/fulcio.go Outdated Show resolved Hide resolved
Signed-off-by: Bob Callaway <bcallaway@google.com>
Signed-off-by: Bob Callaway <bcallaway@google.com>
@codecov-commenter
Copy link

codecov-commenter commented Apr 15, 2022

Codecov Report

Merging #1762 (2cdefb5) into main (d067d40) will increase coverage by 0.14%.
The diff coverage is 54.20%.

@@            Coverage Diff             @@
##             main    #1762      +/-   ##
==========================================
+ Coverage   30.48%   30.63%   +0.14%     
==========================================
  Files         136      136              
  Lines        8384     8442      +58     
==========================================
+ Hits         2556     2586      +30     
- Misses       5494     5520      +26     
- Partials      334      336       +2     
Impacted Files Coverage Δ
cmd/cosign/cli/attest.go 0.00% <0.00%> (ø)
cmd/cosign/cli/options/fulcio.go 0.00% <0.00%> (ø)
cmd/cosign/cli/policy_init.go 1.35% <0.00%> (-0.01%) ⬇️
cmd/cosign/cli/sign.go 0.00% <0.00%> (ø)
cmd/cosign/cli/signblob.go 0.00% <0.00%> (ø)
cmd/cosign/cli/sign/sign.go 15.84% <20.00%> (ø)
cmd/cosign/cli/fulcio/fulcio.go 30.30% <57.74%> (+12.04%) ⬆️
pkg/oci/static/signature.go 50.00% <66.66%> (ø)
internal/pkg/cosign/fulcio/signer.go 62.50% <100.00%> (ø)
pkg/oci/mutate/options.go 89.18% <100.00%> (ø)
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Signed-off-by: Bob Callaway <bcallaway@google.com>
@nsmith5
Copy link
Contributor

nsmith5 commented May 13, 2022

@bobcallaway is it worth resurrecting my other PR just to unblock bumping the Fulcio library here? Or are we pretty close to being able to switch over to GRPC with this work?

@bobcallaway
Copy link
Member Author

i'm almost done with a rebase on this; where do we stand on getting the v0.4.0 fulcio code into prod?

@dlorenc
Copy link
Member

dlorenc commented May 20, 2022

i'm almost done with a rebase on this; where do we stand on getting the v0.4.0 fulcio code into prod?

Should be next week. I just need to cut over the IPs in DNS.

@dlorenc
Copy link
Member

dlorenc commented May 20, 2022

cc @k4leung4

@haydentherapper
Copy link
Contributor

We're discussing a rollout plan - Will ping this PR once Fulcio's been updated

@haydentherapper
Copy link
Contributor

@bobcallaway .4 is out! This should be good to go

@bobcallaway
Copy link
Member Author

bobcallaway commented Jun 2, 2022 via email

cmd/cosign/cli/fulcio/fulcio.go Show resolved Hide resolved
cmd/cosign/cli/fulcio/fulcio.go Outdated Show resolved Hide resolved
cmd/cosign/cli/fulcio/fulcio.go Outdated Show resolved Hide resolved
return fClient, nil
host := fulcioServer.Host
switch fulcioServer.Scheme {
case "https":
Copy link
Contributor

Choose a reason for hiding this comment

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

I've also seen dns:///foo.example.com:443 as a supported scheme for gRPC.

I also think we should allow scheme-less and match on port.

So either:

  • scheme=https
  • port=443
    should use a TLS connection

otherwise, an insecure connection

fs, err := fulcio.NewSigner(ctx, idToken, oidcIssuer, oidcClientID, oidcClientSecret, oidcRedirectURL, fClient)
if err != nil {
return nil, err
}

// verify the sct
if err := ctl.VerifySCT(ctx, fs.Cert, fs.Chain, fs.SCT); err != nil {
if err := ctl.VerifySCT(ctx, []byte(fs.Cert), []byte(strings.Join(fs.Chain, "\n")), fs.SCT); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Do you want to add a TODO here to change VerifySCT to take the list of certs rather than a single PEM-encoded chain? No need to change it now, but it would be better than converting back and forth going forward

func getFulcioCert(u *apis.URL) (*x509.CertPool, error) {
fClient := api.NewClient(u.URL())
rootCertResponse, err := fClient.RootCert()
func getFulcioCert(fulcioURL *apis.URL) (*x509.CertPool, 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 be providing this client in Fulcio to avoid duplication? I had hoped setting up a gRPC connection required very little boilerplate, but given that we need scheme/port detection, it might be good to centralize it.

fyi @wlynch, who would need the same in gitsign

@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

Signed-off-by: Bob Callaway <bcallaway@google.com>
@vaikas
Copy link
Contributor

vaikas commented Nov 29, 2022

zomg, I totes missed this and I'm so sorry. I'm curious why we have two separate ports for HTTP and GRPC and not just use Duplex there, but I reckon that's an issue that should be brought up in Fulcio land.

mostly because gRPC support was added later and the majority of the duplex implementations I've seen simply just use HTTP/2 as a signal to route to gRPC vs HTTP interfaces, but that could/would break some clients.

I think we should be fine here because at least our implementation here (and:
https://github.com/chainguard-dev/go-grpc-kit

Switches based off of the grpc headers.
https://github.com/chainguard-dev/go-grpc-kit/blob/main/pkg/duplex/server.go#L29

So, I'd be surprised if that would break HTTP clients, since I wouldn't be expecting them to be setting grpc headers.

We can add a bunch of testing for these, but I reckon it would simplify bunch of things to be able to utilize duplex. I'll try to spin up some testing for this.

@bobcallaway
Copy link
Member Author

if you're checking for Content-Type that seems reasonable - I think the code examples I had seen in the past (not the chainguard-dev one) were only switching on HTTP 1 v 2 which didn't seem client-safe.

We did ship Fulcio v1 with the --grpc-port cmd line arg so if we retain that ability while also having the duplex support I think we could accommodate both.

@vaikas
Copy link
Contributor

vaikas commented Nov 29, 2022

if you're checking for Content-Type that seems reasonable - I think the code examples I had seen in the past (not the chainguard-dev one) were only switching on HTTP 1 v 2 which didn't seem client-safe.

We did ship Fulcio v1 with the --grpc-port cmd line arg so if we retain that ability while also having the duplex support I think we could accommodate both.

Just to make sure I understand, you're saying that we should retain that flag on the server side and hence be able to serve on two ports?

@bobcallaway
Copy link
Member Author

if you're checking for Content-Type that seems reasonable - I think the code examples I had seen in the past (not the chainguard-dev one) were only switching on HTTP 1 v 2 which didn't seem client-safe.
We did ship Fulcio v1 with the --grpc-port cmd line arg so if we retain that ability while also having the duplex support I think we could accommodate both.

Just to make sure I understand, you're saying that we should retain that flag on the server side and hence be able to serve on two ports?

We could deprecate --grpc-port as a command line arg and find another way to express the intent when launching the server, but I dont think we should just remove the ability to run on separate ports given that Fulcio is v1.0.0 now.

@vaikas
Copy link
Contributor

vaikas commented Nov 30, 2022 via email

@haydentherapper
Copy link
Contributor

@bobcallaway What is the status of the PR? Looks like most tests are passing

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions
Copy link

github-actions bot commented Feb 5, 2023

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions
Copy link

github-actions bot commented Mar 9, 2023

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions
Copy link

github-actions bot commented Apr 9, 2023

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions
Copy link

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions
Copy link

This PR was closed because it has been stalled for 10 days with no activity.

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

Successfully merging this pull request may close these issues.

7 participants