设置桶的加密配置
功能介绍
OBS使用PUT操作为桶创建或更新默认服务端加密配置信息。
设置桶加密配置后,在该桶中上传对象时,会采用桶的默认加密配置对数据进行加密。目前支持配置的服务端加密方式有:KMS托管密钥的服务端加密(SSE-KMS)、OBS托管密钥的服务端加密(SSE-OBS)。有关服务端加密方式的更多信息请参考服务端加密章节。
要使用此操作,您必须具有执行PutEncryptionConfiguration操作的权限。桶拥有者默认具有此权限,并且可以将此权限授予其他人。
有关权限控制的更多信息请参考《对象存储服务权限配置指南》的OBS权限控制概述章节。
请求消息样式(SSE-KMS SM4)
PUT /?encryption HTTP/1.1 User-Agent: curl/7.29.0 Host: bucketname.obs.cn-north-4.myhuaweicloud.com Accept: */* Date: date Authorization: authorization string Content-Length: length <ServerSideEncryptionConfiguration> <Rule> <ApplyServerSideEncryptionByDefault> <SSEAlgorithm>kms</SSEAlgorithm> <KMSDataEncryption>SM4</KMSDataEncryption> <KMSMasterKeyID>kmskeyid-value</KMSMasterKeyID> </ApplyServerSideEncryptionByDefault> </Rule> </ServerSideEncryptionConfiguration>
请求消息样式(SSE-KMS AES256)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
PUT /?encryption HTTP/1.1 User-Agent: curl/7.29.0 Host: bucketname.obs.cn-north-4.myhuaweicloud.com Accept: */* Date: date Authorization: authorization string Content-Length: length <ServerSideEncryptionConfiguration> <Rule> <ApplyServerSideEncryptionByDefault> <SSEAlgorithm>kms</SSEAlgorithm> <KMSMasterKeyID>kmskeyid-value</KMSMasterKeyID> </ApplyServerSideEncryptionByDefault> </Rule> </ServerSideEncryptionConfiguration> |
请求消息样式(SSE-OBS)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
PUT /?encryption HTTP/1.1 User-Agent: curl/7.29.0 Host: bucketname.obs.cn-north-4.myhuaweicloud.com Accept: */* Date: date Authorization: authorization string Content-Length: length <ServerSideEncryptionConfiguration> <Rule> <ApplyServerSideEncryptionByDefault> <SSEAlgorithm>AES256</SSEAlgorithm> </ApplyServerSideEncryptionByDefault> </Rule> </ServerSideEncryptionConfiguration> |
请求消息参数
该请求消息中不使用消息参数。
请求消息头
该请求使用公共消息头,具体参见表3。
请求消息元素
在此请求中,需要在请求的消息体中配置桶的加密配置。桶加密的配置信息以XML格式上传。具体的配置元素如表1。
消息头名称 |
描述 |
是否必选 |
---|---|---|
ServerSideEncryptionConfiguration |
桶的默认加密配置的根元素。 类型:Container 父元素:无 子元素:Rule |
是 |
Rule |
桶的默认加密配置的子元素。 类型:Container 父元素:ServerSideEncryptionConfiguration 子元素:ApplyServerSideEncryptionByDefault |
是 |
ApplyServerSideEncryptionByDefault |
桶的默认加密配置的子元素。 类型:Container 父元素:Rule 子元素:SSEAlgorithm,KMSMasterKeyID |
是 |
SSEAlgorithm |
桶的默认加密配置要使用的服务端加密算法。 类型:String 有效值:
父元素:ApplyServerSideEncryptionByDefault |
是 |
KMSDataEncryption |
SSE-KMS加密方式下的数据加密算法。 类型:String 有效值:SM4 父元素:ApplyServerSideEncryptionByDefault |
否 |
KMSMasterKeyID |
SSE-KMS加密方式下使用的KMS主密钥,如果用户没有提供该头域,那么默认的主密钥将会被使用。 类型:String 有效值支持两种格式:
其中:
父元素:ApplyServerSideEncryptionByDefault |
否 |
ProjectID |
SSE-KMS加密方式下KMS主密钥所属的项目ID。如果KMS主密钥所属的项目为非默认项目,则需要通过该参数进行项目ID指定。 类型:String 有效值:
父元素:ApplyServerSideEncryptionByDefault
说明:
使用非默认IAM项目下的自定义密钥对桶内对象进行SSE-KMS加密,只有密钥拥有者可以对加密后的对象进行上传下载类操作,非密钥拥有者不能对加密后的对象进行上传下载类操作。 |
否 |
响应消息样式
1 2 3 |
HTTP/1.1 status_code Date: date Content-Length: length |
响应消息头
该请求的响应消息使用公共消息头,具体请参考表1。
响应消息元素
该请求的响应消息不带消息元素。
错误响应消息
无特殊错误,所有错误已经包含在表2中。
请求示例(SSE-KMS SM4)
PUT /?encryption HTTP/1.1 User-Agent: curl/7.29.0 Host: bucketname.obs.cn-north-4.myhuaweicloud.com Accept: */* Date: Thu, 21 Feb 2019 03:05:34 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:DpSAlmLX/BTdjxU5HOEwflhM0WI= Content-Length: 778 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ServerSideEncryptionConfiguration xmlns="http://obs.cn-north-4.myhuaweicloud.com/doc/2015-06-30/"> <Rule> <ApplyServerSideEncryptionByDefault> <SSEAlgorithm>kms</SSEAlgorithm> <KMSDataEncryption>SM4</KMSDataEncryption> <KMSMasterKeyID>4f1cd4de-ab64-4807-920a-47fc42e7f0d0</KMSMasterKeyID> </ApplyServerSideEncryptionByDefault> </Rule> </ServerSideEncryptionConfiguration>
响应示例(SSE-KMS SM4)
1 2 3 4 5 6 |
HTTP/1.1 200 OK Server: OBS x-obs-request-id: BF26000001643670AC06E7B9A7767921 x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCSvK6z8HV6nrJh49gsB5vqzpgtohkiFm Date: Thu, 21 Feb 2019 03:05:34 GMT Content-Length: 0 |
请求示例(SSE-KMS AES256)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
PUT /?encryption HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.cn-north-4.myhuaweicloud.com Accept: */* Date: Thu, 21 Feb 2019 03:05:34 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:DpSAlmLX/BTdjxU5HOEwflhM0WI= Content-Length: 778 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ServerSideEncryptionConfiguration xmlns="http://obs.cn-north-4.myhuaweicloud.com/doc/2015-06-30/"> <Rule> <ApplyServerSideEncryptionByDefault> <SSEAlgorithm>kms</SSEAlgorithm> <KMSMasterKeyID>4f1cd4de-ab64-4807-920a-47fc42e7f0d0</KMSMasterKeyID> </ApplyServerSideEncryptionByDefault> </Rule> </ServerSideEncryptionConfiguration> |
响应示例(SSE-KMS AES256)
1 2 3 4 5 6 |
HTTP/1.1 200 OK Server: OBS x-obs-request-id: BF26000001643670AC06E7B9A7767921 x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCSvK6z8HV6nrJh49gsB5vqzpgtohkiFm Date: Thu, 21 Feb 2019 03:05:34 GMT Content-Length: 0 |
请求示例(SSE-OBS)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
PUT /?encryption HTTP/1.1 User-Agent: curl/7.29.0 Host: bucketname.obs.cn-north-4.myhuaweicloud.com Accept: */* Date: Thu, 21 Feb 2019 03:05:34 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:DpSAlmLX/BTdjxU5HOEwflhM0WI= Content-Length: 778 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ServerSideEncryptionConfiguration xmlns="http://obs.cn-north-4.myhuaweicloud.com/doc/2015-06-30/"> <Rule> <ApplyServerSideEncryptionByDefault> <SSEAlgorithm>AES256</SSEAlgorithm> </ApplyServerSideEncryptionByDefault> </Rule> </ServerSideEncryptionConfiguration> |
响应示例(SSE-OBS)
1 2 3 4 5 6 |
HTTP/1.1 200 OK Server: OBS x-obs-request-id: BF26000001643670AC06E7B9A7767921 x-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCSvK6z8HV6nrJh49gsB5vqzpgtohkiFm Date: Thu, 21 Feb 2019 03:05:34 GMT Content-Length: 0 |