Browse code

Add --signature-v2 and signature_v2 config option

For use with S3-like systems that don't yet support V4 signatures.

If you use --signature-v2 against an AWS endpoint that only supports
v4 signatures, s3cmd will loop forever trying to re-issue the same
(failing) request with signature v2. This isn't ideal, but is a side
effect of the attempt to upgrade from V2 to V4 silently.

Matt Domsch authored on 2014/12/17 08:08:00
Showing 3 changed files
... ...
@@ -116,6 +116,7 @@ class Config(object):
116 116
     expiry_days = ""
117 117
     expiry_date = ""
118 118
     expiry_prefix = ""
119
+    signature_v2 = False
119 120
 
120 121
     ## Creating a singleton
121 122
     def __new__(self, configfile = None, access_key=None, secret_key=None):
... ...
@@ -153,7 +153,7 @@ class S3Request(object):
153 153
             h += "/" + self.resource['bucket']
154 154
         h += self.resource['uri']
155 155
 
156
-        if self.resource['bucket'] is None or not check_bucket_name_dns_conformity(self.resource['bucket']):
156
+        if self.resource['bucket'] is None or not check_bucket_name_dns_conformity(self.resource['bucket']) or self.s3.config.signature_v2:
157 157
             # in case of bad DNS name due to bucket name v2 will be used
158 158
             # this way we can still use capital letters in bucket names for the older regions
159 159
             debug("Using signature v2")
... ...
@@ -2230,6 +2230,7 @@ def main():
2230 2230
     optparser.add_option("--ca-certs", dest="ca_certs_file", action="store", default=None, help="Path to SSL CA certificate FILE (instead of system default)")
2231 2231
     optparser.add_option("--check-certificate", dest="check_ssl_certificate", action="store_true", help="Check SSL certificate validity")
2232 2232
     optparser.add_option("--no-check-certificate", dest="check_ssl_certificate", action="store_false", help="Check SSL certificate validity")
2233
+    optparser.add_option("--signature-v2", dest="signature_v2", action="store_true", help="Use AWS Signature version 2 instead of newer signature methods. Helpful for S3-like systems that don't have AWS Signature v4 yet.")
2233 2234
 
2234 2235
     optparser.set_usage(optparser.usage + " COMMAND [parameters]")
2235 2236
     optparser.set_description('S3cmd is a tool for managing objects in '+