Comments - About MariaDB Connector/J

5 years, 3 months ago vgriffin

After doing a fair amount of web searching, and a log of trial and error, I got an SSL connection working with the connection to mydb defined in my persistence.xml file. I'm using MariaDB 10.3 (Alpha) and Hibernate 5.2.12, configured as JPA rather than Hibernate. I'm using IntelliJ and put "myCert.pem" into my resources directory so it ends up on the top level of my classpath. Note that the CN used in the certificate MUST match the domain used for connection. (So far, I've only used "localhost". Another server is tomorrow's task. You'll see localhost in the example, too.) The line in persistence.xml that makes the magic happen is:

<property name="javax.persistence.jdbc.url" value="jdbc:mariadb:localhost:3306/mydb?useSSL=true&amp;serverSslCert=classpath:myCert.pem"/>

The last problem was that I didn't remember initially that the XML file needed &amp; in the String. Note that user and password are already javax.persistence.jdbc properties.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.