Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Do not check ETag for SSE KMS #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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