SqlClient: ReadAsync throws open SSL error for specific table on Linux on Azure
Describe the bug
When connecting to SQL Server on Azure with Linux client we get a SQLException that has a error linked to OpenSSL. We tried both Ubuntu 18x and Ubuntu 19x and same error.
Oddly enough, this error happens on a very specific table. Also same error with older client System.Data.SqlClient This is on net core preview 7
Exception message:
Stack trace:
---> System.Data.SqlClient.SqlException (0x80131904): A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 35 - An internal exception was caught)
---> System.IO.IOException: The decryption operation failed, see inner exception.
---> Interop+OpenSsl+SslException: Decrypt failed with OpenSSL error - SSL_ERROR_SSL.
---> Interop+Crypto+OpenSslCryptographicException: error:1408F10B:SSL routines:ssl3_get_record:wrong version number
--- End of inner exception stack trace ---
at Interop.OpenSsl.Decrypt(SafeSslHandle context, Byte[] outBuffer, Int32 offset, Int32 count, SslErrorCode& errorCode)
at System.Net.Security.SslStreamPal.EncryptDecryptHelper(SafeDeleteContext securityContext, ReadOnlyMemory`1 input, Int32 offset, Int32 size, Boolean encrypt, Byte[]& output, Int32& resultSize)
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.ReadAsyncInternal[TReadAdapter](TReadAdapter adapter, Memory`1 buffer)
at System.Data.SqlClient.SNI.SNIPacket.<ReadFromStreamAsync>g__ReadFromStreamAsync|27_0(SNIPacket packet, SNIAsyncCallback cb, ValueTask`1 valueTask)
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParserStateObject.ReadAsyncCallbackCaptureException(TaskCompletionSource`1 source)
--- End of stack trace from previous location where exception was thrown ---
at Apption.DBConnectors.SQLServer.SQLServerTableMetadata.ReadTable(SQLDatabase database, SQLTable table, ITargetBlock`1 target)
Expected behavior
SQL Clients reads data correctly from source data.
Further technical details
Microsoft.Data.SqlClient version: 1.0.19189.1 SQL Server version: Azure SQL Server Operating system: Ubuntu 18.04 docker container
Additional context Error seems to be related to SSL version https://stackoverflow.com/questions/29627991/1408f10bssl-routinesssl3-get-recordwrong-version-number-call-on-indy
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 22 (20 by maintainers)
Commits related to this issue
- Fix bad usage of ArrayPool in TdsParserStateObject (#171) Apply https://github.com/dotnet/corefx/pull/37270 to M.D.SqlClient. Fixes #145. — committed to dotnet/SqlClient by rmja 5 years ago
- Fix bad usage of ArrayPool in TdsParserStateObject (#171) Apply https://github.com/dotnet/corefx/pull/37270 to M.D.SqlClient. Fixes #145. — committed to yukiwongky/SqlClient by rmja 5 years ago
Well I’m sorry I broke it in the first place. It’s been a bad day for my quality of my work.
Sorry for my impatience to get this fix out in a hurry, but I really believe that it is urgent now where ef core relies on M.D.SqlClient. It’s release is imminent and it will have a dependency with this fatal issue. I really hope that a patch release will be out asap.
I created https://github.com/aspnet/EntityFrameworkCore/issues/17592 to track the update of the reference if this gets a patch release before the ef core release
Cc @cheenamalhotra @David-Engel @Divega