lucidsoftware / apt-boto-s3

The fast and simple S3 transport for apt.
Apache License 2.0
56 stars 13 forks source link

Wrong signature type returned by s3_uri.signature_version #6

Closed yannh closed 8 years ago

yannh commented 8 years ago

I believe the signature_version method does not return s3v4 when it should. Specifically: elif self.virtual_host_bucket() == '': return 's3v4'

I believe this never get executed. Some debugging showed that in my case self.virtual_host_bucket would return None instead of empty string, therefore I patched it to : elif not self.virtual_host_bucket()

On a side note, to get this working I had to hardcode the region in the connection initialisation:

163 s3 = boto3.resource( 164 's3', 165 aws_access_key_id=s3_access_key, 166 aws_secret_access_key=s3_access_secret, 167 endpoint_url=s3_uri.endpoint_url(), 168 region_name="eu-central-1", 169 config=botocore.client.Config(signature_version=s3_uri.signature_version()) 170 )

This is currently just a hack to get things working as I am in a rush - but I might be able to provide a PR in a few weeks.

pauldraper commented 8 years ago

It should be empty, if the URL is s3://s3.amazonaws.com/bucket.

I did add the ability to pull the region from the URL, if present. s3://s3-eu-central-1.amazonaws.com/bucket

I recommend using the s3://s3-region.amazonaws.com/bucket style URL. Though there's probably a way to query for a bucket's region.

yannh commented 8 years ago

s3://s3-eu-central-1.amazonaws.com/bucket ? I was using s3://s3.eu-central-1.amazonaws.com/bucket , which is an alternative DNS :) It works with a dash instead of the dot :+1:

pauldraper commented 8 years ago

Yeah, I noticed that in https://github.com/lucidsoftware/apt-boto-s3/issues/5#issuecomment-226533951

eu-central-1 and ap-northeast-2 allow s3.region or s3-region. Everyone else supports only the latter.