错误信息
SSL routines:tls_setup_handshake:no protocols available
也可能输出为
- error:0A0000BF:SSL routines::no protocols available
openssl CLI(3.0 和 3.5)输出“error:0A0000BF:SSL routines:tls_setup_handshake:no protocols available”;格式化错误时不带函数名的应用程序显示为“error:0A0000BF:SSL routines::no protocols available”。
OpenSSL (client or server side) — SSL_R_NO_PROTOCOLS_AVAILABLE before the handshake starts
含义
OpenSSL 连握手都拒绝开始,因为应用所有限制之后,已经没有可以提供的协议版本了。通常是应用程序要求使用 TLS 1.0 或 1.1,而 OpenSSL 的安全级别(当前发行版默认为 2)禁止使用它们;或者配置的最低版本高于最高版本。没有任何数据发送到服务器。
原因
强制使用 TLS 1.0/1.1,而安全级别禁止使用
常见从 OpenSSL 3.0 起,安全级别 1 及以上会禁用 TLS 1.0 和 1.1;各发行版默认使用级别 2。因此,为了兼容旧设备而硬编码为 TLS 1.0 的客户端就没有任何版本可提供。
最低版本高于最高版本
偶见最低版本设为 TLS 1.3、最高版本却是 TLS 1.2 的配置(通常是两处不同的设置相互叠加造成的),会留下一个空的版本范围。
系统级加密策略覆盖了应用程序的设置
偶见RHEL 和 Fedora 的加密策略(DEFAULT、FUTURE)以及 Debian 的 openssl.cnf,会为这台机器上的每个 OpenSSL 应用程序设置 MinProtocol 和安全级别。
修复方法
- 1.
找出施加限制的设置
在 openssl.cnf 和系统加密策略中查找 MinProtocol、MaxProtocol 以及 CipherString 中的 @SECLEVEL 值。
bash openssl version -d # where openssl.cnf lives grep -nE 'MinProtocol|MaxProtocol|CipherString' /usr/lib/ssl/openssl.cnf /etc/ssl/openssl.cnf 2>/dev/null update-crypto-policies --show 2>/dev/null # RHEL/Fedora system policy - 2.
旧设备:仅对单条命令降低安全级别
在密码套件字符串中加上 @SECLEVEL=0,只会为那一次调用重新启用 TLS 1.0/1.1。不要把这类例外写进系统级配置,也不要在不受信任的网络上使用。
bash # For a one-off test against a legacy device: lower the security level for this command only echo | openssl s_client -connect legacy.example.com:443 -tls1 -cipher 'DEFAULT:@SECLEVEL=0' - 3.
使用自洽的版本范围
确保最低版本不高于最高版本;如今常用的范围是 TLS 1.2 到 TLS 1.3。
ini # openssl.cnf (system_default_sect): a consistent range MinProtocol = TLSv1.2 MaxProtocol = TLSv1.3