Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ServiceURL option for KMS client #45

Merged
merged 5 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/AmazonS3CryptoConfigurationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Amazon.KeyManagementService;
using Amazon.S3;

namespace Amazon.Extensions.S3.Encryption
Expand All @@ -41,5 +42,13 @@ public AmazonS3CryptoConfigurationBase()
// By default, store encryption info in metadata
StorageMode = CryptoStorageMode.ObjectMetadata;
}
/// <summary>
/// Configuration for the AWS Key Management Service client that will be used internally when encrypting S3 objects with KMS keys.
/// </summary>
/// <remarks>
/// If not specified here, the internal KMS client will inherit the region, timeout, and proxy configuration from the S3 configuration
/// </remarks>
public AmazonKeyManagementServiceConfig KmsConfig { get; set; }
bdurrani marked this conversation as resolved.
Show resolved Hide resolved

}
}
28 changes: 18 additions & 10 deletions src/AmazonS3EncryptionClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,27 @@ internal IAmazonKeyManagementService KMSClient
{
if (kmsClient == null)
{
var kmsConfig = new AmazonKeyManagementServiceConfig
if (this.S3CryptoConfig.KmsConfig != null)
{
RegionEndpoint = this.Config.RegionEndpoint,
Timeout = this.Config.Timeout
};

var proxySettings = this.Config.GetWebProxy();
if(proxySettings != null)
kmsClient = new AmazonKeyManagementServiceClient(Credentials,
this.S3CryptoConfig.KmsConfig);
}
else
{
kmsConfig.SetWebProxy(proxySettings);
var kmsConfig = new AmazonKeyManagementServiceConfig
{
RegionEndpoint = this.Config.RegionEndpoint,
Timeout = this.Config.Timeout
};

var proxySettings = this.Config.GetWebProxy();
if(proxySettings != null)
{
kmsConfig.SetWebProxy(proxySettings);
}

kmsClient = new AmazonKeyManagementServiceClient(Credentials, kmsConfig);
}

kmsClient = new AmazonKeyManagementServiceClient(Credentials, kmsConfig);
}
}
}
Expand Down