Skip to content

Commit

Permalink
Fix | Addressing failure on providing correct error message when symm…
Browse files Browse the repository at this point in the history
…etric key decryption fails using Always Encrypted. (dotnet#1948)
  • Loading branch information
JRahnama authored and lcheunglci committed Mar 30, 2023
1 parent 4031ef9 commit 466721f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Expand Up @@ -6024,6 +6024,13 @@ internal bool TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, T
}
catch (Exception e)
{
if (stateObj is not null)
{
// call to decrypt column keys has failed. The data wont be decrypted.
// Not setting the value to false, forces the driver to look for column value.
// Packet received from Key Vault will throws invalid token header.
stateObj.HasPendingData = false;
}
throw SQL.ColumnDecryptionFailed(columnName, null, e);
}
}
Expand Down
Expand Up @@ -6828,6 +6828,13 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
}
catch (Exception e)
{
if (stateObj is not null)
{
// call to decrypt column keys has failed. The data wont be decrypted.
// Not setting the value to false, forces the driver to look for column value.
// Packet received from Key Vault will throws invalid token header.
stateObj._pendingData = false;
}
throw SQL.ColumnDecryptionFailed(columnName, null, e);
}
}
Expand Down

0 comments on commit 466721f

Please sign in to comment.