通过HTTPS访问网站,谷歌浏览器报错“使用了不受支持的协议ERR_SSL_VERSION_OR_CIPHER_MISMATCH”的原因及解决方法

我的软件环境:

Ubuntu 24

Nginx

Cloudflare DNS

我使用Let’s Encrypt的Cerbot为admin.larabbs.zuotijia.me申请SSL/TLS证书后,使用浏览器访问https://admin.larabbs.zuotijia.me网站报错:

  • 谷歌浏览器报错“使用了不受支持的协议ERR_SSL_VERSION_OR_CIPHER_MISMATCH”的原因及解决方法。
  • 火狐浏览器报错“连接到 admin.larabbs.zuotijia.me 时发生错误。无法安全地与对等端通信:没有双方共用的加密算法。错误代码:SSL_ERROR_NO_CYPHER_OVERLAP”

但是同样使用Let’s Encrypt的Cerbot为www.zuotijia.me申请SSL/TLS证书,能正常通过浏览器访问https://www.zuotijia.me网站。说明不是Cerbot的问题。

错误原因

错误原因是,在Cloudflare上使用的是Cloudflare免费提供的SSL通用证书(Cloudflare Universal SSL),它只支持根域名(yourwebsite.com)以及二级泛域名(*.yourwebsite.com),不支持三级及以上的域名。

解决方法

方法一,不要使用三级及以上的域名。

方法二,在Cloudflare的仪表板->SSL/TLS->概述界面

配置加密模式为“灵活”或“关闭”:

但这种方法不够安全,因此不推荐这种方法。

方法三,不要使用Cloudflare管理域名,使用其他域名服务提供商来管理你的域名。

参考

https://devsdawn.com/2021/10/cloudflare-multi-level-subdomains-ssl-error

https://developers.cloudflare.com/ssl/edge-certificates/additional-options/total-tls/error-messages

https://developers.cloudflare.com/ssl/edge-certificates/additional-options/total-tls

https://developers.cloudflare.com/ssl/edge-certificates/additional-options/total-tls/enable

https://developers.cloudflare.com/ssl/edge-certificates/custom-certificates

https://developers.cloudflare.com/ssl/edge-certificates/custom-certificates/uploading

https://www.obodizhu.com/resouce-experience/perfect-solution-to-err_ssl_version_or_cipher_mismatch-error.html

https://www.cnblogs.com/yzbg/articles/17323611.html

https://community.cloudflare.com/t/topic/399346

JDBC连接MySQL数据库警告:Establishing SSL connection without server’s identity verification is not recommend

JDBC连接MySQL出现如下警告:

Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

原因是高版本MySQL需要指明是否进行SSL连接。

解决方法是在JDBC连接MySQL的URL字符串中加入useSSL=true或者useSSL=false即可,例如:

jdbc:mysql://127.0.0.1:3306/framework?serverTimezone=UTC&characterEncoding=utf8&useSSL=false

如果你的连接确实没有暴露给网络(仅限本地主机),或者你在没有真实数据的非生产环境中工作,那么可以肯定的是:通过包含选项useSSL=false来禁用SSL没有坏处。

如果要使用useSSL=true,需要以下一组选项才能使SSL使用证书、主机验证并禁用弱协议选项:

  • useSSL=true
  • sslMode=VERIFY_IDENTITY
  • trustCertificateKeyStoreUrl=file:path_to_keystore
  • trustCertificateKeyStorePassword=password
  • enabledTLSProtocols=TLSv1.2

因此,作为一个示例,让我们假设你希望使用SSL将其中一种Atlassian产品(Jira、Confluence、Bamboo等)连接到MySQL服务器,你需要执行以下主要步骤:

  • 首先,确保你有一个为MySQL服务器主机生成的有效的SSL/TLS证书,并且CA证书安装在客户端主机上(如果你使用自签名,那么你可能需要手动执行此操作,但对于流行的公共CA,它已经在那里了)。
  • 接下来,确保java密钥库包含所有CA证书。在Debian/Ubuntu上,这是通过运行以下命令来实现的:
update-ca-certificates -f
chmod 644 /etc/ssl/certs/java/cacerts
  • 最后,更新Atlassian产品使用的连接字符串以包含所有必需的选项,这在Debian/Ubuntu上类似于:
jdbc:mysql://mysql_server/confluence?useSSL=true&sslMode=VERIFY_IDENTITY&trustCertificateKeyStoreUrl=file%3A%2Fetc%2Fssl%2Fcerts%2Fjava%2Fcacerts&trustCertificateKeyStorePassword=changeit&enabledTLSProtocols=TLSv1.2&useUnicode=true&characterEncoding=utf8

更多相关信息请参见MySQL官方文档https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-using-ssl.html

参考

https://beansandanicechianti.blogspot.com/2019/11/mysql-ssl-configuration.html