Technology Sharing

  • 首页
  • 资料分享
  • 在线工具
    • 随机密码生成器
  • 介绍
  • RSS
  • privacy
  • 云产品推广
    • 腾讯云
    • 阿里云
Share IT knowledge
  1. 首页
  2. linux
  3. 正文

Nginx: SSL_do_handshake() failed… and that’s OK!

2022年8月2日 236点热度 0人点赞 0条评论

背景:前几天查看网站错误日志,发现有以下错误

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
2022/08/01 22:35:21 [crit] 388149#388149: *64975 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking, client: 154.89.5.125, server: 0.0.0.0:443
2022/08/01 22:35:21 [crit] 388149#388149: *64975 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking, client: 154.89.5.125, server: 0.0.0.0:443
2022/08/01 22:35:21 [crit] 388149#388149: *64975 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking, client: 154.89.5.125, server: 0.0.0.0:443

从报错日志中不难看出跟ssl相关,那么就可以直接定位到nginx配置中ssl相关参数,进一步确认跟ssl_protocols相关。

本质上,此错误可能意味着以下两种情况之一:

  • 客户端使用的是非常旧的设备,因此它无法使用您nginx定义的ssl协议
  • 客户端故意尝试使用较旧的不安全SSL协议

无论哪种情况,您都不应该担心,尽管您可能想降低 Web 服务器的安全性以支持旧协议,例如 TLS v1.0 和 TLS v1.1 但要知道这是一个坏主意。为了一些过时的客户,会影响较多用户的安全。

解决办法如下:

情况一:

  • 在Ubuntu 20.04 中, OpenSSL升级到了1.1.1f, TLS默认最低支持1.2。
  • 虽然nginx中配置支持ssl_protocols TLSv1 TLSv1.1 TLSv1.2 ,但是当请求为TLSv1 TLSv1.1 时却不生效,因为默认openssl最低支持TLSv1.2


修改openssl配置文件,设置支持最低为TLSv1

vim /etc/ssl/openssl.cnf
vim /etc/ssl/openssl.cnf

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#以下配置在顶部添加
openssl_conf = default_conf
#以下配置在顶部添加 openssl_conf = default_conf
#以下配置在顶部添加
openssl_conf = default_conf              

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#以下配置在底部添加
[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT@SECLEVEL=1
#以下配置在底部添加 [default_conf] ssl_conf = ssl_sect [ssl_sect] system_default = system_default_sect [system_default_sect] MinProtocol = TLSv1 CipherString = DEFAULT@SECLEVEL=1
#以下配置在底部添加
[default_conf]
ssl_conf = ssl_sect

[ssl_sect]
system_default = system_default_sect

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

情况二:

  • 在Ubuntu 22.04 中, OpenSSL升级到了3.0.x, TLS默认最低支持1.2。
  • 虽然nginx中配置支持ssl_protocols TLSv1 TLSv1.1 TLSv1.2 ,但是当请求为TLSv1 TLSv1.1 时却不生效,因为默认openssl最低支持TLSv1.2 3.下图是通过抓包得到的信息

修改openssl配置文件,设置支持最低为TLSv1

vim /etc/ssl/openssl.cnf
vim /etc/ssl/openssl.cnf

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[system_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT:@SECLEVEL=0
[system_default_sect] MinProtocol = TLSv1 CipherString = DEFAULT:@SECLEVEL=0
[system_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT:@SECLEVEL=0

重启服务器

reboot
reboot

测试

nmap --script ssl-enum-ciphers -p 443 127.0.0.1
nmap --script ssl-enum-ciphers -p 443 127.0.0.1

打赏微海报分享
标签: 暂无
最后更新:2024年1月12日

nico

Linux运维工程师 软考网络工程师 && 软考信息安全工程师

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

nico

Linux运维工程师
软考网络工程师 && 软考信息安全工程师

最新 热点 随机
最新 热点 随机
linux部署JDK环境 [Solved] MariaDB import issue: Error at line 1: Unknown command '\-'. Could not retrieve mirrorlist http://mirrorlist.centos.org/ CentOS 7 Kubernetes如何删除卡在“Terminating”状态的命名空间 解决GitLab Runner签名无效 如何禁用 Ubuntu "Daemons using outdated libraries" 弹出窗口
linux systemd 多种启动方案 修改wordpress后台登录地址 查看MySQL用户授予的权限 部署SaltStack [nginx]proxy_pass 失败时回退到 try_files Ubuntu 和 Debian 中使用apt/apt-get单独升级某个软件包
最近评论
woodcockkienzlelsj8o9+73s48g9rr3m0@gmail.com 发布于 11 个月前(07月17日) necessitatibus corporis et odit nam quo harum et c...
RonaldG 发布于 11 个月前(07月07日) Very interesting topic, thank you for putting up.&...
小黑 发布于 1 年前(12月28日) 不错
nico 发布于 2 年前(02月09日) 嘻嘻嘻!!!
Bruse 发布于 2 年前(02月09日) 我来啦!!!
nico 发布于 3 年前(12月10日) 方便查询
Justin 发布于 3 年前(12月10日) 写的很好,谢谢分享!我 Mark 一下~
nico 发布于 3 年前(11月18日) 主题的原因吧
Justin 发布于 3 年前(09月22日) 这篇文章的质量很高呀!写得很详细~ 话说你的文章是隐藏了发布时间吗?
Justin 发布于 3 年前(08月27日) 好家伙,这标题乍一看还以为你打算进军英文技术写作领域了🤓

COPYRIGHT © 2023 Technology Sharing. ALL RIGHTS RESERVED.

备案图标 皖公网安备34132402000202 皖ICP备2023004851号-1