终极解决本地https域名访问ERR_SSL_PROTOCOL_ERROR

昨天升级了下mac电脑,访问本地项目代码环境https域名不能访问

导致在谷歌浏览器里访问本地https站点,提示”ERR_SSL_PROTOCOL_ERROR”,而用safari浏览器和firefox可以正常访问,推测谷歌浏览器对ssl校验比较严格。

1、解决办法是将本地环境的nginx升级到最新版,大家也可以直接用第2个办法升级openssl

brew upgrade nginx
nginx -v
提示如下就代表是最新版了
nginx version: nginx/1.19.0 
sudo nginx -t
提示
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /usr/local/etc/nginx/servers/

需要将里面这段SSL配置删除

ssl on;
sudo nginx -t
出现如下,代表配置正确
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

重启nginx,

sudo nginx -s reload

发现依然不能正常访问,排除了nginx的配置兼容问题。

2、升级openssl版本

采用源码安装,不要用 brew upgrade openssl 方式升级,没有用,版本依然是低版本。

下载oepnssl1.1.1g版本:https://www.openssl.org/source/openssl-1.1.1g.tar.gz

tar -zxvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config
make
sudo make install
brew link openssl --force

然后重启电脑,也不要问为什么,反正重启电脑就好。

提示有2020就代表是最新版本了
OpenSSL 1.1.1g  21 Apr 2020