Enable Server Side Encryption

OpenDAL has native support for server side encryption.

S3

NOTE: they can't be enabled at the same time.

Enable SSE-KMS with aws managed KMS key:

//! Example for initiating a s3 backend with SSE-KMS and AWS managed key.
use anyhow::Result;
use log::info;
use opendal::services::s3;
use opendal::services::s3::Builder;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder: Builder = s3::Builder::default();

    // Setup builders

    // Enable SSE-KMS with aws managed kms key
    builder.server_side_encryption_with_aws_managed_kms_key();

    let op = Operator::new(builder.build()?);
    info!("operator: {:?}", op);

    // Writing your testing code here.

    Ok(())
}

Enable SSE-KMS with customer managed KMS key:

//! Example for initiating a s3 backend with SSE-KMS and customer managed key.
use anyhow::Result;
use log::info;
use opendal::services::s3;
use opendal::services::s3::Builder;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder: Builder = s3::Builder::default();

    // Setup builders

    // Enable SSE-KMS with customer managed kms key
    builder.server_side_encryption_with_customer_managed_kms_key("aws_kms_key_id");

    let op = Operator::new(builder.build()?);
    info!("operator: {:?}", op);

    // Writing your testing code here.

    Ok(())
}

Enable SSE-S3:

//! Example for initiating a s3 backend with SSE-S3
use anyhow::Result;
use log::info;
use opendal::services::s3;
use opendal::services::s3::Builder;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder: Builder = s3::Builder::default();

    // Setup builders

    // Enable SSE-S3
    builder.server_side_encryption_with_s3_key();

    let op = Operator::new(builder.build()?);
    info!("operator: {:?}", op);

    // Writing your testing code here.

    Ok(())
}

Enable SSE-C:

//! Example for initiating a s3 backend with SSE-C.
use anyhow::Result;
use log::info;
use opendal::services::s3;
use opendal::services::s3::Builder;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder: Builder = s3::Builder::default();

    // Setup builders

    // Enable SSE-C
    builder.server_side_encryption_with_customer_key("AES256", "customer_key".as_bytes());

    let op = Operator::new(builder.build()?);
    info!("operator: {:?}", op);

    // Writing your testing code here.

    Ok(())
}