Support executing the Go toolchain with GOFIPS set #1141
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is currently not possible to execute the Go toolchain with most combinations of
GOFIPS
+GOEXPERIMENT
. For example, this command fails:GOFIPS=1 GOEXPERIMENT=systemcrypto go test ./...
:The
GOFIPS
env is intended to be used in the temporary binary generated bygo test
(andgo run
), but it also affects the Go toolchain itself, as it importscrypto/sha256
, which triggers theGOFIPS
check even before building the binary.This PR updates the Go toolchain initialization to unset
GOFIPS
for it's own processes, while keeping it set for the user binaries. There is no need to add new tests, asgo test
andgo run
are already heavily tested. We haven't seen any test failure in our fips builders yet because we were settingGOFIPS=true
instead ofGOFIPS=1
, which caused the tests to ignore it.Notice that this change doesn't preclude the Go toolchain to run in FIPS mode. When
GOFIPS
is unset, the default behavior is to try to use FIPS mode whenever possible. The only change is that the process won't panic when FIPS mode can't be enabled. If someone wants to make sure that the Go toolchain is executed in FIPS mode, then the only solution is to build it with-tags requirefips
.Fixes #1106.