title: Spring RestTemplate call to HTTPS *without* HttpClient
body: <p>Trying to make REST calls with RestTemplate using the server cert as the client cert to make calls with.</p>
  
  <p>Don't ask me why :-), but I don't want to use Apache's HttpClient. I just think it's overkill.</p>
  
  <p>I've seen code that uses regular JDK's <code>SSLContext</code> to set things up system-wide, i.e., set up <code>SSLContext</code> and the call <code>SSLContext.setDefault(sslContext)</code> as in this code:</p>
  
  <pre><code>// ... keymanagers, trustmanagers are omitted here
  SSLContext sslContext = SSLContext.getInstance("TLS");
  sslContext.init(keymanagers, trustmanagers, new SecureRandom());
  SSLContext.setDefault(sslContext);
  </code></pre>
  
  <p>However, I saw a GitHub comment here (<a href="https://github.com/spring-projects/spring-boot/issues/6493" rel="nofollow noreferrer">https://github.com/spring-projects/spring-boot/issues/6493</a>) that states that setting <code>SSLContext</code> as default like that isn't really a good idea.</p>
  
  <p>So, my question is: outside of having to use HttpClient, is there a way to use the <code>sslContext</code> configured in the code snippet above in <code>RestTemplate</code> setup somehow?</p>