Search code examples
c#sql-server.net-coreraspberry-pi3raspbian

Connecting to SQL Server from Raspberry Pi results in Error 35 (during pre-login handshake)


I'd want to ask what may be the reason that I'm able to connect to SQL Server from Windows finely, but when I'm attempting to connect to the same server, using same connection string and server being pingable from Raspbian @ Raspberry Pi, then this error occurs:

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)


ex.InnerException {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 --- at Interop.OpenSsl.DoSslHandshake(SafeSslHandle context, Byte[] recvBuf, Int32 recvOffset, Int32 recvCount, Byte[]& sendBuf, Int32& sendCount) at System.Net.Security.SslStreamPal.HandshakeInternal(SafeFreeCredentials credential, SafeDeleteContext& context, ArraySegment`1 inputBuffer, Byte[]& outputBuffer, SslAuthenticationOptions sslAuthenticationOptions)

I'm using System.Data.SqlClient

try
{
    using (var connection = new SqlConnection(connStr))
    {
        connection.Open();
    }
}
catch (Exception ex)
{
    ...
}

.NET Core 3.1

How can I solve that? Thanks in advance


Solution

  • I installed (checked for updates) OpenSSL as Leszek Mazur suggested:

    sudo apt-get update
    sudo apt-get install openssl
    

    and then in sudo nano /etc/ssl/openssl.cnf

    I changed minimal version of TLS from 1.2:

    [system_default_sect]
    MinProtocol = TLSv1.2
    

    to 1.0:

    [system_default_sect]
    MinProtocol = TLSv1