0

I get the following error, while trying to upload a file to Amazon using AFNetworking / AFAmazonS3Client

s3Client = [[AFAmazonS3Client alloc] initWithAccessKeyID:@"mykey" secret:@"mysecretkey"];
s3Client.bucket = @"media.mysite.com";

[s3Client postObjectWithFile:video.assetPath destinationPath:@"/media/videos/" parameters:nil progress:

 ^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite){

     DLog(@"%f%% Uploaded", (totalBytesWritten / (totalBytesExpectedToWrite * 1.0f) * 100));
 }

                     success:^(id responseobject){

                         DLog(@"Success");
                         [self deleteAsset:video];

                     }failure:^(NSError* error){

                          DLog(@"Failed %@", error);
                         [self updateVideoAsset:video.assetID key:@"uploadStatus" value:[NSNumber numberWithInt:ESUploadNotStarted]];
                     }];

The certificate for this server is invalid. You might be connecting to a server that is pretending to be “media.myserver.com.s3.amazonaws.com” which could put your confidential information at risk

how to get around this

Thanks Tonku

2 Answers2

0

There appears to be some problems in the AWS SDK for iOS (older versions) that could cause this problem: https://forums.aws.amazon.com/message.jspa?messageID=248288

Blake Schwendiman
  • 442
  • 1
  • 4
  • 9
0

In case someone else stumbles onto this: Use a bucket name without periods in it (e.g. media-mysite-com). That way, Amazon's wildcard SSL certificate will still apply, and you'll avoid the error.

See e.g. How to Configure SSL for Amazon S3 bucket

Community
  • 1
  • 1