I have a .NET Core console application that connects to a SQL Server database. The application works fine on Windows, but I'm encountering an SSL/TLS handshake failure when running it on an Ubuntu 22.04 LTS VM .
class Program{ static void Main() { var connectionString = "Data Source=DB*****;Initial Catalog=efdfdApi;User Id=useridd;Password=*****;Connect Timeout=30;Encrypt=false;TrustServerCertificate=true;Application Intent=ReadWrite;MultiSubnetFailover=false"; try { using (var connection = new SqlConnection(connectionString)) { connection.Open(); Console.WriteLine("Connection successful!"); } } catch (Exception ex) { Console.WriteLine($"Connection failed: {ex.Message}"); } }}
Issue: When I execute
dotnet TestConnection.dll
on my Ubuntu VM, I get the following error:Connection failed: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed)
Additional Information:
I've verified that the connection string is correct and works on Windows.
I suspect there might be SSL/TLS configuration differences between Windows and Ubuntu that I need to address.
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" />
I used these
sudo apt-get update
sudo apt-get install -y libssl-dev ca-certificates libkrb5-dev
sudo apt-get install openssl
sudo apt-get update
sudo apt-get install -y libssl-dev ca-certificates libkrb5-dev
sudo apt-get install ca-certificates
What steps should I take to troubleshoot and resolve this SSL/TLS handshake failure when connecting to SQL Server from .NET Core on Ubuntu?