mysql - ssl连接时如何修复“无法打开jks文件”
问题描述
当我尝试与 MySQL 建立基于 JDBC 的 SSL 连接时,出现以下异常:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:无法打开文件://home/files/_jvm/bin/keystore.jks [home]
- 我试图将所有属性保留在 JDBC url
- 我也尝试传入属性实例
Class.forName("com.mysql.jdbc.Driver");
Properties mysqlProperties = new Properties();
mysqlProperties.put("user", "root");
mysqlProperties.put("password", "root");
mysqlProperties.put("clientCertificateKeyStoreUrl", "file://home/files/_jvm/bin/keystore.jks");
mysqlProperties.put("clientCertificateKeyStorePassword", "mypass");
mysqlProperties.put("trustCertificateKeyStoreUrl", "file://home/files/_jvm/bin//truststore.jks");
mysqlProperties.put("trustCertificateKeyStorePassword", "mypass");
con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/db74?verifyServerCertificate=true&useSSL=true&requireSSL=true",
mysqlProperties);
System.out.println(con.getMetaData().getDatabaseProductName());
我希望通过加密连接[基于 ssl/tls 的连接]获得数据库名称。
解决方案
推荐阅读
- ionic3 - 嵌入 Vimeo Pro 并在移动应用程序中使用 Vimeo Player
- sql - Oracle 12c 中的 FLASHBACK_TRANSACTION_QUERY 视图不返回任何行
- c - 如何构建 sqlcipher?
- c# - 使自动按键注册像真正的键盘按键 C#(和或 C++)
- android - Android - Firebase 实时数据库中的复杂查询
- r - R中的CGlur的数据树:递归循环查找所有子节点直到叶子
- python - 绘制 Scipy optimize.minimize 每次迭代的收敛结果?
- python - How to configure Ansible for Python virtual environment?
- c# - 努力理解我的导师为我编写的代码,用于 arknoid/brickbreaker 碰撞检测
- javascript - 如何根据输入的json动态加载html元素?