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

Add ability to handle sse-c with add-header #1004

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

geraldhansen
Copy link

@geraldhansen geraldhansen commented Sep 26, 2018

Hi there,

I like to use s3cmd for sse-c, for this I use the add-header parameter in this way:

secret="12345678901234567890123456789012" 
key=$(echo -n $secret | base64)
key_md5=$(echo -n $secret | openssl dgst -md5 -binary | openssl enc -base64)

s3cmd --add-header=x-amz-server-side-encryption-customer-algorithm:AES256 \
    --add-header=x-amz-server-side-encryption-customer-key:"${key}" \
    --add-header=x-amz-server-side-encryption-customer-key-MD5:"${key_md5}" \
    --remove-header=x-amz-server-side-encryption \
    put test.txt s3://aws-encryption-test/test_encrypted.txt
s3cmd --add-header=x-amz-server-side-encryption-customer-algorithm:AES256 \
    --add-header=x-amz-server-side-encryption-customer-key:"${key}" \
    --add-header=x-amz-server-side-encryption-customer-key-MD5:"${key_md5}" \
    --remove-header=x-amz-server-side-encryption \
    get s3://aws-encryption-test/test_encrypted.txt test_downloaded.txt

This commit will suppress md5-sum checks for sse-c uploaded and downloaded
files. And use extra-headers also for get requests to download
sse-c enrypted files again.

This will suppress md5-sum checks for sse-c uploaded and downloaded
files. And use extra-headers also for get and info requests to download
sse-c enrypted files again.
@PoplarYang
Copy link

I found a error:

secret="12345678901234567890123456789012" 
key=$(echo -n $secret | base64)
key_md5=$(echo -n $secret | openssl dgst -md5 -binary | openssl enc -base64)

s3cmd --add-header=x-amz-server-side-encryption-customer-algorithm:AES256 \
    --add-header=x-amz-server-side-encryption-customer-key:"${key}" \
    --add-header=x-amz-server-side-encryption-customer-key-MD5:"${key_md5}" \
    --remove-header=x-amz-server-side-encryption put --acl-public test.txt s3://test-src/test6.txt -vvvv
INFO: No cache file found, creating it.
INFO: Compiling list of local files...
INFO: Running stat() and reading/calculating MD5 values on 1 files, this may take some time...
INFO: Summary: 1 local files to upload
WARNING: test.txt: Owner username not known. Storing UID=501 instead.
upload: 'test.txt' -> 's3://test-src/test6.txt'  [1 of 1]
 12 of 12   100% in    0s   349.80 B/s  done
Public URL of the object is: http://ks3-bj.ksyun.com/test-src/test6.txt

s3cmd --add-header=x-amz-server-side-encryption-customer-algorithm:AES256 \
    --add-header=x-amz-server-side-encryption-customer-key:"${key}" \
    --add-header=x-amz-server-side-encryption-customer-key-MD5:"${key_md5}" \
    --remove-header=x-amz-server-side-encryption get s3://test-src/test6.txt .
download: 's3://test-src/test6.txt' -> './test6.txt'  [1 of 1]
ERROR: S3 error: 400 (MissingCustomerKey): The data is encrypted by customer key, but missing it in the request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants