title: Enabling AES_128_CBC and RC4_128 for JDBC connections to MS SQL Server 2005
body: <p>To ensure backward compatibility of my application, I'm testing JDBC over TLS behaviour when an <em>MS SQL Server</em> version vulnerable to <a href="https://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3389" rel="nofollow">CVE-2011-3389</a> is used (any 2005, or 2008/2008R2 w/o service packs fit). In theory, two options are available:</p>
  
  <ul>
  <li>either disable CBC protection via <code>-Djsse.enableCBCProtection=false</code> and continue to use a block cipher such as <code>AES_128_CBC</code> or <code>3DES_EDE_CBC</code>,</li>
  <li>or fall back to a stream cipher such as <code>RC4</code> (yes I'm aware this is insecure, too, due to <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=cve-2015-2808" rel="nofollow">CVE-2015-2808</a>).</li>
  </ul>
  
  <p>In practice, while I have no trouble establishing a connection using <code>3DES_EDE_CBC</code> with CBC protection off, I'm still unable to use <code>RC4_128</code> using an JDK newer than <strong>1.8.0_51</strong> (which happened to <a href="http://www.oracle.com/technetwork/java/javase/8u51-relnotes-2587590.html" rel="nofollow">address</a> CVE-2015-2808) or <code>AES_{128,256}_CBC</code> (using any <strong>1.6+</strong> JDK).</p>
  
  <p>Here's the results broken down by Java version:</p>
  
  <ul>
  <li><strong>1.6.0_45</strong> (<em>jTDS</em>) 
  
  <ul>
  <li><code>SSL_RSA_WITH_RC4_128_MD5</code> is used</li>
  </ul></li>
  <li><strong>1.7.0_76</strong> (<em>jTDS</em>) and any 1.8.0 up to <strong>1.8.0_45</strong> (<em>MS SQL JDBC</em>):
  
  <ul>
  <li><code>SSL_RSA_WITH_RC4_128_MD5</code> (default) or <code>SSL_RSA_WITH_3DES_EDE_CBC_SHA</code> can be used</li>
  <li>won't use <code>AES_128_CBC</code> even if <code>3DES</code> is disabled (<code>3DES_EDE_CBC</code> will be forced anyway)</li>
  </ul></li>
  <li><strong>1.8.0_45</strong> (IBM J9 8.0 SR1) (<em>MS SQL JDBC</em>)
  
  <ul>
  <li><code>SSL_RSA_WITH_3DES_EDE_CBC_SHA</code> is used (successful only if CBC protection is off), also if either <code>AES</code> or <code>RC4</code> is requested</li>
  </ul></li>
  <li><strong>1.8.0_51+</strong> (Oracle) (<em>MS SQL JDBC</em>)
  
  <ul>
  <li><code>SSL_RSA_WITH_3DES_EDE_CBC_SHA</code> is used (successful only if CBC protection is off),</li>
  <li>won't use <code>AES_128_CBC</code> or <code>AES_256_CBC</code> even if requested (unlike previous  Java versions, <code>3DES</code> is no longer forced, instead I get an <code>IOException</code> after <code>ClientHello</code>, which does list <code>*_WITH_AES_128_CBC_SHA</code> as compatible ciphersuites)</li>
  <li>won't use <code>RC4</code> even if both with <code>AES</code> and <code>3DES</code> are disabled: <code>"no negotiable cipher suite"</code> (both <em>jTDS</em> and <em>MS SQL JDBC</em>).</li>
  </ul></li>
  </ul>
  
  <p>Here's the <code>java.security</code> I use to request <code>AES</code>:</p>
  
  <pre><code>jdk.certpath.disabledAlgorithms=MD2
  jdk.tls.disabledAlgorithms=SSLv3, RC4, TLSv1.1, TLSv1.2, 3DES_EDE_CBC
  jdk.tls.legacyAlgorithms= \
          K_NULL, C_NULL, M_NULL, \
          RC4_128, RC4_40
  </code></pre>
  
  <p>and here's the version to request <code>RC4</code>:</p>
  
  <pre><code>jdk.certpath.disabledAlgorithms=MD2
  jdk.tls.disabledAlgorithms=SSLv3, AES_128_CBC, TLSv1.1, TLSv1.2, AES_256_CBC, AES_128_GCM, AES_256_GCM, 3DES_EDE_CBC
  jdk.tls.legacyAlgorithms= \
          K_NULL, C_NULL, M_NULL
  </code></pre>
  
  <p>Questions:</p>
  
  <ul>
  <li>Apparently, <code>AES_{128,256}_CBC</code> is supported by my Java clients, as I can use <code>TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA</code> when connecting to <em>MS SQL Server 2014</em>. Can anyone confirm it is <strong>not</strong> supported by <em>MS SQL Server 2005</em>? Since disabling <code>AES</code> effectively leads to <code>"no negotiable cipher suite"</code>, I assume it <strong>is</strong> supported, but something happens server-side, even though CBC protection is off.</li>
  <li>How can I still use <code>RC4</code> in Java <strong>1.8.0_51+</strong>? <a href="https://stackoverflow.com/a/33048221/1343979">This solution</a> no longer works, nor has any effect <code>https.cipherSuites</code> system property (described <a href="https://blogs.oracle.com/coffeys/entry/jdk_and_use_of_rc4" rel="nofollow">here</a>). There's a magical <code>jdk.tls.enableRC4CipherSuites</code> system property in <a href="https://bugs.openjdk.java.net/browse/JDK-8142326" rel="nofollow">6u115</a> and <a href="https://bugs.openjdk.java.net/browse/JDK-8141050" rel="nofollow">7u101</a>, but it seems to have no effect in Java 1.8.</li>
  <li>What the heck is wrong with <em>jTDS</em>? It works fine with Java 1.6 and 1.7 (driver versions 1.2.8 and 1.3.1), but using Java 1.8 I'm constantly receiving <code>"Connection reset by peer"</code> whenever <em>MS SQL JDBC</em> would just use <code>3DES</code> to encrypt connection data. </li>
  </ul>