Skip to content

Commit f6416fd

Browse files
authored
Enforce TLS in fips mode for cns-csi admission handler (#3506)
* Add approved TLS 1.3 cipher suites * Enfore TLS in fips mode for cns-csi admission handler
1 parent daee8bd commit f6416fd

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export BIN_OUT ?= $(BUILD_OUT)/bin
1313
# DIST_OUT is the directory containting the distribution packages
1414
export DIST_OUT ?= $(BUILD_OUT)/dist
1515

16+
# Compile Go with boringcrypto. This is required to import crypto/tls/fipsonly package.
17+
export GOEXPERIMENT=boringcrypto
18+
1619

1720
################################################################################
1821
## VERIFY GO VERSION ##
@@ -103,11 +106,11 @@ CSI_BIN_SRCS += $(addsuffix /*.go,$(shell go list -f '{{ join .Deps "\n" }}' ./c
103106
export CSI_BIN_SRCS
104107
endif
105108
$(CSI_BIN): $(CSI_BIN_SRCS)
106-
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags '$(LDFLAGS_CSI)' -o $(CSI_BIN_LINUX) $<
109+
CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags '$(LDFLAGS_CSI)' -o $(CSI_BIN_LINUX) $<
107110
@touch $@
108111

109112
$(CSI_BIN_WINDOWS): $(CSI_BIN_SRCS)
110-
CGO_ENABLED=0 GOOS=windows GOARCH=$(GOARCH) go build -ldflags '$(LDFLAGS_CSI)' -o $(CSI_BIN_WINDOWS) $<
113+
CGO_ENABLED=1 GOOS=windows GOARCH=$(GOARCH) go build -ldflags '$(LDFLAGS_CSI)' -o $(CSI_BIN_WINDOWS) $<
111114
@touch $@
112115

113116

@@ -141,7 +144,7 @@ CONTROLLER_GEN=$(shell which controller-gen)
141144
endif
142145

143146
$(SYNCER_BIN): $(SYNCER_BIN_SRCS) syncer_manifest
144-
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags '$(LDFLAGS_SYNCER)' -o $(abspath $@) $<
147+
CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags '$(LDFLAGS_SYNCER)' -o $(abspath $@) $<
145148
@touch $@
146149

147150
# The default build target.

hack/check-staticcheck.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ GOOS=linux "$(go env GOPATH)"/bin/staticcheck --version
3131

3232
# shellcheck disable=SC2046
3333
# shellcheck disable=SC1083
34-
GOOS=linux "$(go env GOPATH)"/bin/staticcheck $(go list ./... | grep -v /vendor/)
34+
GOOS=linux "$(go env GOPATH)"/bin/staticcheck $(go list ./...)

images/ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ COPY cmd ./cmd/
5050
ARG GOOS
5151
ARG GOARCH
5252
ARG GOPROXY
53-
ENV CGO_ENABLED=0 GOOS=${GOOS:-linux} GOARCH=${GOARCH:-amd64}
53+
ENV CGO_ENABLED=1 GOOS=${GOOS:-linux} GOARCH=${GOARCH:-amd64}
5454
ENV GOPROXY ${GOPROXY:-https://proxy.golang.org}
5555
RUN LDFLAGS=$(cat ldflags.txt) && \
5656
go build -ldflags "${LDFLAGS}" ./cmd/vsphere-csi

images/driver/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ WORKDIR /build
3838
COPY go.mod go.sum ./
3939
COPY pkg/ pkg/
4040
COPY cmd/ cmd/
41-
ENV CGO_ENABLED=0
41+
ENV CGO_ENABLED=1
42+
ENV GOFIPS=1
43+
ENV GOEXPERIMENT="boringcrypto"
4244
ENV GOPROXY ${GOPROXY:-https://proxy.golang.org}
4345
RUN go build -a -ldflags="-w -s -extldflags=static -X sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service.Version=${VERSION}" -o vsphere-csi ./cmd/vsphere-csi
4446

images/syncer/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ COPY pkg/ pkg/
3737

3838
COPY cmd/ cmd/
3939

40-
ENV CGO_ENABLED=0
40+
ENV CGO_ENABLED=1
4141

4242
ENV GOPROXY ${GOPROXY:-https://proxy.golang.org}
4343

44+
ENV GOFIPS=1
45+
46+
ENV GOEXPERIMENT="boringcrypto"
47+
4448
RUN go build -a -ldflags="-w -s -extldflags=static -X sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer.Version=${VERSION}" -o vsphere-syncer ./cmd/syncer
4549

4650
################################################################################

images/windows/driver/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ WORKDIR /build
3737
COPY go.mod go.sum ./
3838
COPY pkg/ pkg/
3939
COPY cmd/ cmd/
40-
ENV CGO_ENABLED=0
40+
ENV CGO_ENABLED=1
41+
ENV GOFIPS=1
42+
ENV GOEXPERIMENT="boringcrypto"
4143
ENV GOPROXY ${GOPROXY:-https://proxy.golang.org}
4244
RUN GOOS=windows GOARCH=amd64 go build -a -ldflags="-w -s -extldflags=static -X sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service.Version=${VERSION}" -o ./bin/vsphere-csi.windows_amd64 cmd/vsphere-csi/main.go
4345

pkg/syncer/admissionhandler/cnscsi_admissionhandler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package admissionhandler
33
import (
44
"context"
55
"crypto/tls"
6+
_ "crypto/tls/fipsonly"
67
"crypto/x509"
78
"encoding/json"
89
"fmt"
@@ -85,7 +86,9 @@ func startCNSCSIWebhookManager(ctx context.Context, enableWebhookClientCertVerif
8586
func(t *tls.Config) {
8687
// CipherSuites allows us to specify TLS 1.2 cipher suites that have been recommended by the Security team
8788
t.CipherSuites = []uint16{tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
88-
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}
89+
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
90+
tls.TLS_AES_128_GCM_SHA256,
91+
tls.TLS_AES_256_GCM_SHA384}
8992
t.MinVersion = tls.VersionTLS12
9093
},
9194
}

0 commit comments

Comments
 (0)