title: How to make an SSL connection to MySQL using MariaDB Connector/J?
body: <p>I'm using MySQL 5.7.10 with SSL enabled and certificates generated as per <a href="http://dev.mysql.com/doc/refman/5.7/en/creating-ssl-files-using-openssl.html" rel="nofollow">these instructions</a>. My Java 7 application uses a <a href="https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/" rel="nofollow">MariaDB Connector/J</a> and SSL is enabled in the JDBC URL:</p>
  
  <pre class="lang-none prettyprint-override"><code>jdbc:mysql://dbservername:3306/dbname?useSSL=true&amp;trustServerCertificate=false
  </code></pre>
  
  <p>But the connection fails with:</p>
  
  <pre class="lang-none prettyprint-override"><code>Caused by: java.lang.RuntimeException: Could not generate DH keypair
  ...
  Caused by: java.security.InvalidAlgorithmParameterException: Prime size must be multiple of
  64, and can only range from 512 to 1024 (inclusive)
  </code></pre>
  
  <p>According to <a href="http://mysqlblog.fivefarmers.com/2015/08/11/ssltls-connections-to-recent-mysql-servers-in-java/" rel="nofollow">this blog post</a>, the problem could be resolved by:</p>
  
  <ol>
  <li>Upgrading to Java 8 (or higher).</li>
  <li>Downgrading to MySQL 5.7.5 (or lower).</li>
  <li>Excluding Diffie-Hellman (DH) ciphers.</li>
  </ol>
  
  <p>(1) isn't an option on the project I'm working on. (2) seems restrictive and would prevent access to future MySQL improvements. (3) seems the most promising: I've verified it does work with <a href="https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html" rel="nofollow">MySQL connector/J</a> but unfortunately its GPL license prevents me from being able to use it on my project.</p>
  
  <p>Does MariaDB Connector/J have an equivalent property to <code>enabledSSLCipherSuites</code> or is there any other way to prevent it from using DH ciphers when connecting?</p>