This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addEncryptionHeaders(encryptionKey) { | |
return function(req) { | |
const key = Buffer.alloc(32).fill(encryptionKey) | |
const key64 = AWS.util.base64.encode(key) | |
const keyMD5 = AWS.util.crypto.md5(key.toString(), 'base64') | |
req.httpRequest.headers['x-amz-server-side-encryption-customer-algorithm'] = 'AES256' | |
req.httpRequest.headers['x-amz-server-side-encryption-customer-key'] = key64 | |
req.httpRequest.headers['x-amz-server-side-encryption-customer-key-MD5'] = keyMD5 | |
} | |
} |