Skip to content

Commit 20e1535

Browse files
authored
[5.1.1] Fix | Addressing failure on providing correct error message when symmetric key decryption fails using Always Encrypted. (#1968)
1 parent 0156df2 commit 20e1535

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

+7
Original file line numberDiff line numberDiff line change
@@ -6070,6 +6070,13 @@ internal bool TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, int length, T
60706070
}
60716071
catch (Exception e)
60726072
{
6073+
if (stateObj is not null)
6074+
{
6075+
// call to decrypt column keys has failed. The data wont be decrypted.
6076+
// Not setting the value to false, forces the driver to look for column value.
6077+
// Packet received from Key Vault will throws invalid token header.
6078+
stateObj.HasPendingData = false;
6079+
}
60736080
throw SQL.ColumnDecryptionFailed(columnName, null, e);
60746081
}
60756082
}

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

+7
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)