← Back to team overview

maria-discuss team mailing list archive

New Question: Connect Spring Hibernate and C3p0 application to Mariadb through SSL certificate authentication.

 

Hello,

A new question has been asked in "MariaDB FAQ" by ashishjagtap:
--------------------------------
I have created application in Spring,Hibernate and c3p0 which is now connecting to Mysql database. now we are migrating our application to MariaDB (Server version: 5.5.5-10.0.7-MariaDB Source distribution) through SSL.

following is the configuration file that we are using to connect to Mysql database

JDBC.properties

jdbc.initialPoolSize=10
jdbc.maxPoolSize=30
jdbc.minPoolSize=5
jdbc.acquireIncrement=3
jdbc.acquireRetryAttempts=0
jdbc.preferredTestQuery=SELECT 1
jdbc.idleConnectionTestPeriod=600
jdbc.numHelperThreads=10
jdbc.debugUnreturnedConnectionStackTraces=true
jdbc.mydbUrl=jdbc:mysql://myhost.com:3306/mydb?verifyServerCertificate=true&useSSL=true&requireSSL=true&characterEncoding=utf8
jdbc.mydbUsername=myuser

datasource-context.xml

<bean id="mydbCommon" class="com.mchange.v2.c3p0.ComboPooledDataSource" abstract="true" destroy-method="close">
	<property name="driverClass" value="${jdbc.rptdbDriverClassName}"/>
	<!-- Common properties for all DS -->
        <property name="initialPoolSize" value="${jdbc.initialPoolSize}"/>
        <property name="maxPoolSize" value="${jdbc.maxPoolSize}"/>
        <property name="minPoolSize" value="${jdbc.minPoolSize}"/>
        <property name="acquireIncrement" value="${jdbc.acquireIncrement}"/>
        <property name="acquireRetryAttempts" value="${jdbc.acquireRetryAttempts}"/>
        <property name="preferredTestQuery" value="${jdbc.preferredTestQuery}"/>
        <property name="idleConnectionTestPeriod" value="${jdbc.idleConnectionTestPeriod}"/>
        <property name="numHelperThreads" value="${jdbc.numHelperThreads}"/>
        <property name="debugUnreturnedConnectionStackTraces" value="${jdbc.debugUnreturnedConnectionStackTraces}"/>
</bean>
<bean id="mydb" parent="mydbCommon">
		<property name="jdbcUrl" value="${jdbc.mydbUrl}"/>
        <property name="user" value="${jdbc.mydbUsername}"/>
</bean> 

we are able to connect to DB server through command line using following command

mysql -h myhost.com -P3306 -umyuser --ssl-ca ca.crt --ssl-cert app.crt --ssl-key my-key.key

now how can I specify --ssl-ca,--ssl-cert and --ssl-cert files while connecting to MariaDB through Hibernate and c3p0. or what is the steps to connect to MariaDB database through SSL using c3p0 and hibernate.


--------------------------------

To view or answer this question please visit: http://mariadb.com/kb/en/connect-spring-hibernate-and-c3p0-application-to-mariadb-through-ssl-certif/