Chrome, Edge and other Chromium browsers浏览器
错误信息
net::ERR_SSL_PROTOCOL_ERROR
错误页面上显示为“ERR_SSL_PROTOCOL_ERROR”,在自动化工具和开发者工具中显示为“net::ERR_SSL_PROTOCOL_ERROR”。
Chrome, Edge and other Chromium browsers — "This site can't provide a secure connection"
含义
Chrome 无法完成 TLS 握手,因为服务器的回复违反了协议:最常见的情况是对方根本不是 TLS(该端口上运行的是纯 HTTP 服务器),或者服务器发送了格式错误或意料之外的握手数据。页面会显示“This site can't provide a secure connection — <host> sent an invalid response”。这与证书无关。
原因
用 https:// 访问提供纯 HTTP 服务的端口
常见开发服务器、管理端口,或者缺少 TLS 监听器的服务器。
HSTS 强制纯 HTTP 开发站点使用 https://
常见位于 HSTS 预加载列表中的域名(例如 .dev 和 .app),或者以前发送过 Strict-Transport-Security 的主机,总会被升级到 https://,即使本地服务器只支持 HTTP 也是如此。
配置错误或有故障的 TLS 服务器
偶见后端协议配置错误的代理、有缺陷的网络设备,或者在握手中途关闭连接的服务器。
杀毒软件或防火墙干扰
偶见破坏握手的 HTTPS 扫描功能和网络过滤器,会让原本正常的网站也出现同样的错误。
修复方法
- 1.
检查端口使用的协议
如果响应的是纯 HTTP,就改用 TLS 端口,或在该监听器上启用 TLS。
bash curl -si http://www.example.com:8080/ | head -1 # plain HTTP answers? openssl s_client -connect www.example.com:443 -servername www.example.com -brief </dev/null - 2.
开发环境:清除 HSTS 或使用本地 HTTPS
在 chrome://net-internals/#hsts 中删除该主机的 HSTS 条目(预加载的域名无法删除),或者为开发服务器配置一张本地受信任的证书。
text Local development on a domain with HSTS (e.g. *.dev, or a site you once visited over HTTPS): open chrome://net-internals/#hsts, "Delete domain security policies" for the host, or serve the dev site over HTTPS with a locally trusted certificate (mkcert). - 3.
网站所有者:在提供 https:// 的端口上启用 TLS
为监听器配置 TLS 和证书,并从外部测试握手。
text Site owners: make sure the port that browsers reach with https:// has TLS enabled (nginx: "listen 443 ssl;" plus ssl_certificate / ssl_certificate_key).