You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/11/02 18:07:29 UTC

svn commit: r1196699 - /libcloud/trunk/libcloud/compute/drivers/ec2.py

Author: tomaz
Date: Wed Nov  2 17:07:28 2011
New Revision: 1196699

URL: http://svn.apache.org/viewvc?rev=1196699&view=rev
Log:
Fix the request signature generation in the base EC2 compute driver. If the
endpoint is using a non-standard port, append it to the hostname used to
generate the signature. Patch has been contributed by Simon Delamare <simon dot
delamare at ens-lyon dot fr> and is part of LIBCLOUD-125.

Modified:
    libcloud/trunk/libcloud/compute/drivers/ec2.py

Modified: libcloud/trunk/libcloud/compute/drivers/ec2.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/ec2.py?rev=1196699&r1=1196698&r2=1196699&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/ec2.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/ec2.py Wed Nov  2 17:07:28 2011
@@ -225,7 +225,12 @@ class EC2Connection(ConnectionUserAndKey
                          urllib.quote(params[key], safe='-_~'))
 
         qs = '&'.join(pairs)
-        string_to_sign = '\n'.join(('GET', self.host, path, qs))
+
+        hostname = self.host
+        if (self.secure and self.port != 443) or (not self.secure and self.port != 80):
+            hostname += ":" + str(self.port)
+
+        string_to_sign = '\n'.join(('GET', hostname, path, qs))
 
         b64_hmac = base64.b64encode(
             hmac.new(secret_key, string_to_sign, digestmod=sha256).digest()