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 24, 2023
1 parent 0156df2 commit 624fb26
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Expand Up @@ -6070,6 +6070,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 @@ -6884,6 +6884,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 624fb26

Please sign in to comment.