简体   繁体   English

无法连接 docker 容器内的 SQLServer

[英]Unable to connect SQLServer inside docker container

I'm creating a container, which has an .net core application, based on the official microsoft image.我正在创建一个容器,它有一个 .net 核心应用程序,基于官方的 microsoft 图像。

I'm getting the following error when the application try to connect to SQL server, it only happens inside the container: A connection was successfully established with the server, but then an error occurred during the pre-login handshake.当应用程序尝试连接到 SQL 服务器时,我收到以下错误,它只发生在容器内:与服务器成功建立连接,但在登录前握手期间发生错误。 (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed) (提供者:SSL 提供者,错误:31 - 加密(ssl/tls)握手失败)

My application uses the following packages for communcicate with sqlserver:我的应用程序使用以下包与 sqlserver 通信:

  • System.Data.SqlClient 4.8.2 System.Data.SqlClient 4.8.2
  • Dapper 2.0.78小巧玲珑 2.0.78

My connectionstring looks like this:我的连接字符串如下所示:

Data Source=xxx.xxx.xxx.xxx;Initial Catalog=XXXXXXXX;User ID=XXXXX;Password=XXXX;MultipleActiveResultSets=True;Connect Timeout=60;TrustServerCertificate=true

My docker Version isthe latest avaliable at the time: "Docker version 20.10.2, build 2291f61" is running on windows and this is how i'm creating the docher image:我的 docker 版本是当时可用的最新版本:“Docker 版本 20.10.2,构建 2291f61”在 windows 上运行,这就是我创建 docher 映像的方式:

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build-env
WORKDIR /prj

COPY . .
RUN dotnet publish myapp.csproj -o /app 

FROM mcr.microsoft.com/dotnet/aspnet:3.1
WORKDIR /app

RUN update-ca-certificates --fresh

COPY --from=build-env /app .
ENTRYPOINT ["dotnet", "myapp.dll"]

I've been googling for some time now, and I didn't found a solution that works for me, can some one help?我已经在谷歌上搜索了一段时间,但没有找到适合我的解决方案,有人可以帮忙吗?

This error typically occurs in client environments like docker image containers, Unix clients, or Windows clients where TLS 1.2 is the minimum supported TLS protocol. 此错误通常发生在客户端环境中,例如 docker 映像容器、Unix 客户端或 Windows 客户端,其中 TLS 1.2 是支持的最低 TLS 协议。

Configure TLS/SSL settings in the docker image/client environment to connect with TLS 1.0.在 docker 映像/客户端环境中配置 TLS/SSL 设置以连接 TLS 1.0。

MinProtocol = TLSv1 
CipherString = DEFAULT@SECLEVEL=1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM