Skip to content

Commit

Permalink
fix: Do not check ETag for SSE KMS
Browse files Browse the repository at this point in the history
  • Loading branch information
justhamade authored and Justin Hamade committed Jul 17, 2019
1 parent 70d8e7f commit 106d975
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Client.prototype.uploadFile = function(params) {
var defaultContentType = params.defaultContentType || 'application/octet-stream';
s3Params.ContentType = mime.getType(localFile, defaultContentType);
}
var sse = s3Params.ServerSideEncryption;
var fatalError = false;
var localFileSlicer = null;
var parts = [];
Expand Down Expand Up @@ -315,7 +316,7 @@ Client.prototype.uploadFile = function(params) {
}
pend.wait(function() {
if (fatalError) return;
if (!compareMultipartETag(data.ETag, multipartETag)) {
if (sse !== 'aws:kms' && !compareMultipartETag(data.ETag, multipartETag)) {
errorOccurred = true;
uploader.progressAmount -= overallDelta;
cb(new Error("ETag does not match MD5 checksum"));
Expand Down Expand Up @@ -411,7 +412,7 @@ Client.prototype.uploadFile = function(params) {
}
pend.wait(function() {
if (fatalError) return;
if (!compareMultipartETag(data.ETag, localFileStat.multipartETag)) {
if (sse !== 'aws:kms' && !compareMultipartETag(data.ETag, localFileStat.multipartETag)) {
cb(new Error("ETag does not match MD5 checksum"));
return;
}
Expand Down Expand Up @@ -507,9 +508,11 @@ Client.prototype.downloadFile = function(params) {
handleError(new Error("Downloaded size does not match Content-Length"));
return;
}
if (eTagCount === 1 && !multipartETag.anyMatch(eTag)) {
handleError(new Error("ETag does not match MD5 checksum"));
return;
if (headers['x-amz-server-side-encryption'] !== 'aws:kms' ) {
if (eTagCount === 1 && !multipartETag.anyMatch(eTag)) {
handleError(new Error("ETag does not match MD5 checksum"));
return;
}
}
cb();
});
Expand Down Expand Up @@ -773,6 +776,7 @@ Client.prototype.downloadBuffer = function(s3Params) {
var self = this;
var downloader = new EventEmitter();
s3Params = extend({}, s3Params);
var sse = s3Params.ServerSideEncryption;

downloader.progressAmount = 0;

Expand Down Expand Up @@ -825,9 +829,11 @@ Client.prototype.downloadBuffer = function(s3Params) {
handleError(new Error("Downloaded size does not match Content-Length"));
return;
}
if (eTagCount === 1 && !multipartETag.anyMatch(eTag)) {
handleError(new Error("ETag does not match MD5 checksum"));
return;
if (headers['x-amz-server-side-encryption'] !== 'aws:kms' ) {
if (eTagCount === 1 && !multipartETag.anyMatch(eTag)) {
handleError(new Error("ETag does not match MD5 checksum"));
return;
}
}
cb();
});
Expand Down

0 comments on commit 106d975

Please sign in to comment.