title: How to programmatically add self signed certificate for making a HTTPS request from java code?
body: <p>Following code snippet is to get <code>JSon</code> response from a <code>HTTP</code> URL:</p>
  
  <pre><code>private static void getJson(String location) {
      try {
          try {
              createSSLSocket();
              URL url = new URL(
                      "https://abc.com/key/one");
              HttpURLConnection conn = (HttpURLConnection) url
                      .openConnection();
              conn.setRequestMethod("GET");
              conn.setRequestProperty("Accept", "application/json");
              if (conn.getResponseCode() != 200) {
                  throw new RuntimeException("Failed : HTTP error code : "
                          + conn.getResponseCode());
              }
              BufferedReader br = new BufferedReader(new InputStreamReader(
                      (conn.getInputStream())));
              String output;
              System.out.println("Output from Server .... \n");
              while ((output = br.readLine()) != null) {
                  System.out.println(output);
              }
              conn.disconnect();
  
          } catch (MalformedURLException e) {
              e.printStackTrace();
  
          } catch (IOException e) {
              e.printStackTrace();
  
          }
      } catch (Exception ex) {
          ex.printStackTrace();
      }
  
  }
  </code></pre>
  
  <p>But it is throwing <code>SSLHandshaking</code> exception because i didn't added self signed certification exception to the code. I have done this in <code>C#</code> but not in java. What steps should i perform? Need your suggestion :)</p>
  
  <p>Thanks in advance.</p>