LiveUI / S3

S3 Client written in Swift
MIT License
94 stars 60 forks source link

s3.location returns buggy Region for us-west-1 #48

Open tomTheWolf opened 5 years ago

tomTheWolf commented 5 years ago

When I call s3.location() for a bucket in region us-west-1, the Region returned looks like this:

Region(name: s3-us-west-1, hostName: nil, useTLS: true)

Then, when calling s3.list() using that location, I get this error:

2019-10-07 15:32:10.520061-0700 Run[70472:4524045] TIC SSL Trust Error [2:0x102cc4bb0]: 3:0 2019-10-07 15:32:10.527247-0700 Run[70472:4524045] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9843) 2019-10-07 15:32:10.527305-0700 Run[70472:4524045] Task <5F5D6D8B-0F73-4900-BB34-754DFBD7D862>.<2> HTTP load failed (error code: -1202 [3:-9843]) 2019-10-07 15:32:10.527380-0700 Run[70472:4524047] Task <5F5D6D8B-0F73-4900-BB34-754DFBD7D862>.<2> finished with error - code: -1202 ERROR: Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “MY_BUCKET.s3.s3-us-west-1.amazonaws.com” which could put your confidential information at risk." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x102ccc510>, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9843, NSErrorPeerCertificateChainKey=( "<cert(0x103840000) s: *.s3-us-west-1.amazonaws.com i: DigiCert Baltimore CA-2 G2>", "<cert(0x103841c00) s: DigiCert Baltimore CA-2 G2 i: Baltimore CyberTrust Root>" ), NSUnderlyingError=0x102e1fa90 {Error Domain=kCFErrorDomainCFNetwork Code=-1202 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x102ccc510>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9843, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9843, kCFStreamPropertySSLPeerCertificates=( "<cert(0x103840000) s: *.s3-us-west-1.amazonaws.com i: DigiCert Baltimore CA-2 G2>", "<cert(0x103841c00) s: DigiCert Baltimore CA-2 G2 i: Baltimore CyberTrust Root>" )}}, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “MY_BUCKET.s3.s3-us-west-1.amazonaws.com” which could put your confidential information at risk., NSErrorFailingURLKey=https://MY_BUCKET.s3.s3-us-west-1.amazonaws.com/?list-type=2, NSErrorFailingURLStringKey=https://MY_BUCKET.s3.s3-us-west-1.amazonaws.com/?list-type=2, NSErrorClientCertificateStateKey=0} [ ERROR ] Abort.400: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “MY_BUCKET.s3.s3-us-west-1.amazonaws.com” which could put your confidential information at risk. (S3Controller.swift:86)

It looks like the region is actually supposed to be named us-west-1, not s3-us-west-1. If I call s3.list() and pass the .usWest1 region, the call works fine.