CertificateLoader { void applySslSocketFactory(OkHttpClient.Builder builder) throws FeatureException { try { MDC.put("security_context", "[security_support]"); if (certificatePath == null) { logger.info("no custom certificate path supplied, using system default"); return; } builder.sslSocketFactory(sslContext.getSocketFactory(), trustManager); logger.info("ok, custom socket factory and trust manager added to builder"); } finally { MDC.remove("security_context"); } } CertificateLoader(String certificatePath);   }
@Test public void build() { OkHttpClient.Builder builder = new OkHttpClient.Builder(); CertificateLoader securitySupport = new CertificateLoader("classpath:certs"); try { securitySupport.applySslSocketFactory(builder); OkHttpClient build = builder.build(); Request request = new Request.Builder() .url("https: .get() .build(); build.newCall(request).execute(); } catch (Exception e) { fail("expected custom letsencrypt install to succeed " + e.getMessage()); } }