Q:

Android HttpPost javax.net.ssl.SSLProtocolException unrecognized name

I am trying to post some data to an api from an Android tablet, but I keep getting an SSLProtocolException and I can't figure out the problem.
This is the error I keep getting:
javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7bccbdc8: Failure in SSL library, usually a protocol error
error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 unrecognized name (external/openssl/ssl/s23_clnt.c:741 0x73d67718:0x00000000)
W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:468)
W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.<init>(OpenSSLSocketImpl.java:717)
W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:688)
W/System.err﹕ at org.apache.http.impl.io.SocketInputBuffer.<init>(SocketInputBuffer.java:70)
W/System.err﹕ at org.apache.http.impl.SocketHttpClientConnection.createSessionInputBuffer(SocketHttpClientConnection.java:83)
W/System.err﹕ at org.apache.http.impl.conn.DefaultClientConnection.createSessionInputBuffer(DefaultClientConnection.java:170)
W/System.err﹕ at org.apache.http.impl.SocketHttpClientConnection.bind(SocketHttpClientConnection.java:106)
W/System.err﹕ at org.apache.http.impl.conn.DefaultClientConnection.openCompleted(DefaultClientConnection.java:129)
W/System.err﹕ at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:221)
W/System.err﹕ at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:167)
W/System.err﹕ at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:125)
W/System.err﹕ at     org.apache.http.impl.client.DefaultRequestDirector.executeOriginal(DefaultRequestDirector.java:1227)
W/System.err﹕ at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:677)
W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
W/System.err﹕ at com.example.casper.bilfinger.sendJSONdata.doInBackground(sendJSONdata.java:130)
W/System.err﹕ at com.example.casper.bilfinger.sendJSONdata.doInBackground(sendJSONdata.java:54)
W/System.err﹕ at android.os.AsyncTask$2.call(AsyncTask.java:288)
W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err﹕ W/System.err﹕at java.lang.Thread.run(Thread.java:841)
W/System.err﹕ Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7bccbdc8: Failure in SSL library, usually a protocol error
W/System.err﹕ error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 unrecognized name (external/openssl/ssl/s23_clnt.c:741 0x73d67718:0x00000000)
W/System.err﹕ W/System.err﹕at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
W/System.err﹕ W/System.err﹕at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:425)
W/System.err﹕ ... 23 more

And this is the code I'm using.
public  class sendJSONdata extends AsyncTask<String, String, String>{

    String httpAuthUser=*username*;
    String httpAuthPassword=*password*;

    String Bedrijf;
    String Naam;
    String Functie;
    String Vestiging;
    String Telefoonnummer;
    String Email;
    String Opmerkingen;
    String GesprokenMet;
    Context context;

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    public sendJSONdata(String[] values,Context context)
    {
         Bedrijf= values[0];
         Naam= values[1];
         Functie= values[2];
         Vestiging= values[3];
         Telefoonnummer= values[4];
         Email= values[5];
         Opmerkingen= values[6];
         GesprokenMet= values[7];
        this.context=context;
        //System.setProperty("jsse.enableSNIExtension", "false");

    }

    protected String doInBackground(String... strings) {
        ///Build JSON object and fill with your data
        JSONObject subpostMessage = new JSONObject();
        try {
            subpostMessage.put("emailAdres", Email);
            subpostMessage.put("Naam", Naam);
            subpostMessage.put("Bedrijfsnaam", Bedrijf);
            subpostMessage.put("Telnummer", Telefoonnummer);
            subpostMessage.put("Functie", Functie);
            subpostMessage.put("Vestiging", Vestiging);
            subpostMessage.put("Opmerkingen", Opmerkingen);
            subpostMessage.put("GesprokenMet", GesprokenMet);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        //Connect to HttpClient with basic Aut
        HttpParams httpParameters = new BasicHttpParams();
        HttpClient httpclient = new MyHttpClient(httpParameters,context);//new DefaultHttpClient(httpParameters);//
        HttpPost httppost = new HttpPost(*Https to php file");
        String base64EncodedCredentials = "Basic " + Base64.encodeToString((httpAuthUser + ":" + httpAuthPassword).getBytes(), Base64.NO_WRAP);
        httppost.setHeader("Authorization", base64EncodedCredentials);

        String responseStr = null;
        try {
            // Add your data to te connection
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("postData", subpostMessage.toString()));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            Log.d("httpPost: ",httppost.getMethod());
            Log.d("ValuePairs- name: ",nameValuePairs.get(0).getName()+ " val: "+ nameValuePairs.get(0).getValue());

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);

            //Recover result response
            responseStr = EntityUtils.toString(response.getEntity());

            Log.d("JSON ATTEMPT","Response: "+responseStr);
        } catch (ClientProtocolException e) {
            Log.d("JSON ATTEMPT","Response:CPerror "+e.toString());
        } catch (IOException e) {
            Log.d("JSON ATTEMPT","Response:IOerror "+e.toString());
        }
        return responseStr;
    }

    protected void onPostExecute(String result) {
        if (result == null) {
            //Request Failed
            return;
        }

        //System.out.println("RECEIVED RESPONSE: " + result);

        try {
            JSONObject jObj = new JSONObject(result);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onProgressUpdate(String... values) {
    }

}

And the place where its called.
    void postJSONdata()
    {
        String[] values  = new String[8];
        values[0]=bnaam.getText().toString();
        values[1]=naam.getText().toString();
        values[2]=functie.getText().toString();
        values[3]=vestiging.getText().toString();
        values[4]=tele.getText().toString();
        values[5]=mail.getText().toString();
        values[6]=opmerking.getText().toString();
        values[7]=gesprokenmet.getText().toString();
        sendJSONdata task = new sendJSONdata(values,getApplicationContext());
        task.execute();
    }

This error is thrown on any jdk I try (6,7,8),
Most of the post I found suggested it had to do with SNI which was introduced in 7 but with 6 I still have the same error.

A:

This problem is caused by the configuration of the server, combined with no or invalid support of SNI by the client. The server will return with the unrecognized_name alert if no SNI was used or if SNI was used with the wrong name. Thus you need to make sure that you use a Java version which supports SNI, enable it and also use the correct name to access the server.

