如果 openssl 3 配置文件中的 CipherString = DEFAULT@SECLEVEL=1 不起作用怎么办

问题描述 投票:0回答:1

我正在尝试将 Docker 中托管的 .NET 7 应用程序更新到 .NET 8

之前我使用了带有 openssl 1.1.1 的 Docker 映像 (mcr.microsoft.com/dotnet/aspnet:7.0)。

在 /etc/ssl/openssl.cnf 中,我对 mssql 连接使用了以下解决方法:

[default_conf]
ssl_conf = ssl_sect

[ssl_sect]
system_default = system_default_sect

[system_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT@SECLEVEL=1

但是后来我更新了 dockerfile 的基本映像。 (至 mcr.microsoft.com/dotnet/aspnet:8.0)。我发现,openssl 在新容器中已更新到 3.0.11。

我的解决方法不再有效。配置发生了一些变化,但我不知道它到底是什么:

https://www.openssl.org/docs/man3.1/man5/config.html
https://www.openssl.org/docs/man1.1.1/man5/config.html

有人可以解释一下,如何使用 openssl 默认设置 tls1 吗?

这是原始问题的堆栈跟踪:

Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): 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)
  ---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.
    at System.Net.Security.SslStream.ReceiveHandshakeFrameAsync[TIOAdapter](CancellationToken cancellationToken)
    at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken)
    at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions)
    at Microsoft.Data.SqlClient.SNI.SNITCPHandle.EnableSsl(UInt32 options)
sql-server docker entity-framework asp.net-core openssl
1个回答
0
投票

我找到了解决方案。几乎相同的解决方法,但对于 openssl 3.0.11:

RUN sed -i '/\[openssl_init\]/a ssl_conf = ssl_configuration' /etc/ssl/openssl.cnf

RUN echo "\n[ssl_configuration]" >> /etc/ssl/openssl.cnf \
    && echo "system_default = tls_system_default" >> /etc/ssl/openssl.cnf

RUN echo "\n[tls_system_default]" >> /etc/ssl/openssl.cnf \
    && echo "MinProtocol = TLSv1" >> /etc/ssl/openssl.cnf \
    && echo "CipherString = DEFAULT@SECLEVEL=0" >> /etc/ssl/openssl.cnf

这意味着 DEFAULT@SECLEVEL=1 切换为 0 并且部分被稍微重组。应用脚本后,需要重新检查配置文件的内容:

[openssl_init]
ssl_conf = ssl_configuration    # Section must be registered here

# I adding new section in the end of the file:

[ssl_configuration]
system_default = tls_system_default

[tls_system_default]
MinProtocol = TLSv1
CipherString = DEFAULT@SECLEVEL=0

来源:https://www.openssl.org/docs/man3.0/man7/migration_guide.htmlhttps://www.openssl.org/docs/man3.0/man5/config.html

TLS 中基于 SHA1 和 MD5 的签名的安全强度已降低。 这会导致 SSL 3、TLS 1.0、TLS 1.1 和 DTLS 1.0 不再在默认安全级别 1 下工作,而是需要安全级别 0。

© www.soinside.com 2019 - 2024. All rights reserved.