title: Is it possible to build a Java 11 HttpClient that uses SSL/TLS JAVA_OPTS as its SSLContext?
body: <p>I know with Apache's <code>HttpClientBuilder</code> you can call <code>useSystemProperties()</code> and it will create a client with an <code>SSLContext</code> configured from the <code>javax.net.ssl.keyStore</code> (and truststore) if passed as <code>JAVA_OPTS</code>:</p>
  
  <pre><code>try (CloseableHttpClient client = HttpClientBuilder.create().useSystemProperties.build()) {
    // If javax.net.ssl props are set, make requests that require client auth
    // Otherwise make regular requests
  }
  </code></pre>
  
  <p>I want to do something similar with the Java 11 <code>HttpClient</code>.  The reason for this is in my use-case, I am treating key stores and trust stores as optional and it would be nice to not have to check their existence in my code.  Basically, I want to set an <code>SSLContext</code> based on <code>JAVA_OPTS</code> if they exist; otherwise just use the <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.Builder.html#sslContext(javax.net.ssl.SSLContext)" rel="nofollow noreferrer"><code>"Default"</code> context</a>.</p>