title: Handshake Failed using using okHttp but working using HttpURLConnection
body: <p>I am trying to send get request to a server (sending get request for testing, actually I need to send a post request to same server. If get works, post will work)</p>
  
  <p>link to server is
  <a href="https://bits-bosm.org/2017/registrations/signup/" rel="nofollow noreferrer">https://bits-bosm.org/2017/registrations/signup/</a></p>
  
  <p>The problem is when I send request using okHttp, I get a failure response saying Handshake failed.</p>
  
  <p>Here is the code I am using to send the request using okHttp (in kotlin)</p>
  
  <pre><code>val request = Request.Builder()
              .url("https://bits-bosm.org/2017/registrations/signup/")
              .build()
  
      okHttpClient.newCall(request).enqueue(object : Callback {
          override fun onFailure(call: Call?, e: IOException?) {
              val mMessage = e?.message?.toString()
              Log.w("failure Response", mMessage)
          }
  
          override fun onResponse(call: Call?, response: Response?) {
              val mMessage = response?.body()?.string()
              Log.e("Message", mMessage)
          }
      })
  </code></pre>
  
  <p>But if I use HttpUrlConnection to send the get request to the same server, I get the response.</p>
  
  <p>Here is the code for the same (java)</p>
  
  <pre><code>private static final String USER_AGENT = "Mozilla/5.0";
  
  private static final String GET_URL = "https://bits-bosm.org/2017/registrations/signup/";
  
  
  
  static void sendGET() throws IOException {
      URL obj = new URL(GET_URL);
      HttpURLConnection con = (HttpURLConnection) obj.openConnection();
      con.setRequestMethod("GET");
      con.setRequestProperty("User-Agent", USER_AGENT);
      int responseCode = con.getResponseCode();
      System.out.println("GET Response Code :: " + responseCode);
      if (responseCode == HttpURLConnection.HTTP_OK) { // success
          BufferedReader in = new BufferedReader(new InputStreamReader(
                  con.getInputStream()));
          String inputLine;
          StringBuffer response = new StringBuffer();
  
          while ((inputLine = in.readLine()) != null) {
              response.append(inputLine);
          }
          in.close();
  
          // print result
          Log.e("Result", response.toString());
      } else {
          System.out.println("GET request not worked");
      }
  
  }
  </code></pre>
  
  <p>From what I have searched the internet and from what I could deduce, the problem is the site is signed using self certificate, and okHttp disallows them. I have even tried using code snippets which I found on Internet which don't check the certificate (Custom SSLSocketFactory) and a few more solutions but none of them worked. Also I don't care about security right now, I just want to get it worked. But I have no access to backend and cannot change/remove ssl security.</p>
  
  <p>What can do to make it work? Is there something which I am missing?</p>