Search code examples
c#.netsql-serverlinuxsystem.data.sqlclient

ASP.NET Core. System.Data.SqlClient.SqlException - SSL_ERROR_SSL


My specs: PC with MS SQL Server 2008 (SP4) - 10.0.6535.0; PC on Linux (Debian GNU/Linux) with my ASP.NET Core 5.0 application (for sql - System.Data.SqlClient). I can't make successful sql request to the remote SQL server.

Logger:

[2022-08-24 13:41:55.3955] [ERROR] [GPNA.MyApplication.Infrastructure.Modules.DataLoaderModule] System.AggregateException: One or more errors occurred. (A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught))
 ---> System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)
 ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
 ---> Interop+OpenSsl+SslException: SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL.
 ---> Interop+Crypto+OpenSslCryptographicException: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol
   --- End of inner exception stack trace ---

What is wrong with SSL? – I switched off SSL in Visual Studio. And tryied different variations in SqlConnectionString, played with linux config openssl.cnf. Is the problem caused by my App, Linux or SQL Server?

SqlConnectionString like:

Data Source=10.20.17.76;Initial Catalog=Runtime; User ID=sa; Password=******; Connect Timeout=300; TrustServerCertificate=True; Encrypt = False

Thanks!

Update: I tried to launch my app on remote PC Windows Server 2008, which is connect to PC with MS SQL Server, and it works! On Linux - don't. So, the problem not in the MS SQL Server.


Solution

  • My mistake: I should have written "TLSv1", but i did "TLSv1.0", distrib based on Debian.

    openssl.cnf
    [system_default_sect]
    MinProtocol = TLSv1
    CipherString = DEFAULT@SECLEVEL=1