title: Need to ignore certificate when using restTemplate
body: <p>I am trying to send a request to following address. The certificate is not valid and I would like to ignore it. I wrote following code based on my research on <a href="https://stackoverflow.com/questions/23504819/how-to-disable-ssl-certificate-checking-with-spring-resttemplate">1</a>, <a href="https://stackoverflow.com/questions/17619871/access-https-rest-service-using-spring-resttemplate">2</a> but I am not able to complete it. I am using Java 1.7,</p>
  
  <pre><code>https://api.stubhubsandbox.com/search/catalog/events/v3
  </code></pre>
  
  <p>Code</p>
  
  <pre><code>private static final TrustManager[] UNQUESTIONING_TRUST_MANAGER = new TrustManager[]{
      new X509TrustManager() {
          public java.security.cert.X509Certificate[] getAcceptedIssuers(){
              return null;
          }
          public void checkClientTrusted( X509Certificate[] certs, String authType ){}
          public void checkServerTrusted( X509Certificate[] certs, String authType ){}
          public void checkClientTrusted(
                  java.security.cert.X509Certificate[] arg0, String arg1)
                  throws CertificateException {
              // TODO Auto-generated method stub
  
          }
          public void checkServerTrusted(
                  java.security.cert.X509Certificate[] arg0, String arg1)
                  throws CertificateException {
              // TODO Auto-generated method stub
  
          }
      }
  };
  
  public static void main(String[] args) {
      TrustStrategy acceptingTrustStrategy = 
  
      SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
              .loadTrustMaterial(null, acceptingTrustStrategy)
              .build();
  
      SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
  
      CloseableHttpClient httpClient = HttpClients.custom()
              .setSSLSocketFactory(csf)
              .build();
  
      HttpComponentsClientHttpRequestFactory requestFactory =
              new HttpComponentsClientHttpRequestFactory();
  
      requestFactory.setHttpClient(httpClient);
  
      RestTemplate restTemplate = new RestTemplate(requestFactory);
      String url = "https://api.stubhubsandbox.com/search/catalog/events/v3";
      RestTemplate rest = new RestTemplate();
      Map&lt;String, String&gt; mvm = new HashMap&lt;String, String&gt;();
      mvm.put("Authorization", "Bearer TOKEEEEEEEN");
      Object object = rest.postForObject(url, null, Object.class, mvm);
      System.err.println("done");
  
  
  }
  </code></pre>