Help Center> Relational Database Service> Troubleshooting> RDS for MySQL> Connection Issues> Failed to Connect to a Database Using mariadb-connector in SSL Mode
Updated on 2023-03-06 GMT+08:00

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://xxx.xxx.xxx.xxx:xxxx/mysql?useSsl=true&trustServerCertificate=true";
  • If the CA certificate is provided and the certificate is verified:
    String url = "jdbc:mysql://xxx.xxx.xxx.xxx:xxxx/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.