ruby/example_code/s3/s3-ruby-example-get-cspk-item.rb
def run_me
  bucket_name = 'doc-example-bucket'
  object_key = 'my-file.txt'
  region = 'us-west-2'
  private_key_file = 'my-private-key.pem'
  private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file))

  # When initializing this Amazon S3 encryption client, note:
  # - For key_wrap_schema, use rsa_oaep_sha1 for asymmetric keys.
  # - For security_profile, for reading or decrypting objects encrypted
  #     by the v1 encryption client, use :v2_and_legacy instead.
  s3_encryption_client = Aws::S3::EncryptionV2::Client.new(
    encryption_key: private_key,
    key_wrap_schema: :rsa_oaep_sha1,
    content_encryption_schema: :aes_gcm_no_padding,
    security_profile: :v2,
    region: region
  )
  puts "The content of '#{object_key}' in bucket '#{bucket_name}' is:"
  puts download_object_with_private_key_encryption(
    s3_encryption_client,
    bucket_name,
    object_key
  )
end
# Full example call:
# Prerequisites: the same RSA key pair you originally used to encrypt the object.
# Replace us-west-2 with the AWS Region you're using for Amazon S3.

Full example call:
Prerequisites: the same RSA key pair you originally used to encrypt the object.
Replace us-west-2 with the AWS Region you're using for Amazon S3.
Full example call : Prerequisites : the same RSA key pair you originally used to encrypt the object . Replace us - west - 2 with the AWS Region you ' re using for Amazon S3 .
def run_me
  bucket_name = 'doc-example-bucket'
  object_key = 'my-file.txt'
  region = 'us-west-2'
  private_key_file = 'my-private-key.pem'
  private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file))
  s3_encryption_client = Aws::S3::EncryptionV2::Client.new(
    encryption_key: private_key,
    key_wrap_schema: :rsa_oaep_sha1,
    content_encryption_schema: :aes_gcm_no_padding,
    security_profile: :v2,
    region: region
  )
  puts "The content of '#{object_key}' in bucket '#{bucket_name}' is:"
  puts download_object_with_private_key_encryption(
    s3_encryption_client,
    bucket_name,
    object_key
  )
end
def run_me bucket_name = 'doc-example-bucket' object_key = 'my-file.txt' region = 'us-west-2' private_key_file = 'my-private-key.pem' private_key = OpenSSL :: PKey :: RSA . new ( File . read ( private_key_file ) ) s3_encryption_client = Aws :: S3 :: EncryptionV2 :: Client . new ( encryption_key : private_key , key_wrap_schema : :rsa_oaep_sha1 , content_encryption_schema : :aes_gcm_no_padding , security_profile : :v2 , region : region ) puts "The content of '#{object_key}' in bucket '#{bucket_name}' is:" puts download_object_with_private_key_encryption ( s3_encryption_client , bucket_name , object_key ) end
Full example call:
Prerequisites: the same RSA key pair you originally used to encrypt the object.
Full example call : Prerequisites : the same RSA key pair you originally used to encrypt the object .
# When initializing this Amazon S3 encryption client, note:
 # - For key_wrap_schema, use rsa_oaep_sha1 for asymmetric keys.
 # - For security_profile, for reading or decrypting objects encrypted
 #     by the v1 encryption client, use :v2_and_legacy instead.
