idea中使用database TLS异常处理

idea中使用database TLS异常提示

08S01\] Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. No appropriate protocol (protocol is disabled or cipher suites are inappropriate) The following required algorithms might be disabled: SSLv3, TLSv1, TLSv1.1, DTLSv1.0, RC4, DES, MD5withRSA, DH keySize \< 1024, EC keySize \< 224, 3DES_EDE_CBC, anon, NULL, ECDH. Edit the list of disabled algorithms to include required algorithms. You can try to enable TLSv1 or TLSv1.1 first. JDBC driver may have disabled TLS 1.1 and its earlier versions.

原因:
JDBC 客户端支持的 TLS 版本/套件 和 MySQL 服务器端启用的 TLS 不匹配

解决方案:

方案一 idea中database中的advanced下的useSSL改成false

方案二 升级mysql的TLS,让他支持TLSv1.2,TLSv1.3

mysql版本要求:MySQL 5.7.10+

  1. 先看版本与SSL库
shell 复制代码
SELECT VERSION();
SHOW VARIABLES LIKE 'have_ssl';
SHOW VARIABLES LIKE 'ssl_cipher';
SHOW VARIABLES LIKE 'tls_version';
  1. 配置 my.cnf/mysqld.cnf
shell 复制代码
[mysqld]
# 开启现代协议
tls_version=TLSv1.2,TLSv1.3   # 至少包含 TLSv1.2

# 指定证书(PEM)
ssl_ca=/etc/mysql/ssl/ca.pem
ssl_cert=/etc/mysql/ssl/server-cert.pem
ssl_key=/etc/mysql/ssl/server-key.pem

证书生成

复制代码
# 生成 CA 私钥和证书
openssl genrsa 2048 > ca-key.pem
openssl req -new -x509 -nodes -days 3650 -key ca-key.pem -out ca.pem

# 生成服务端私钥和证书请求
openssl genrsa 2048 > server-key.pem
openssl req -new -key server-key.pem -out server-req.pem

# 用 CA 签发服务端证书
openssl x509 -req -in server-req.pem -days 3650 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem

# 生成客户端私钥和证书
openssl genrsa 2048 > client-key.pem
openssl req -new -key client-key.pem -out client-req.pem
openssl x509 -req -in client-req.pem -days 3650 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem

最终你会得到:

ca.pem(CA 证书)

server-cert.pem / server-key.pem(服务端证书和私钥)

client-cert.pem / client-key.pem(客户端证书和私钥)

然后你将证书拷贝到 my.cnf/mysqld.cnf 配置的证书地方

相关推荐
宠..几秒前
为单选按钮绑定事件
运维·服务器·开发语言·数据库·c++·qt·microsoft
宠..6 分钟前
对单选按钮分组
开发语言·数据库·c++·qt·安全·安全性测试
Ashley_Amanda10 分钟前
SAP ABAP 开发全攻略:从核心编程到最佳实践
大数据·数据库·sql
黎相思14 分钟前
附录:SQLite介绍
数据库·sqlite
毕设十刻15 分钟前
基于Vue的新生入学报道管理系统(程序 + 源码 + 数据库 + 调试部署 + 开发环境配置),配套论文文档字数达万字以上,文末可获取,系统界面展示置于文末
前端·数据库·vue.js
Vic1010117 分钟前
Redis防重复点击与分布式锁
java·数据库·redis·分布式
游戏开发爱好者821 分钟前
对 iOS IPA 文件进行深度混淆的一种实现路径
android·ios·小程序·https·uni-app·iphone·webview
罗政31 分钟前
mybatis-plus插件解决sql报错:this is incompatible with sql_mode=only_full_group_by ”
数据库·sql·mybatis
leo_qiu_s33 分钟前
MERGE INTO语句
数据库
未来之窗软件服务38 分钟前
幽冥大陆(六十二) 多数据库交叉链接系统Go语言—东方仙盟筑基期
数据库·人工智能·oracle·golang·数据库集群·仙盟创梦ide·东方仙盟