Failed to Connect to a Database Using mariadb-connector in SSL Mode
Scenario
A database could not be connected using JDBC, and the following error message was displayed:
unable to find certification path to requested target
Possible Causes
In the figure above, a MariaDB JAR package is used to connect to the database, which is slightly different from the official driver package of MySQL.
Solution
The connection string for mariadb-java-client-2.7.5 is as follows:
- If the CA certificate is not provided and the certificate is not verified:
String url = "jdbc:mysql://ip:port/mysql?useSsl=true&trustServerCertificate=true";
- If the CA certificate is provided and the certificate is verified:
String url = "jdbc:mysql://ip:port/mysql?useSsl=true&serverSslCert=D:\\ca.pem&disableSslHostnameVerification=true";
Note: RDS for MySQL DB instances do not support hostname verification, so you need to set disableSslHostnameVerification to true. The way you set this parameter depends on the MariaDB JAR package version. For details, see the notes on usage of the corresponding version.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot