2017-06-08 1 views
1

Ich verwende meine Anwendung in einem AWS AMI. Das AMI wird über eine Cloud-Formationsvorlage gestartet, die AWS::IAM::Role role mit sts:AssumeRole erstellt. Sobald die EC2-Instanz aktiv ist, erstelle ich einen S3-Bucket von der Ec2-Instanz mit boto3.create_bucket.x-amz-server-side-encryption header wird für diesen Vorgang nicht unterstützt

In meiner Anwendung lade ich eine Datei in den erstellten Bucket mit Verschlüsselungsmarkierung auf. Aber beim Hochladen Ich erhalte eine Fehlermeldung:

com.amazonaws.services.s3.model.AmazonS3Exception: x-amz-server-side-encryption header is not supported for this operation. (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: 04DD9259D04F92CA), S3 Extended Request ID: EVdqFn6jUNshxUejZFWa6VN/lHPXHyi0F+TG+UZ3K9Sh8Gy0MPABi1AnxZloIajypLb39/5UAVA=

Dies ist die serverseitige Verschlüsselung Teil meines Code:

ObjectMetadata meta = new ObjectMetadata(); 
    meta.setContentLength(contentLength); 
    meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION) 

Was mache ich falsch? Dies funktioniert wie erwartet, wenn ich meinen Code anderswo ausführe und einen S3-Bucket verwende. Ist das irgendwie an Wolkenbildung oder sts:AssumeRole gebunden?

Antwort

0

The Put object function in boto3 verfügt über Optionen zum Festlegen der Verschlüsselung auf Objektebene.

object = bucket.put_object(
    ServerSideEncryption='AES256'|'aws:kms', 
    SSECustomerAlgorithm='string', 
    SSECustomerKey='string', 
    SSEKMSKeyId='string', 
) 
  • ServerSideEncryption (string) -- The Server-side encryption algorithm used when storing this object in S3 (e.g., AES256, aws:kms). StorageClass (string) -- The type of storage to use for the object. Defaults to 'STANDARD'.

  • SSECustomerAlgorithm (string) -- Specifies the algorithm to use to when encrypting the object (e.g., AES256).

  • SSECustomerKey (string) -- Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data. This value is used to store the object and then it is discarded; Amazon does not store the encryption key. The key must be appropriate for use with the algorithm specified in the x-amz-server-side​-encryption​-customer-algorithm header.> -

  • SSECustomerKeyMD5 (string) -- Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. Amazon S3 uses this header for a message integrity check to ensure the encryption key was transmitted without error. Please note that this parameter is automatically populated if it is not provided. Including this parameter is not required

  • SSEKMSKeyId (string) -- Specifies the AWS KMS key ID to use for object encryption. All GET and PUT requests for an object protected by AWS KMS will fail if not made via SSL or using SigV4. Documentation on configuring any of the officially supported AWS SDKs and CLI can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version)

http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html

Verwandte Themen