Skip to content

Commit

Permalink
[5.1.1] Fix | Addressing failure on providing correct error message w…
Browse files Browse the repository at this point in the history
…hen symmetric key decryption fails using Always Encrypted. (#1968)
  • Loading branch information
lcheunglci authored Mar 27, 2023
1 parent 0156df2 commit 20e1535
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -6884,6 +6884,13 @@ internal bool TryReadSqlValue(SqlBuffer value,
}
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 20e1535

Please sign in to comment.