Fixed issue where some values may not be getting assigned or validated if a config file was not being used.

feature/minimum_tls_version
Jeromy Streets 2 years ago
parent 81e8ebadd3
commit 562f95e8ea
  1. 15
      config/config.go
  2. 2
      config/config_test.go

@ -83,7 +83,7 @@ func Load(filename string) (err error) {
// If no filename provided, assign envvars.
if filename == "" {
overrideWithEnvVars()
return
return validate()
}
// Read contents from configuration file.
@ -161,6 +161,19 @@ func validate() error {
return err
}
}
// For logging minimum TLS version being used while debugging, backfill
// the TLSMinVersStr field.
switch Get.TLSMinVers {
case tls.VersionTLS10:
Get.TLSMinVersStr = "TLS1.0"
case tls.VersionTLS11:
Get.TLSMinVersStr = "TLS1.1"
case tls.VersionTLS12:
Get.TLSMinVersStr = "TLS1.2"
case tls.VersionTLS13:
Get.TLSMinVersStr = "TLS1.3"
}
} else {
if 0 < len(Get.TLSMinVersStr) {
msg := "value for 'TLS_MIN_VERS' is set but 'TLS_CERT' and 'TLS_KEY' are not"

@ -178,6 +178,8 @@ func TestValidate(t *testing.T) {
{"Prefix missing leading /", empty, empty, "my/prefix", "", true},
{"Prefix with trailing /", empty, empty, "/my/prefix/", "", true},
{"Valid paths w/min ok TLS", validPath, validPath, prefix, "tls11", false},
{"Valid paths w/min ok TLS", validPath, validPath, prefix, "tls12", false},
{"Valid paths w/min ok TLS", validPath, validPath, prefix, "tls13", false},
{"Valid paths w/min bad TLS", validPath, validPath, prefix, "bad", true},
{"Empty paths w/min ok TLS", empty, empty, prefix, "tls11", true},
{"Empty paths w/min bad TLS", empty, empty, prefix, "bad", true},

Loading…
Cancel
Save