Object Storage Service (OSS) provides server-side encryption for uploaded data. When you upload data, OSS encrypts and stores it. When you download the data, OSS automatically decrypts it and returns the original data. The HTTP response header indicates that the data was encrypted on the server.
Usage notes
Before you configure server-side encryption, ensure that you understand this feature. For more information, see Server-side encryption.
The sample code in this topic uses a public endpoint in the China (Hangzhou) region (
cn-hangzhou) as an example. If you want to access OSS from other Alibaba Cloud products in the same region, you must use an internal network endpoint. For more information about the regions and endpoints that OSS supports, see Regions and endpoints.To configure bucket encryption, you must have the
oss:PutBucketEncryptionpermission. To retrieve the bucket encryption configuration, you must have theoss:GetBucketEncryptionpermission. To delete the bucket encryption configuration, you must have theoss:DeleteBucketEncryptionpermission. For more information, see Attach a custom policy to a RAM user.
Examples
References
For the complete sample code for server-side encryption, see put_bucket_encryption, get_bucket_encryption, and delete_bucket_encryption.
For more information about the API operation for configuring server-side encryption, see PutBucketEncryption.
For more information about the API operation for retrieving the server-side encryption configuration, see GetBucketEncryption.
For more information about the API operation for deleting the server-side encryption configuration, see DeleteBucketEncryption.