title: SSLHandshakeException using HttpsURLConnection in Android
body: <p>Details about my app:</p>
  
  <pre><code>compileSdkVersion 22
      buildToolsVersion '22.0.1'
  
  
  
      defaultConfig {
          applicationId "My application id"
          minSdkVersion 13
          targetSdkVersion 22
          versionCode 4
          versionName "2"
      }
  </code></pre>
  
  <p>I'm using HttpsURLConnection for Login authentication.But now i'm facing <strong>javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException</strong> that too on devices running below android lollipop.Authentication is working as expected on devices running OS verions abouve 5.Please let me know your suggestions for this issue.</p>
  
  <p>Here is the code i'm using :</p>
  
  <pre><code>    HttpsURLConnection conn = null;
      try {
          URL url = new URL("URL to my application");
  
          String authStr = username + ":" + password;
  
          String authEncoded = Base64.encodeToString(authStr.getBytes(), Base64.NO_WRAP);
          conn = (HttpsURLConnection) url.openConnection();
          conn.setRequestMethod("POST");
          conn.setRequestProperty("Authorization", "Basic " + authEncoded);
          conn.setDoOutput(true);
  
          conn.setConnectTimeout(120000);
          int code = conn.getResponseCode();
  
          if(code ==200){
              for(int i=0;i&lt;conn.getHeaderFields().size();i++){
                  String value = conn.getHeaderField(i);
  
                  HeaderElement headerElement =  BasicHeaderValueParser.parseHeaderElement(value, new BasicHeaderValueParser());
  
                  if(headerElement.getName().equals("SMSESSION")){
  
                      cookieString = SMSESSION+"="+headerElement.getValue();
                      Log.d("validhdvaluelogin",cookieString);
                      cookieeditor.putString(ArticleListActivity.CURRENT_COOKIE,
                              cookieString);
                      cookieeditor.apply();
  
                      return true;
                  }
  
  
              }
          }else {
              return false;
          }
  
  
  
      }
  
      catch (Exception e) {
          e.printStackTrace();
          return false;
      }
  
  
      if (conn != null) {
          conn.disconnect();
      }
  
      return false;
  </code></pre>
  
  <p>And here is the exception :</p>
  
  <pre><code>javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL       
  handshake aborted: ssl=0xb87b0350: Failure in SSL library, usually a    
  protocol error
  error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake            
  failure (external/openssl/ssl/s23_clnt.c:741 0xa9092990:0x00000000)
  at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:448)
  at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.&lt;init&gt;(OpenSSLSocketImpl.java:661)
  at com.android.org.conscrypt.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:632)
  at org.apache.http.impl.io.SocketInputBuffer.&lt;init&gt;(SocketInputBuffer.java:70)
  at org.apache.http.impl.SocketHttpClientConnection.createSessionInputBuffer(SocketHttpClientConnection.java:83)
  at org.apache.http.impl.conn.DefaultClientConnection.createSessionInputBuffer(DefaultClientConnection.java:170)
  at org.apache.http.impl.SocketHttpClientConnection.bind(SocketHttpClientConnection.java:106)
  at org.apache.http.impl.conn.DefaultClientConnection.openCompleted(DefaultClientConnection.java:129)
  at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:172)
  at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
  at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
  at com.ericsson.labs.it.infoservicemx.network.AuthComm.login(AuthComm.java:148)
  at com.ericsson.labs.it.infoservicemx.LoginActivity$UserLoginTask.doInBackground(LoginActivity.java:312)
  at com.ericsson.labs.it.infoservicemx.LoginActivity$UserLoginTask.doInBackground(LoginActivity.java:230)
  at android.os.AsyncTask$2.call(AsyncTask.java:288)
  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
  at java.lang.Thread.run(Thread.java:841)
  Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb87b0350: Failure in SSL library, usually a protocol error
  error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:741 0xa9092990:0x00000000)
  at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
  at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
  ... 23 more
  </code></pre>