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

Go crypto fallback: use GOEXPERIMENT for opt-in #984

Merged
merged 1 commit into from
Jul 17, 2023

Conversation

dagood
Copy link
Member

@dagood dagood commented Jul 14, 2023

#965 changed Microsoft Go behavior so that instead of falling back to Go crypto, the build will fail if a backend is enabled and its requirements aren't met.

This caused issues in the Go build and test because in many places, cgo isn't enabled and cross-builds are being done. So, #965 added -tags=allow_missing_crypto_backend_fallback to opt out of this behavior, and disabled the crypto backend during the build part of CI, only enabling it during test. Passing the tags to the right parts of the tests is tricky, and other workarounds were needed too to account for using different GOEXPERIMENT values for build vs. test. Once the repo has a VERSION file, (#982) it gets even more complicated, and ultimately I didn't get this approach working in the 1.21 release branch.

This PR changes the allow_missing_crypto_backend_fallback tag to a allowcryptofallback GOEXPERIMENT. This means the complicated workarounds aren't necessary because opensslcrypto,allowcryptofallback follow each other around and take effect in the same places (and they are omitted in the same places).

I also added a note to the fallback compile error message that directly addresses the breaking change, for anyone depending on the fallback behavior.

Open to names other than allowcryptofallback, although I'm happy with it. Experiments are inherently easier to find than build tags, and someone might have a convoluted build script where they would actually want to use it (although I plan to discourage using it in the FIPS doc), so I figure a reasonable name would be good to have.

+ "",
+ "If you only performed a Go toolset upgrade and didn't expect this error, your code was likely depending on fallback to Go standard library crypto.",
+ "As of Go 1.21, Go crypto fallback is a build error. This helps prevent accidental fallback.",
+ "Removing "+backend.name+"crypto will restore pre-1.21 behavior by intentionally using Go standard library crypto.",
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that I'm not mentioning allowcryptofallback here. I think it's probably exceptionally rare that someone actually needs to use it rather than just removing the crypto backend they aren't using. I don't want to inadvertently encourage people to try it out without understanding the context--I think it would be better to describe it in the FIPS readme where there's more room for detail and we can update it more freely.

@dagood dagood merged commit 1f0c6b0 into microsoft/main Jul 17, 2023
19 checks passed
@dagood dagood deleted the dev/dagood/exp-fallback branch July 17, 2023 16:49
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.

3 participants