Skip to content

Commit c6aa4b4

Browse files
committed
POC of replacing boringcrypto with Go's native FIPS-140-3 module
https://go.dev/blog/fips140 boringcrypto is slated to be removed in a future release. Signed-off-by: Michael Shen <mishen@umich.edu>
1 parent deab6d9 commit c6aa4b4

File tree

7 files changed

+9
-61
lines changed

7 files changed

+9
-61
lines changed

boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ ARG SAAS_OPERATOR_DIR
33
COPY ${SAAS_OPERATOR_DIR} manifests
44
RUN initializer --permissive
55

6-
# ubi-micro does not work for clusters with fips enabled unless we make OpenSSL available
7-
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
6+
FROM registry.access.redhat.com/ubi9/ubi-micro:latest
87

98
COPY --from=builder /bin/registry-server /bin/registry-server
109
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe

boilerplate/openshift/golang-osd-operator/README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ Checks consist of:
121121

122122
## FIPS (Federal Information Processing Standards)
123123

124-
To enable FIPS in your build there is a `make ensure-fips` target.
125-
126-
Add `FIPS_ENABLED=true` to your repos Makefile. Please ensure that this variable is added **before** including boilerplate Makefiles.
124+
To enable FIPS in your build, add `FIPS_ENABLED=true` to your repo's Makefile. Please ensure that this variable is added **before** including boilerplate Makefiles.
127125

128126
e.g.
129127

@@ -133,19 +131,15 @@ FIPS_ENABLED=true
133131
include boilerplate/generated-includes.mk
134132
```
135133

136-
`ensure-fips` will add a [fips.go](./fips.go) file in the same directory as the `main.go` file. (Please commit this file as normal)
137-
138-
`fips.go` will import the necessary packages to restrict all TLS configuration to FIPS-approved settings.
139-
140-
With `FIPS_ENABLED=true`, `ensure-fips` is always run before `make go-build`
134+
FIPS is enabled via the `fips140=on` GODEBUG option. See https://go.dev/blog/fips140 for more details.
141135

142136
## Additional deployment support
143137

144138
- The convention currently supports a maximum of two deployments. i.e. The operator deployment itself plus an optional additional deployment.
145139
- If an additional deployment image has to be built and appended to the CSV as part of the build process, then the consumer needs to:
146140
- Specify `SupplementaryImage` which is the deployment name in the consuming repository's `config/config.go`.
147141
- Define the image to be built as `ADDITIONAL_IMAGE_SPECS` in the consuming repository's Makefile, Boilerplate later parses this image as part of the build process; [ref](https://github.com/openshift/boilerplate/blob/master/boilerplate/openshift/golang-osd-operator/standard.mk#L56).
148-
142+
149143
e.g.
150144

151145
```.mk

boilerplate/openshift/golang-osd-operator/configure-fips.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

boilerplate/openshift/golang-osd-operator/fips.go.tmplt

Lines changed: 0 additions & 16 deletions
This file was deleted.

boilerplate/openshift/golang-osd-operator/standard.mk

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,11 @@ GOBIN?=$(shell go env GOBIN)
9898
unexport GOFLAGS
9999
GOFLAGS_MOD ?=
100100

101-
GOENV+=GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=1 GOFLAGS="${GOFLAGS_MOD}"
101+
GOENV+=GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 GOFLAGS="${GOFLAGS_MOD}"
102102
GOBUILDFLAGS=-gcflags="all=-trimpath=${GOPATH}" -asmflags="all=-trimpath=${GOPATH}"
103103

104104
ifeq (${FIPS_ENABLED}, true)
105-
GOFLAGS_MOD+=-tags=fips_enabled
106-
GOFLAGS_MOD:=$(strip ${GOFLAGS_MOD})
107-
$(warning Setting GOEXPERIMENT=boringcrypto - this generally causes builds to fail unless building inside the provided Dockerfile. If building locally consider calling 'go build .')
108-
GOENV+=GOEXPERIMENT=boringcrypto
105+
GOENV+=GODEBUG=fips140=on
109106
GOENV:=$(strip ${GOENV})
110107
endif
111108

@@ -237,10 +234,6 @@ endif
237234
.PHONY: generate
238235
generate: op-generate go-generate openapi-generate manifests
239236

240-
ifeq (${FIPS_ENABLED}, true)
241-
go-build: ensure-fips
242-
endif
243-
244237
.PHONY: go-build
245238
go-build: ## Build binary
246239
${GOENV} go build ${GOBUILDFLAGS} -o build/_output/bin/$(OPERATOR_NAME) .
@@ -342,10 +335,6 @@ opm-build-push: python-venv docker-push
342335
OLM_CHANNEL="${OLM_CHANNEL}" \
343336
${CONVENTION_DIR}/build-opm-catalog.sh
344337

345-
.PHONY: ensure-fips
346-
ensure-fips:
347-
${CONVENTION_DIR}/configure-fips.sh
348-
349338
# You will need to export the forked/cloned operator repository directory as OLD_SDK_REPO_DIR to make this work.
350339
# Example: export OLD_SDK_REPO_DIR=~/Projects/My-Operator-Fork
351340
.PHONY: migrate-to-osdk1

boilerplate/openshift/golang-osd-operator/update

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ for file in $DOCKERFILES; do
9292
${SED?} -i "1s,.*,FROM $IMAGE_PULL_PATH AS builder," $file
9393
fi
9494

95-
# Update any UBI images to use a versioned tag of ubi9/ubi-minimal that is compatible with dependabot.
95+
# Update any UBI images to use a versioned tag of ubi9/ubi-micro that is compatible with dependabot.
9696
# WARNING: The ubi version _must_ match the one that Boilerplate's image is built with. Update this if you change the
9797
# base ubi version.
98-
UBI_IMAGE_NAME="registry.access.redhat.com/ubi9/ubi-minimal"
98+
UBI_IMAGE_NAME="registry.access.redhat.com/ubi9/ubi-micro"
9999
for ubi_latest in $(grep -oE 'registry.access.redhat.com/ubi[7-9]/ubi.*?:.*' ${file}); do
100100
replacement_image=$(skopeo inspect --override-os linux --override-arch amd64 docker://${UBI_IMAGE_NAME} --format "{{.Name}}:{{.Labels.version}}-{{.Labels.release}}")
101101
echo "Overwriting ${file}'s ${ubi_latest} image to ${replacement_image}"

test/projects/file-generate/build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
1+
FROM registry.access.redhat.com/ubi9/ubi-micro:latest
22

33
ENV OPERATOR=/usr/local/bin/file-generate \
44
USER_UID=1001 \

0 commit comments

Comments
 (0)