天天看點

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)

出現問題的 asp.net core 程式是跑在容器中的,容器鏡像用的是

mcr.microsoft.com/dotnet/core/aspnet:3.0

運作容器内的 openssl 指令發現 openssl 的版本比較高

1.進入容器

docker exec -it [容器ID] bas         h
           

2.檢視容器openssl版本

openssl version

OpenSSL 1.1.1d  10 Sep 2019

      

3.檢視 openssl.cnf 配置檔案

cat /etc/ssl/openssl.cnf      
[system_default_sect]
MinProtocol = TLSv1.1
CipherString = DEFAULT@SECLEVEL=2           

 發現允許的 ssl 最低版本是

TLSv1.2

,而程式所使用的 SQL Server 資料庫版本比較低不支援

TLSv1.2

,修改為

TLSv1.0

後問題解決

4.修改方法:在 Dockerfile 中添加下面的指令

RUN sed -i \'s/TLSv1.2/TLSv1.0/g\' /etc/ssl/openssl.cnf      

參考資料:https://q.cnblogs.com/q/115080/