SignatureDoesNotMatch when CultureInfo is thai
KeNJiKunG opened this issue · 1 comments
KeNJiKunG commented
The requests always return SignatureDoesNotMatch
when CultureInfo.CurrentCulture
is 'th-TH' but works when CultureInfo.CurrentCulture
is 'en-GB'.
I found these codes will generated Authorization token with non-gregorian year which is incorrect.
minio-dotnet/Minio/V4Authenticator.cs
Lines 237 to 240 in 254b32f
minio-dotnet/Minio/V4Authenticator.cs
Lines 223 to 228 in 254b32f
Here is my reproducible code.
using System.Globalization;
using Minio;
public class Program
{
public static async Task Main(string[] args)
{
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("th-TH");
// CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-GB");
var http = new HttpClient(new MyHttpClientHandler());
var endpoint = "play.min.io";
var accessKey = "USERNAME"; // <--- Replace with a valid access key.
var secretKey = "PASSWORD"; // <--- Replace with a valid secret key.
var factory = new MinioClientFactory(config =>
{
config.WithEndpoint(endpoint)
.WithCredentials(accessKey, secretKey)
.WithHttpClient(http, true)
.WithSSL();
// config.SetTraceOn(new ReqeustLogger());
});
var client = factory.CreateClient().Build();
// client.SetTraceOn(new ReqeustLogger());
var isExists = await client.BucketExistsAsync(new Minio.DataModel.Args.BucketExistsArgs()
.WithBucket("my-every-not-existing-random-bucket-2")
);
Console.WriteLine(isExists);
var download = await client.GetObjectAsync(new Minio.DataModel.Args.GetObjectArgs()
.WithBucket("my-every-not-existing-random-bucket-2")
.WithObject("Not exists")
.WithCallbackStream((stream) => { })
);
Console.WriteLine(download);
}
}
public class MyHttpClientHandler : HttpClientHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var respons = await base.SendAsync(request, cancellationToken);
Console.WriteLine( request.Headers );
Console.WriteLine(respons.Headers);
return respons;
}
}
asdword commented
I also have the same problem. add this code before executing any minio actions for reset current culture
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
worked for me.