From b359508ab4a8fce95cb03088e7032b7ffa0d61b5 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 2 Sep 2025 18:08:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9minio=20=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Helper/OSSService.cs | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/IRaCIS.Core.Application/Helper/OSSService.cs b/IRaCIS.Core.Application/Helper/OSSService.cs index 2d8ad841b..b9bb13502 100644 --- a/IRaCIS.Core.Application/Helper/OSSService.cs +++ b/IRaCIS.Core.Application/Helper/OSSService.cs @@ -16,6 +16,7 @@ using Minio; using Minio.DataModel; using Minio.DataModel.Args; using Minio.Exceptions; +using System.Net.Http; using System.Reactive.Linq; using System.Runtime.InteropServices; using System.Web; @@ -226,8 +227,14 @@ public class OSSService : IOSSService var minIOConfig = ObjectStoreServiceOptions.MinIO; + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; + var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}") .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL) + .WithHttpClient(new HttpClient(httpClientHandler)) .Build(); var putObjectArgs = new PutObjectArgs() @@ -347,9 +354,14 @@ public class OSSService : IOSSService { var minIOConfig = ObjectStoreServiceOptions.MinIO; + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}") .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL) + .WithHttpClient(new HttpClient(httpClientHandler)) .Build(); var putObjectArgs = new PutObjectArgs() @@ -420,10 +432,16 @@ public class OSSService : IOSSService } else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO") { + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; + var minIOConfig = ObjectStoreServiceOptions.MinIO; var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}") .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL) + .WithHttpClient(new HttpClient(httpClientHandler)) .Build(); var getObjectArgs = new GetObjectArgs() @@ -508,10 +526,17 @@ public class OSSService : IOSSService { var minIOConfig = ObjectStoreServiceOptions.MinIO; + + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; + var minioClient = new MinioClient() .WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}") .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey) .WithSSL(minIOConfig.UseSSL) + .WithHttpClient(new HttpClient(httpClientHandler)) .Build(); var memoryStream = new MemoryStream(); @@ -961,8 +986,14 @@ public class OSSService : IOSSService var minIOConfig = ObjectStoreServiceOptions.MinIO; + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; + var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}") .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL) + .WithHttpClient(new HttpClient(httpClientHandler)) .Build(); @@ -1070,8 +1101,15 @@ public class OSSService : IOSSService var minIOConfig = ObjectStoreServiceOptions.MinIO; + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; + + var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}") .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL) + .WithHttpClient(new HttpClient(httpClientHandler)) .Build(); @@ -1149,8 +1187,15 @@ public class OSSService : IOSSService var minIOConfig = ObjectStoreServiceOptions.MinIO; + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; + + var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}") .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL) + .WithHttpClient(new HttpClient(httpClientHandler)) .Build();