Repository: minio/minio (language: go)

Issue:
KMS : Invalid configuration for static KMS key: 'MINIO_KMS_SECRET_KEY' and 'MINIO_KMS_SECRET_KEY_FILE' are present
Hi there !

On a Docker Swarm (or Docker Compose), it's not possible to define environment var `MINIO_KMS_SECRET_KEY_FILE` through secrets : it makes the container crash.

## Current Behavior
If the environment var `MINIO_KMS_SECRET_KEY_FILE` is present and `MINIO_KMS_SECRET_KEY` is not, the container will consider that the environment var `MINIO_KMS_SECRET_KEY` is also present and it will stop with the following issue :
`FATAL Invalid KMS configuration specified: kms: invalid configuration for static KMS key: 'MINIO_KMS_SECRET_KEY' and 'MINIO_KMS_SECRET_KEY_FILE' are present`

## Expected Behavior
If env var `MINIO_KMS_SECRET_KEY` is not specified, it should not be considered by the container image.

## Possible Solution
I think something could be found on the kms config file, but I couldn't find exactly what :
https://github.com/minio/minio/blob/master/internal/kms/config.go (about lines 253 or 300). Seems like 
`os.Unsetenv(EnvKMSSecretKey)` on line 314 is not functional (I don't know Go Language).

## Steps to Reproduce (for bugs)
Save two secrets in Docker Swarm :
`echo "Roudoudou" | docker secret create minio_root_password -`
`echo "minio_key:JAzw9eJEMMDRr6Sqqz6iC+uVg2Yeu8S/xvJDOlOZifg=" | docker secret create minio_kms_secret_key -`

And then, try the very basic following docker-compose.yml :
```
services:
  minio:
    image: minio/minio
    environment:
      - MINIO_ROOT_USER=Admin
      - MINIO_ROOT_PASSWORD_FILE=/run/secrets/minio_root_password
      - MINIO_KMS_SECRET_KEY_FILE=/run/secrets/minio_kms_secret_key
    command: server /data --console-address ':9001'
    ports:
      - '9001:9001'
      - '9000:9000'
    secrets:
      - minio_root_password
      - minio_kms_secret_key

secrets:
  minio_root_password:
    external: true
  minio_kms_secret_key:
    external: true
```
The container crash and restart with the following error :
`FATAL Invalid KMS configuration specified: kms: invalid configuration for static KMS key: 'MINIO_KMS_SECRET_KEY' and 'MINIO_KMS_SECRET_KEY_FILE' are present`

## Context
Discovered while trying to build a stack with Minio to have a very simple encrypted backend to manage (one node, one drive) and a [FileStash](https://www.filestash.app/) connected as frontend.

## Regression
It seems to be a regression. 
The Docker Compose work fine with the `minio/minio:RELEASE.2024-05-07T06-41-25Z` image.
It's broken in the `minio/minio:RELEASE.2024-05-10T01-41-38Z` image.

=> This PR may be concerned : https://github.com/minio/minio/commit/8b660e18f26b36cc11a51aad0d806d03b917784d

## Your Environment
minio version RELEASE.2024-07-16T23-46-41Z (commit-id=3535197f993dea840dcb96302ba4d883dc619097)
Runtime: go1.22.5 linux/arm64
From Docker image https://hub.docker.com/layers/minio/minio/latest/images/sha256-cb688c06c3135c6d496e2edecd85a91b43e53b6ef17cb2072b0c1832c141d1d2?context=explore

Arch : Linux/Arm64 (Macbook Pro M1 Pro - 16Go).
Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64
Docker version 27.0.3, build 7d4bcd8

Also tested on 
Arch : Linux/Amd64 (Intel NUC Core i3 - 16Go)
Linux 5.15.0-116-generic #126-Ubuntu SMP Mon Jul 1 10:14:24 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Docker version 27.0.3, build 7d4bcd8




Do not hesitate to ask if you need further information or if I can help
Good luck guys !
Be strong ;-)


Discussion / hints:

Fix patch:
diff --git a/cmd/common-main.go b/cmd/common-main.go
index be3f4a1a08d8c..70abf6d293213 100644
--- a/cmd/common-main.go
+++ b/cmd/common-main.go
@@ -685,16 +685,6 @@ func loadEnvVarsFromFiles() {
 		}
 	}
 
-	if env.IsSet(kms.EnvKMSSecretKeyFile) {
-		kmsSecret, err := readFromSecret(env.Get(kms.EnvKMSSecretKeyFile, ""))
-		if err != nil {
-			logger.Fatal(err, "Unable to read the KMS secret key inherited from secret file")
-		}
-		if kmsSecret != "" {
-			os.Setenv(kms.EnvKMSSecretKey, kmsSecret)
-		}
-	}
-
 	if env.IsSet(config.EnvConfigEnvFile) {
 		ekvs, err := minioEnvironFromFile(env.Get(config.EnvConfigEnvFile, ""))
 		if err != nil && !os.IsNotExist(err) {


Test patch: