我有一个iOS应用程序上传/下载到亚马逊的S3。我想用我自己的Minio云取代亚马逊的S3。Minio与iOS的AWS S3 SDK SignatureDoesNotMatch
我按照这里的快速教程https://github.com/minio/minio,我有我的本地主机上运行Minio,我可以把文件使用s3cmd(https://docs.minio.io/docs/s3cmd-with-minio)。
不幸的是,我无法设法从我的iOS应用程序中运行它。
我使用的是AWS SDK v2.4.16,因此我可以更改端点并使其成为本地主机(http://my-imac.local:9000),并且更新了我的访问密钥和密钥,但出现SignatureDoesNotMatch错误:“我们计算的请求签名与您提供的签名不符,请检查您的密钥和签名方式。“
指着我的本地服务器:
AWSEndpoint *minioEndpoint = [[AWSEndpoint alloc] initWithURLString:@"http://my-imac.local:9000"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:region
endpoint:minioEndpoint
credentialsProvider:credentialProvider];
[AWSS3 registerS3WithConfiguration:configuration forKey:s3RegionString];
这里就是我得到我的本地主机:
time="2017-04-10T23:36:21Z" level=error msg="{\"method\":\"PUT\",\"path\":\"/mybucket/28AB7D6DCFC44102955EBC0AEFF6E4E2-20170407161228839-0700/foo_28AB7D6DCFC44102955EBC0AEFF6E4E2-20170407161228839-0700_v2.json_bin\",\"query\":\"\",\"header\":{\"Accept\":[\"/\"],\"Accept-Encoding\":[\"gzip, deflate\"],\"Accept-Language\":[\"en-us\"],\"Authorization\":[\"AWS4-HMAC-SHA256 Credential=LNTXV0YMMZ9SY7MD0ACZ/20170410/us-east-1/s3/aws4_request, SignedHeaders=content-length;content-type;host;user-agent;x-amz-date, Signature=7b2f4172dd926ba84c7edba5170028e0f9361bd8a656ad8f01c7e232f585ab31\"],\"Connection\":[\"keep-alive\"],\"Content-Length\":[\"282416\"],\"Content-Type\":[\"application/octet-stream\"],\"Host\":[\"my-imac.local\"],\"User-Agent\":[\"aws-sdk-iOS/2.4.16 iPhone-OS/9.1 en_US\"],\"X-Amz-Date\":[\"20170410T233620Z\"]}}" cause="Signature does not match" source="[object-handlers.go:472:objectAPIHandlers.PutObjectHandler()]"
在iOS端:
请求标题是:
{
Authorization = "AWS4-HMAC-SHA256 Credential=LNTXV0YMMZ9SY7MD0ACZ/20170410/us-east-1/s3/aws4_request, SignedHeaders=content-length;content-type;host;user-agent;x-amz-date, Signature=454c8bad35bdd3a15a08c9bf555fc69f1d5c0dabad78a474eabd4d844ca69aef";
"Content-Length" = 282416;
"Content-Type" = "application/octet-stream";
Host = "my-imac.local";
"User-Agent" = "aws-sdk-iOS/2.4.16 iPhone-OS/9.1 en_US";
"X-Amz-Date" = 20170410T233622Z;
}
re sponse:
2017-04-10 16:36:22.507 demo[7969:4711709] AWSiOSSDK v2.4.16 [Debug] AWSURLSessionManager.m line:566 | -[AWSURLSessionManager printHTTPHeadersForResponse:] | Response headers:
{
"Accept-Ranges" = bytes;
Connection = close;
"Content-Type" = "application/xml";
Date = "Mon, 10 Apr 2017 23:36:22 GMT";
Server = "Minio/RELEASE.2017-03-16T21-50-32Z (linux; amd64)";
"Transfer-Encoding" = Identity;
Vary = Origin;
"X-Amz-Request-Id" = 14B42D7AE5B09A2B;
}
嘿你能请https://github.com/minio/minio/issues/4039#issuecomment-293787123并让我们知道这是否解决了您所面临的问题? – koolhead17
@ koolhead17:是的,就是这样!谢谢 – LG01