Skip to content

Commit 9bd90e6

Browse files
authored
[5.0.2] Fix | Addressing failure on providing correct error message when symmetric key decryption fails using Always Encrypted. (#1977)
1 parent bf93b16 commit 9bd90e6

File tree

2 files changed

+14
-0
lines changed
  • src/Microsoft.Data.SqlClient

2 files changed

+14
-0
lines changed

Diff for: src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs

+7
Original file line numberDiff line numberDiff line change
@@ -6024,6 +6024,13 @@ internal bool TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, T
60246024
}
60256025
catch (Exception e)
60266026
{
6027+
if (stateObj is not null)
6028+
{
6029+
// call to decrypt column keys has failed. The data wont be decrypted.
6030+
// Not setting the value to false, forces the driver to look for column value.
6031+
// Packet received from Key Vault will throws invalid token header.
6032+
stateObj.HasPendingData = false;
6033+
}
60276034
throw SQL.ColumnDecryptionFailed(columnName, null, e);
60286035
}
60296036
}

Diff for: src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs

+7
Original file line numberDiff line numberDiff line change
@@ -6828,6 +6828,13 @@ internal bool TryReadSqlValue(SqlBuffer value,
68286828
}
68296829
catch (Exception e)
68306830
{
6831+
if (stateObj is not null)
6832+
{
6833+
// call to decrypt column keys has failed. The data wont be decrypted.
6834+
// Not setting the value to false, forces the driver to look for column value.
6835+
// Packet received from Key Vault will throws invalid token header.
6836+
stateObj._pendingData = false;
6837+
}
68316838
throw SQL.ColumnDecryptionFailed(columnName, null, e);
68326839
}
68336840
}

0 commit comments

Comments
 (0)