4

In our application we are using linux based container which access SQL server installed on VM. Everything works fine in local environment outside the container, But when I ran the app in local container we are getting the below error.

"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"

appsetings.json
"ConnectionStrings": {
    
    "DbConnection": "Server=tcp:vmname\\sqlservername,49763;Database=dbname;User ID=username_Users;Password=pwd;MultipleActiveResultSets=true;Integrated Security=False;"
  }

Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
.......

Any inputs will be appreciated

3
  • So the real question is how to connect to a named SQL Server instance from Linux using ADO.NET? Is the server configured to use SSL? Commented Jul 29, 2021 at 17:21
  • @PanagiotisKanavos yes, it is configured to use SSL and I have configured root CA in the linux image Commented Jul 29, 2021 at 17:28
  • and we are using Entityframework Commented Jul 29, 2021 at 18:18

2 Answers 2

2

Please add ;TrustServerCertificate=true to your connection string.

Sign up to request clarification or add additional context in comments.

4 Comments

Tried that , same issue. Thanks for helping out
@SijoX did you solve this? I am facing the same error. Thanks.
@John see SijoX's answer above. Apparently, upgrading TLS 1.2 resolved the issue.
@John yes , upgrading TLS version solved the issue
1

The issue was related to TLS version of the SQL server, enabling TLS 1.2 resolved the issue

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.