Skip to content

Commit

Permalink
Code changes to fix encryption package build failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
kundadebdatta committed Jun 20, 2023
1 parent 949ce0d commit fd077df
Show file tree
Hide file tree
Showing 14 changed files with 1,751 additions and 3,830 deletions.
41 changes: 0 additions & 41 deletions Microsoft.Azure.Cosmos.Encryption/src/EncryptionContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -837,47 +837,6 @@ internal async Task ThrowIfRequestNeedsARetryPostPolicyRefreshAsync(
}
}

/// <summary>
/// This function handles the scenario where a container is deleted(say from different Client) and recreated with same Id but with different client encryption policy.
/// The idea is to have the container Rid cached and sent out as part of RequestOptions with Container Rid set in "x-ms-cosmos-intended-collection-rid" header.
/// So when the container being referenced here gets recreated we would end up with a stale encryption settings and container Rid and this would result in BadRequest( and a substatus 1024).
/// This would allow us to refresh the encryption settings and Container Rid, on the premise that the container recreated could possibly be configured with a new encryption policy.
/// </summary>
/// <param name="responseMessage"> Response message to validate. </param>
/// <param name="encryptionSettings"> Current cached encryption settings to refresh if required. </param>
/// <param name="encryptionDiagnosticsContext"> Encryption specific diagnostics. </param>
/// <param name="cancellationToken"> Cancellation token. </param>
internal async Task ThrowIfRequestNeedsARetryPostPolicyRefreshAsync(
ResponseMessage responseMessage,
EncryptionSettings encryptionSettings,
EncryptionDiagnosticsContext encryptionDiagnosticsContext,
CancellationToken cancellationToken)
{
if (responseMessage.StatusCode == HttpStatusCode.BadRequest &&
string.Equals(responseMessage.Headers.Get(Constants.SubStatusHeader), Constants.IncorrectContainerRidSubStatus))
{
// get the latest encryption settings.
await this.GetOrUpdateEncryptionSettingsFromCacheAsync(
obsoleteEncryptionSettings: encryptionSettings,
cancellationToken: cancellationToken);

if (encryptionDiagnosticsContext == null)
{
throw new ArgumentNullException(nameof(encryptionDiagnosticsContext));
}

encryptionDiagnosticsContext.AddEncryptionDiagnosticsToResponseMessage(responseMessage);

throw new EncryptionCosmosException(
"Operation has failed due to a possible mismatch in Client Encryption Policy configured on the container. Retrying may fix the issue. Please refer to https://aka.ms/CosmosClientEncryption for more details. " + responseMessage.ErrorMessage,
HttpStatusCode.BadRequest,
int.Parse(Constants.IncorrectContainerRidSubStatus),
responseMessage.Headers.ActivityId,
responseMessage.Headers.RequestCharge,
responseMessage.Diagnostics);
}
}

internal async Task<List<PatchOperation>> EncryptPatchOperationsAsync(
IReadOnlyList<PatchOperation> patchOperations,
EncryptionSettings encryptionSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static async Task<ClientEncryptionKeyResponse> CreateClientEncryptionKeyA

ClientEncryptionKeyProperties clientEncryptionKeyProperties = new ClientEncryptionKeyProperties(
clientEncryptionKeyId,
dataEncryptionKeyAlgorithm,
encryptionAlgorithm,
wrappedDataEncryptionKey,
encryptionKeyWrapMetadata);

Expand Down
12 changes: 0 additions & 12 deletions Microsoft.Azure.Cosmos.Encryption/src/EncryptionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,10 @@
namespace Microsoft.Azure.Cosmos.Encryption
{
/// <summary>
<<<<<<<< HEAD:Microsoft.Azure.Cosmos.Encryption/src/MdeSupport/EncryptionType.cs
/// Represents the encryption algorithms supported for data encryption.
/// </summary>
/// <summary>
/// The type of data encryption.
/// </summary>
/// <remarks>
/// The two encryption types are Deterministic and Randomized.
/// Deterministic encryption always generates the same encrypted value for any given plain text value.
/// Randomized encryption uses a method that encrypts data in a less predictable manner. Randomized encryption is more secure.
========
/// Encryption types supported for data encryption.
/// </summary>
/// <remarks>
/// See <see href="https://aka.ms/CosmosClientEncryption">client-side encryption documentation</see> for more details.
>>>>>>>> master:Microsoft.Azure.Cosmos.Encryption/src/EncryptionType.cs
/// </remarks>
public static class EncryptionType
{
Expand Down
Loading

0 comments on commit fd077df

Please sign in to comment.