You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add FIPS env flag to enable FIPS mode.
FIPS=true will change the following:
- PLATFORMS will default to linux/amd64 linux/arm64
- make local, make release-* - Binary will be build with -tags=fipsrequired and GOEXPERIMENT=systemcrypto
- make build-releaser - chaingaurd microsoft go image will be used as base
- make multipass - microsoft's go toolchain will be downloaded and installed to VM
@@ -170,11 +185,11 @@ test-release: ## - Check that all release binaries are created
170
185
171
186
.PHONY: test-unit
172
187
test-unit: prepare-test-context ## - Run unit tests only
173
-
set -o pipefail; go test${GO_TEST_FLAG} -v -race -coverprofile=build/coverage-${OS_NAME}.out ./... | tee build/test-unit-${OS_NAME}.out
188
+
set -o pipefail; go test${GO_TEST_FLAG}$(if$(FIPS),-tags="requirefips",)-v -race -coverprofile=build/coverage-${OS_NAME}.out ./... | tee build/test-unit-${OS_NAME}.out
174
189
175
190
.PHONY: benchmark
176
191
benchmark: prepare-test-context install-benchstat ## - Run benchmark tests only
177
-
set -o pipefail; go test -bench=$(BENCHMARK_FILTER) -run=$(BENCHMARK_FILTER)$(BENCHMARK_ARGS)$(BENCHMARK_PACKAGE)| tee "build/$(BENCH_BASE)"
192
+
set -o pipefail; go test -bench=$(BENCHMARK_FILTER)$(if$(FIPS),-tags="requirefips",)-run=$(BENCHMARK_FILTER)$(BENCHMARK_ARGS)$(BENCHMARK_PACKAGE)| tee "build/$(BENCH_BASE)"
178
193
179
194
.PHONY: install-benchstat
180
195
install-benchstat: ## - Install the benchstat package
docker-release: build-releaser ## - Builds a release for all platforms in a dockerised environment
270
289
docker run --rm -u $(shell id -u):$(shell id -g) --volume $(PWD):/go/src/github.com/elastic/fleet-server $(BUILDER_IMAGE) release
271
290
272
291
.PHONY: docker-cover-e2e-binaries
273
292
docker-cover-e2e-binaries: build-releaser
274
-
## Build for local architecture and for linux/amd64 for docker images.
275
-
docker run --rm -u $(shell id -u):$(shell id -g) --volume $(PWD):/go/src/github.com/elastic/fleet-server -e SNAPSHOT=true $(BUILDER_IMAGE) cover-linux/$(shell go env GOARCH) cover-$(shell go env GOOS)/$(shell go env GOARCH)
293
+
## Build for local architecture and for linux/$ARCH for docker images.
294
+
docker run --rm -u $(shell id -u):$(shell id -g) --volume $(PWD):/go/src/github.com/elastic/fleet-server -e SNAPSHOT=true $(if$(FIPS),-e FIPS=true)$(BUILDER_IMAGE) cover-linux/$(shell go env GOARCH) cover-$(shell go env GOOS)/$(shell go env GOARCH)
276
295
277
296
.PHONY: release
278
297
release: $(PLATFORM_TARGETS)## - Builds a release. Specify exact platform with PLATFORMS env.
This forces the use of a FIPS compliant provider to handle any cryptographic calls.
7
+
8
+
Currently FIPS is provided by compiling with the [microsoft/go](https://github.com/microsoft/go) distribution.
9
+
This toolchain must be present for local compilation.
10
+
11
+
12
+
## Build changes
13
+
14
+
As we are using Microsfot/go as a base we follow their conventions.
15
+
16
+
The buildtag `requirefips` is passed when FIPS is enabled/required.
17
+
Additionally when compiling `GOEXPERIMENT=systemcrypto` is specified.
18
+
19
+
The `FIPS=true` env var is used by our Makefile as the indicator that controls FIPS.
20
+
This env var is also passed to every child process the Makefile starts.
21
+
The following make commands have different behaviour when FIPS is enabled:
22
+
23
+
-`make multipass` - Provision a multipass VM with the Microsoft/go toolchain. See [Multipass VM Usage](#multipass-vm-usage) for additional details.
24
+
-`make local` - Compile a fleet-server targetting the machine's GOOS/GOARCH with FIPS enabled
25
+
-`make cover-*` - Compile a coverage and fips enabled fleet-server for e2e tests
26
+
-`make test-unit` - Run unit tests passing the `requirefips` build tag.
27
+
-`make benchmark` - Run benchmarks passing the `requirefips` build tag.
28
+
-`make release-*` - Compile a release binary with FIPS enabled. Will have the name fleet-server-$VERSION-$OS-$ARCH-fips
29
+
-`make package-target` - Will package a FIPS enabled release and produce the sha512 checksum for it.
30
+
-`make build-releaser` - Will create the fleet-server builder image based on Microsoft's FIPS enabled golang image.
31
+
-`make docker-release` - Runs `make release` to produce FIPS enabled binaries in a FIPS docker container.
32
+
-`make docker-cover-e2e-binaries` - Will produce coverage and FIPS enabled binaries for e2e tests from within the same docker container that `build-release` makes
33
+
34
+
### Multipass VM Usage
35
+
36
+
A Multipass VM created with `FIPS=true make multipass` is able to compile FIPS enabled golang programs, but is not able to run them.
37
+
When you try to run one the following error occurs:
38
+
```
39
+
GOFIPS=1 ./bin/fleet-server -c fleet-server.yml
40
+
panic: opensslcrypto: can't enable FIPS mode for OpenSSL 3.0.13 30 Jan 2024: openssl: FIPS mode not supported by any provider
0 commit comments