Skip to content

Commit 6b7a71c

Browse files
committed
Fix minio ssl compatible issue
Signed-off-by: yhmo <[email protected]>
1 parent 5031528 commit 6b7a71c

File tree

6 files changed

+31
-15
lines changed

6 files changed

+31
-15
lines changed

configs/milvus.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ minio:
6868
port: 9000 # Port of MinIO/S3
6969
accessKeyID: minioadmin # accessKeyID of MinIO/S3
7070
secretAccessKey: minioadmin # MinIO/S3 encryption string
71+
useSSL: false # Access to MinIO/S3 with SSL
7172
ssl:
72-
enabled: false # Access to MinIO/S3 with SSL
7373
tlsCACert: /path/to/public.crt # path to your CACert file, ignore when it is empty
7474
bucketName: a-bucket # Bucket name in MinIO/S3
7575
rootPath: files # The root path where the message is stored in MinIO/S3

internal/core/src/storage/ChunkManagers.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,22 @@ generateConfig(const StorageConfig& storage_config) {
5353
Aws::Client::ClientConfiguration config = g_config;
5454
config.endpointOverride = ConvertToAwsString(storage_config.address);
5555

56+
// Three cases:
57+
// 1. no ssl, verifySSL=false
58+
// 2. self-signed certificate, verifySSL=false
59+
// 3. CA-signed certificate, verifySSL=true
5660
if (storage_config.useSSL) {
5761
config.scheme = Aws::Http::Scheme::HTTPS;
62+
config.verifySSL = true;
63+
if (!storage_config.sslCACert.empty()) {
64+
config.caPath = ConvertToAwsString(storage_config.sslCACert);
65+
config.verifySSL = false;
66+
}
5867
} else {
5968
config.scheme = Aws::Http::Scheme::HTTP;
69+
config.verifySSL = false;
6070
}
61-
62-
if (!storage_config.sslCACert.empty()) {
63-
config.caPath = ConvertToAwsString(storage_config.sslCACert);
64-
}
65-
config.verifySSL = false;
66-
71+
6772
if (!storage_config.region.empty()) {
6873
config.region = ConvertToAwsString(storage_config.region);
6974
}

internal/core/src/storage/MinioChunkManager.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,22 @@ MinioChunkManager::MinioChunkManager(const StorageConfig& storage_config)
321321
Aws::Client::ClientConfiguration config = g_config;
322322
config.endpointOverride = ConvertToAwsString(storage_config.address);
323323

324+
// Three cases:
325+
// 1. no ssl, verifySSL=false
326+
// 2. self-signed certificate, verifySSL=false
327+
// 3. CA-signed certificate, verifySSL=true
324328
if (storage_config.useSSL) {
325329
config.scheme = Aws::Http::Scheme::HTTPS;
330+
config.verifySSL = true;
331+
if (!storage_config.sslCACert.empty()) {
332+
config.caPath = ConvertToAwsString(storage_config.sslCACert);
333+
config.verifySSL = false;
334+
}
326335
} else {
327336
config.scheme = Aws::Http::Scheme::HTTP;
337+
config.verifySSL = false;
328338
}
329339

330-
if (!storage_config.sslCACert.empty()) {
331-
config.caPath = ConvertToAwsString(storage_config.sslCACert);
332-
}
333-
config.verifySSL = false;
334-
335340
config.requestTimeoutMs = storage_config.requestTimeoutMs == 0
336341
? DEFAULT_CHUNK_MANAGER_REQUEST_TIMEOUT_MS
337342
: storage_config.requestTimeoutMs;

internal/proxy/accesslog/minio_handler.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ func newMinioClient(ctx context.Context, cfg config) (*minio.Client, error) {
108108
creds = credentials.NewStaticV4(cfg.accessKeyID, cfg.secretAccessKeyID, "")
109109
}
110110

111+
// We must set the cert path by os environment variable "SSL_CERT_FILE",
112+
// because the minio.DefaultTransport() need this path to read the file content,
113+
// we shouldn't read this file by ourself.
111114
if cfg.useSSL && len(cfg.sslCACert) > 0 {
112115
err := os.Setenv("SSL_CERT_FILE", cfg.sslCACert)
113116
if err != nil {
@@ -123,6 +126,7 @@ func newMinioClient(ctx context.Context, cfg config) (*minio.Client, error) {
123126
if err != nil {
124127
return nil, err
125128
}
129+
126130
var bucketExists bool
127131
// check valid in first query
128132
checkBucketFn := func() error {

internal/storage/minio_object_storage.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ func newMinioClient(ctx context.Context, c *config) (*minio.Client, error) {
107107
}
108108
}
109109

110+
// We must set the cert path by os environment variable "SSL_CERT_FILE",
111+
// because the minio.DefaultTransport() need this path to read the file content,
112+
// we shouldn't read this file by ourself.
110113
if c.useSSL && len(c.sslCACert) > 0 {
111114
err := os.Setenv("SSL_CERT_FILE", c.sslCACert)
112115
if err != nil {

pkg/util/paramtable/service_param.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,8 @@ func (p *MinioConfig) Init(base *BaseTable) {
10611061
p.SecretAccessKey.Init(base.mgr)
10621062

10631063
p.UseSSL = ParamItem{
1064-
Key: "minio.ssl.enabled",
1065-
FallbackKeys: []string{"minio.useSSL"},
1066-
Version: "2.3.12",
1064+
Key: "minio.useSSL",
1065+
Version: "2.0.0",
10671066
DefaultValue: "false",
10681067
PanicIfEmpty: true,
10691068
Doc: "Access to MinIO/S3 with SSL",

0 commit comments

Comments
 (0)