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

x509: cannot verify signature: insecure algorithm SHA1-RSA #2091

Open
imjasonh opened this issue Jul 22, 2022 · 6 comments
Open

x509: cannot verify signature: insecure algorithm SHA1-RSA #2091

imjasonh opened this issue Jul 22, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@imjasonh
Copy link
Member

imjasonh commented Jul 22, 2022

Description

From head (95b74db)

$ go test ./pkg/cosign/
--- FAIL: TestValidateAndUnpackCertWithSCT (0.00s)
    verify_test.go:457: ValidateAndUnpackCert expected no error, got err = x509: certificate signed by unknown authority (possibly because of "x509: cannot verify signature: insecure algorithm SHA1-RSA (temporarily override with GODEBUG=x509sha1=1)" while trying to verify candidate authority certificate "Certificate Transparency CA")
    verify_test.go:464: ValidateAndUnpackCert expected no error, got err = x509: certificate signed by unknown authority (possibly because of "x509: cannot verify signature: insecure algorithm SHA1-RSA (temporarily override with GODEBUG=x509sha1=1)" while trying to verify candidate authority certificate "Certificate Transparency CA")
FAIL
FAIL	github.com/sigstore/cosign/pkg/cosign	1.422s
FAIL

Adding the GODEBUG as suggested makes the test pass:

GODEBUG=x509sha1=1 go test ./pkg/cosign/
ok  	github.com/sigstore/cosign/pkg/cosign	1.367s
$ go version
go version go1.18.2 darwin/arm64

Mostly filing this since I couldn't find any other reference to this in issues or code in any sigstore repo. Has anybody seen this before

edit: see golang/go#41682

@imjasonh imjasonh added the enhancement New feature or request label Jul 22, 2022
@haydentherapper
Copy link
Contributor

Looking into this. Interestingly it fails on 1.18, but not 1.19.

@haydentherapper
Copy link
Contributor

Need to generate new test data for certificate-transparency-go that doesn't use SHA1 for the signing algorithm digest.

@dmitris
Copy link
Contributor

dmitris commented Apr 26, 2023

go test -v ./pkg/cosign passes now without GODEBUG=x509sha1=1 on the head version (17cc138) with go1.20.3 - has anything changed? @imjasonh - does it work for you now or not? go test ./... works for me as well.

@imjasonh
Copy link
Member Author

Tests also passed for me at head (17cc138) without the env var set. I assume @haydentherapper updated the test data to not rely on SHA1, and the env var is now unnecessary.

Thanks for trying this @dmitris ! 👍

@haydentherapper
Copy link
Contributor

haydentherapper commented Apr 27, 2023

The tests that need x509sha1 require the sct tag, see https://github.com/sigstore/cosign/blob/main/.github/workflows/tests.yaml#L70-L84. I guess e2e tests don't need the flag.

For anyone working in that part of the code, they need to know to specify that tag when running tests, but for the rest of the code, it's not needed.

@dmitris
Copy link
Contributor

dmitris commented May 17, 2023

@imjasonh to avoid potential confusion, could you edit the issue description to add the sct tag in the command - go test -tags=sct ./..., please?

go test -tags=sct -failfast ./...
--- FAIL: TestValidateAndUnpackCertWithSCT (0.01s)
    verify_sct_test.go:80: ValidateAndUnpackCert expected no error, got err = cert verification failed: x509: certificate signed by unknown authority (possibly because of "x509: cannot verify signature: insecure algorithm SHA1-RSA (temporarily override with GODEBUG=x509sha1=1)" while trying to verify candidate authority certificate "Certificate Transparency CA"). Check your TUF root (see cosign initialize) or set a custom root with env var SIGSTORE_ROOT_FILE
    verify_sct_test.go:87: ValidateAndUnpackCert expected no error, got err = cert verification failed: x509: certificate signed by unknown authority (possibly because of "x509: cannot verify signature: insecure algorithm SHA1-RSA (temporarily override with GODEBUG=x509sha1=1)" while trying to verify candidate authority certificate "Certificate Transparency CA"). Check your TUF root (see cosign initialize) or set a custom root with env var SIGSTORE_ROOT_FILE
FAIL
FAIL	github.com/sigstore/cosign/v2/pkg/cosign	4.311s

The test that fails without GODEBUG=x509sha1=1 is TestValidateAndUnpackCertWithSCT from
https://github.com/sigstore/cosign/blob/main/pkg/cosign/verify_sct_test.go#L40.

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

No branches or pull requests

3 participants