DoesS3BucketExistAsync should use the protocol defined by service endpoint
DoesS3BucketExistAsync forces HTTP
Remove https://github.com/aws/aws-sdk-net/blob/efcd29fa8e00d59d1448dc87232d2b3a9b73c63a/sdk/src/Services/S3/Custom/Util/AmazonS3Util.cs#L573 , which should let GetPreSignedURL figure out the correct protocol.
Try to execute DoesS3BucketExistAsync against an HTTPS-only Minio instance.
dotnet --info: .NET Core SDK (reflecting any global.json):
Version: 2.1.302
Commit: 9048955601
Runtime Environment:
OS Name: debian
OS Version: 9
OS Platform: Linux
RID: debian.9-x64
Base Path: /usr/share/dotnet/sdk/2.1.302/
Host (useful for support):
Version: 2.1.2
Commit: 811c3ce6c0
.NET Core SDKs installed:
2.1.302 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Actually it is not enough to remove that line, because that means effectively setting the protocol to whatever the enum defaults to.
Instead, DoesS3BucketExistAsync should fetch the protocol from the service URL e.g. (yes this is hacky code):
var serviceURL = ((AmazonServiceClient) s3Client).Config.DetermineServiceURL();
var request = new GetPreSignedUrlRequest
{
BucketName = bucketName,
Expires = s3Client.Config.CorrectedUtcNow.ToLocalTime().AddDays(1),
Verb = HttpVerb.HEAD,
Protocol = new Uri(serviceURL).Scheme.ToLowerInvariant() == "http" ? Protocol.HTTP : Protocol.HTTPS,
};
Alternatively, the GetPreSignedUrlRequest.Protocol property could be made nullable (with null meaning don't override the protocol) but I don't know where else that is used.
Thank you for reporting this. The default protocol for the config is HTTPS, so this would seem to be a bug. The fix will presumably be to use the config's UseHttp property to determine the correct protocol.
It appears that you are using Minio which is a third-party service provider. We are not currently prioritizing work to support third-party services.
@boblodgett this isn't just about Minio - the SDK is forcing an INSECURE request even when the endpoint is usually HTTPS. This is a pretty serious bug when you're using AWS S3 too. Please reopen.
we'll take another look at this. We are concerned that this maybe a breaking change for application in certain environments. At minimum, we should be able to make a v2 of the function as a way forward.
Has this been effectively fixed in https://github.com/aws/aws-sdk-net/pull/1209 now?
Yes. Use DoesS3BucketExistV2.