@@ -308,6 +308,29 @@ impl fmt::Debug for AzureStorageConfig {
308308 }
309309}
310310
311+ #[ derive( Clone , Eq , PartialEq , Serialize , Deserialize ) ]
312+ #[ serde( tag = "type" , rename_all = "snake_case" ) ]
313+ pub enum S3EncryptionConfig {
314+ /// This is the standard AES256 SSE-C header config. Key is expected to be a
315+ /// 256bit base64-encoded string, and key_md5 is expected to be the
316+ /// base64-encoded MD5 digest of the (binary) key. Akamai gen1 buckets don't
317+ /// respect this (only the a 32 hex char key is expected).
318+ SseC { key : String , key_md5 : String } ,
319+ }
320+
321+ impl fmt:: Debug for S3EncryptionConfig {
322+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
323+ match self {
324+ S3EncryptionConfig :: SseC { key_md5, .. } => f
325+ . debug_struct ( "S3EncryptionConfig" )
326+ . field ( "type" , & "sse_c" )
327+ . field ( "key" , & "***redacted***" )
328+ . field ( "key_md5" , key_md5)
329+ . finish ( ) ,
330+ }
331+ }
332+ }
333+
311334#[ derive( Clone , Default , Eq , PartialEq , Serialize , Deserialize ) ]
312335#[ serde( deny_unknown_fields) ]
313336pub struct S3StorageConfig {
@@ -329,6 +352,8 @@ pub struct S3StorageConfig {
329352 pub disable_multi_object_delete : bool ,
330353 #[ serde( default ) ]
331354 pub disable_multipart_upload : bool ,
355+ #[ serde( default ) ]
356+ pub encryption : Option < S3EncryptionConfig > ,
332357}
333358
334359impl S3StorageConfig {
@@ -685,4 +710,29 @@ mod tests {
685710 assert_eq ! ( s3_storage_config. flavor, Some ( StorageBackendFlavor :: MinIO ) ) ;
686711 }
687712 }
713+
714+ #[ test]
715+ fn test_storage_s3_config_encryption_serde ( ) {
716+ {
717+ let s3_storage_config_yaml = r#"
718+ endpoint: http://localhost:4566
719+ encryption:
720+ type: sse_c
721+ key: test-customer-key
722+ key_md5: test-customer-key-md5
723+ "# ;
724+ let s3_storage_config: S3StorageConfig =
725+ serde_yaml:: from_str ( s3_storage_config_yaml) . unwrap ( ) ;
726+
727+ let expected_s3_config = S3StorageConfig {
728+ endpoint : Some ( "http://localhost:4566" . to_string ( ) ) ,
729+ encryption : Some ( S3EncryptionConfig :: SseC {
730+ key : "test-customer-key" . to_string ( ) ,
731+ key_md5 : "test-customer-key-md5" . to_string ( ) ,
732+ } ) ,
733+ ..Default :: default ( )
734+ } ;
735+ assert_eq ! ( s3_storage_config, expected_s3_config) ;
736+ }
737+ }
688738}
0 commit comments