Skip to content

Commit

Permalink
Set fips_mode_enabled in efs-utils.conf
Browse files Browse the repository at this point in the history
if env var `FIPS_ENABLED` is set: kubernetes-sigs#1325 .
  • Loading branch information
mpatlasov committed May 5, 2024
1 parent 94fed37 commit f5581f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/driver/efs_watch_dog.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ stunnel_check_cert_hostname = true
# Use OCSP to check certificate validity. This option is not supported by certain stunnel versions.
stunnel_check_cert_validity = false
# Enable FIPS mode. stunnel complains if FIPS is available and enabled system-wide, but not set here.
{{if .FipsEnabled -}}
fips_mode_enabled = {{.FipsEnabled -}}
{{else -}}
#fips_mode_enabled = false
{{- end}}
# Define the port range that the TLS tunnel will choose from
port_range_lower_bound = 20049
port_range_upper_bound = 20449
Expand Down Expand Up @@ -163,6 +170,7 @@ type execWatchdog struct {
type efsUtilsConfig struct {
EfsClientSource string
Region string
FipsEnabled string
}

func newExecWatchdog(efsUtilsCfgPath, efsUtilsStaticFilesPath, cmd string, arg ...string) Watchdog {
Expand Down Expand Up @@ -264,7 +272,8 @@ func (w *execWatchdog) updateConfig(efsClientSource string) error {
defer f.Close()
// used on Fargate, IMDS queries suffice otherwise
region := os.Getenv("AWS_DEFAULT_REGION")
efsCfg := efsUtilsConfig{EfsClientSource: efsClientSource, Region: region}
fipsEnabled := os.Getenv("FIPS_ENABLED")
efsCfg := efsUtilsConfig{EfsClientSource: efsClientSource, Region: region, FipsEnabled: fipsEnabled}
if err = efsCfgTemplate.Execute(f, efsCfg); err != nil {
return fmt.Errorf("cannot update config %s for efs-utils. Error: %v", w.efsUtilsCfgPath, err)
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/driver/efs_watch_dog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ stunnel_check_cert_hostname = true
# Use OCSP to check certificate validity. This option is not supported by certain stunnel versions.
stunnel_check_cert_validity = false
# Enable FIPS mode. stunnel complains if FIPS is available and enabled system-wide, but not set here.
#fips_mode_enabled = false
# Define the port range that the TLS tunnel will choose from
port_range_lower_bound = 20049
port_range_upper_bound = 20449
Expand Down

0 comments on commit f5581f0

Please sign in to comment.