docker 连接老版本的sqlserver ssl错误

报错提示

SSL出错,因为升级了驱动,字符串增加Encrypt=True;TrustServerCertificate=True;即可。详细错误: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) English Message : 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)

ssl

dockerfile需要增加如下命令,注意增加的位置需要在

RUN sed -i 's|\[openssl_init\]|&\nssl_conf = ssl_configuration\n[ssl_configuration]\nsystem_default = tls_system_default\n[tls_system_default]\nMinProtocol = TLSv1\nCipherString = DEFAULT@SECLEVEL=0|' /etc/ssl/openssl.cnf

示例dockefile

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime

RUN sed -i 's|\[openssl_init\]|&\nssl_conf = ssl_configuration\n[ssl_configuration]\nsystem_default = tls_system_default\n[tls_system_default]\nMinProtocol = TLSv1\nCipherString = DEFAULT@SECLEVEL=0|' /etc/ssl/openssl.cnf


USER $APP_UID
WORKDIR /app
EXPOSE 8080

ARG BUILD_CONFIGURATION=Release
COPY . .
ARG BUILD_CONFIGURATION=Release


ENTRYPOINT ["dotnet", "Test.dll"]

参考

posted @ 2026-01-13 17:00  Hey,Coder!  阅读(4)  评论(0)    收藏  举报