title: Making SSLEngine use TLSv1.2 on Android (4.4.2)?
body: <p>Folks, I'm hoping there's something obvious that I'm missing, and I hope someone will be able to shed some light.  I'm trying to get TLSv1.2 running in an SSL + NIO context (using the <a href="https://github.com/koush/AndroidAsync" rel="noreferrer">AndroidAsync</a> library), so I'm trying to enable it via an SSLEngine.  I can run code like this:</p>
  
  <pre><code>        SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
          sslContext.init(null, null, null);
          String[] protocols = sslContext.getSupportedSSLParameters().getProtocols();
          for (String protocol : protocols) {
              Timber.d("Context supported protocol: " + protocol);
          }
  
          SSLEngine engine = sslContext.createSSLEngine();
          String[] supportedProtocols = engine.getSupportedProtocols();
          for (String protocol : supportedProtocols) {
              Timber.d("Engine supported protocol: " + protocol);
          }
  </code></pre>
  
  <p>And I end up seeing this on logcat:</p>
  
  <pre><code>06-22 21:56:27.715    1117-1117/? D/XXX﹕ Context supported protocol: SSLv3
  06-22 21:56:27.715    1117-1117/? D/XXX﹕ Context supported protocol: TLSv1
  06-22 21:56:27.725    1117-1117/? D/XXX﹕ Context supported protocol: TLSv1.1
  06-22 21:56:27.725    1117-1117/? D/XXX﹕ Context supported protocol: TLSv1.2
  06-22 21:56:27.735    1117-1117/? D/XXX﹕ Engine supported protocol: TLSv1
  06-22 21:56:27.745    1117-1117/? D/XXX﹕ Engine supported protocol: SSLv3
  </code></pre>
  
  <p>Of course if I try to <code>engine.setEnabledProtocols(new String[] { "TLSv1.2" })</code> I get an IllegalArgumentException "Protocol TLSv1.2 is not supported."</p>
  
  <p>I can see the context claims to support TLSv1.2, but then the engine I make from that context doesn't?  What's going on here?  None of this changes if I use "TLS" instead of "TLSv1.2" in the first line above, btw.</p>
  
  <p>I gather this might have something to do with <a href="https://code.google.com/p/android/issues/detail?id=61085" rel="noreferrer">this issue</a>, and I've read <a href="https://stackoverflow.com/questions/20573215/how-do-you-use-tlsv1-2-on-kitkat-was-where-is-openssl-1-0-1-in-the-android-19">this (as yet unanswered) question</a> and <a href="http://blog.dev001.net/post/67082904181/android-using-sni-and-tlsv1-2-with-apache-httpclient" rel="noreferrer">articles like this</a>, but they don't quite seem to be hitting the spot - solutions I've seen all seem to rely on SSLSocket rather than SSLEngine.</p>
  
  <p>Thanks much for any knowledge you can drop.</p>
  
  <p><strong>UPDATE 6/23/14 10AMEDT</strong></p>
  
  <p>So I found <code>SSLEngine.setSSLParameters</code>, which I was hoping would let me pass in an SSLParameters that I got from <code>SSLContext.getSupportedSSLParameters()</code>, but when I call that I get an exception that claims the cipher suites aren't supported, so it looks like setSSLParameters() is just doing the same thing that setEnabledCipherSuites() does, and the engine is already in a state where it doesn't recognize the TLS 1.2 protocol/suites as supported.</p>