Skip to content

Commit 82353f8

Browse files
author
Javad
authored
Fix | Addressing failure on providing correct error message when symmetric key decryption fails using Always Encrypted. (#1948)
1 parent 23ca8e7 commit 82353f8

File tree

2 files changed

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

2 files changed

+14
-0
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6080,6 +6080,13 @@ internal bool TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, T
60806080
}
60816081
catch (Exception e)
60826082
{
6083+
if (stateObj is not null)
6084+
{
6085+
// call to decrypt column keys has failed. The data wont be decrypted.
6086+
// Not setting the value to false, forces the driver to look for column value.
6087+
// Packet received from Key Vault will throws invalid token header.
6088+
stateObj.HasPendingData = false;
6089+
}
60836090
throw SQL.ColumnDecryptionFailed(columnName, null, e);
60846091
}
60856092
}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6884,6 +6884,13 @@ internal bool TryReadSqlValue(SqlBuffer value,
68846884
}
68856885
catch (Exception e)
68866886
{
6887+
if (stateObj is not null)
6888+
{
6889+
// call to decrypt column keys has failed. The data wont be decrypted.
6890+
// Not setting the value to false, forces the driver to look for column value.
6891+
// Packet received from Key Vault will throws invalid token header.
6892+
stateObj._pendingData = false;
6893+
}
68876894
throw SQL.ColumnDecryptionFailed(columnName, null, e);
68886895
}
68896896
}

0 commit comments

Comments
 (0)