@@ -169,7 +169,15 @@ exports.canonicalizeHeaders = function(headers){
     if (0 !== field.indexOf('x-amz')) continue;
     buf.push(field + ':' + val);
   }
-  return buf.sort().join('\n');
+
+  var headerSort = function(a, b) {
+    // Headers are sorted lexigraphically based on the header name only.
+    a = a.split(":")[0]
+    b = b.split(":")[0]
+
+    return a > b ? 1 : -1;
+  }
+  return buf.sort(headerSort).join('\n');
 };
 
 /**