title: how to make Unirest(java) ignore certificate error
body: <p>I am using Unirest (java version) to make GET and POST request.But I encounter a problem when accessing SSL encrypted site , since my program is behind a corporate network and the network admin setup a firewall mapping for me. For example <code>foobar.com</code> is mapped to <code>56.1.89.12:4444</code>. But when I make request to the address, I will received the following ssl certificate error:</p>
  
  <pre><code>com.mashape.unirest.http.exceptions.UnirestException: javax.net.ssl.SSLException: hostname in certificate didn't match: &lt;56.1.89.12&gt; != &lt;www.foobar.com&gt;
      at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131)
      at com.mashape.unirest.request.BaseRequest.asString(BaseRequest.java:52)
  </code></pre>
  
  <p>I see <code>Unirest</code> has advance configuration to use custom <code>httpclient</code>.So I use </p>
  
  <pre><code>Unirest.setHttpClient(MyHttpClient.makeClient());
  HttpResponse&lt;String&gt; res = null;
  try {
      res = Unirest.get(urlstr).asString();
  } catch (UnirestException e) {
      e.printStackTrace();
  }
  String jsonstr = res.getBody();
  </code></pre>
  
  <p>the <code>makeClient</code> method of <code>MyHttpClient</code> is:</p>
  
  <pre><code>public static HttpClient makeClient(){
   SSLContextBuilder builder = new SSLContextBuilder();
   CloseableHttpClient httpclient = null;
      try {
          // builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
          builder.loadTrustMaterial(null, new TrustStrategy(){
              public boolean isTrusted(X509Certificate[] chain, String authType)
                  throws CertificateException {
                  return true;
              }
          });
          SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
                  builder.build());
          httpclient = HttpClients.custom().setSSLSocketFactory(
                  sslsf).build();
          System.out.println("custom httpclient called");
          System.out.println(httpclient);
  
      } catch (NoSuchAlgorithmException e) {
          e.printStackTrace();
      } catch (KeyStoreException e) {
          e.printStackTrace();
      } catch (KeyManagementException e) {
          e.printStackTrace();
      }
  
  return httpclient;
  }
  </code></pre>
  
  <p>the main idea is taken from <a href="https://stackoverflow.com/questions/19517538/ignoring-ssl-certificate-in-apache-httpclient-4-3">Ignoring SSL certificate in Apache HttpClient 4.3</a></p>
  
  <p>But still this didn't work.Any suggestions?</p>