title: How to use SSL encryption when connecting Vaadin App with Hibernate to MariaDB on Azure
body: <p>I am currently working on a Java 8 app with Vaadin and Hibernate which I am trying to migrate to Azure for testing purposes.
  Everything worked out so far except for one thing:<br>
  When I activate the require SSL option in The MariaDB on Azure, I can't connect anymore:</p>
  
  <p><code>Caused by: java.sql.SQLException: SSL connection is required. Please specify SSL options and retry.</code></p>
  
  <p>Unfortunately I didn't write this app myself and I am not too familiar with neither Vaadin nor Hibernate or even Java in general and how to establish ssl or db connections with those.<br>So I need some help:</p>
  
  <p>This is the JDBC Connection string in the Servlet.java file, where for my understanding the db init happens:</p>
  
  <pre><code>Connection con = DriverManager.getConnection("jdbc:mysql://&lt;username&gt;.mariadb.database.azure.com:3306/&lt;db&gt;?autoReconnect=true", "&lt;username&gt;", "&lt;password&gt;");
  </code></pre>
  
  <p><br>
  which I changed by just adding this to the URL: <code>&amp;useSSL=true&amp;requireSSL=true&amp;verifyServerCertificate=true</code></p>
  
  <p>Now the app doesn't stop at the DB init anymore but still crashes before the page is fully rendered, with the same error message.</p>
  
  <p>I found a <code>hibernate.cfg.xml</code> with the following content (I removed the mappings to keep it shorter):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;!-- Hibernate --&gt;
          &lt;property name="hibernate.use_sql_comments"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.format_sql"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.show_sql"&gt;false&lt;/property&gt;
          &lt;property name="hibernate.connection.autocommit"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLInnoDBDialect&lt;/property&gt;
  
          &lt;!-- Hikari --&gt;
          &lt;property name="hibernate.connection.provider_class"&gt;com.zaxxer.hikari.hibernate.HikariConnectionProvider&lt;/property&gt;
          &lt;property name="hibernate.hikari.dataSourceClassName"&gt;com.mysql.jdbc.jdbc2.optional.MysqlDataSource&lt;/property&gt;
          &lt;property name="hibernate.hikari.dataSource.url"&gt;jdbc:mysql://dbname.mariadb.database.azure.com:3306/db&lt;/property&gt;
          &lt;property name="hibernate.hikari.dataSource.user"&gt;username&lt;/property&gt;
          &lt;property name="hibernate.hikari.dataSource.password"&gt;password&lt;/property&gt;
          &lt;property name="hibernate.hikari.dataSource.cachePrepStmts"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.hikari.dataSource.prepStmtCacheSize"&gt;250&lt;/property&gt;
          &lt;property name="hibernate.hikari.dataSource.prepStmtCacheSqlLimit"&gt;2048&lt;/property&gt;
          &lt;property name="hibernate.hikari.dataSource.useServerPrepStmts"&gt;true&lt;/property&gt;
      &lt;/session-factory&gt;
  
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p><br>
  What do I have to change there to make use of SSL for the connection?</p>