@Test public void build() { OkHttpClient.Builder builder = new OkHttpClient.Builder(); SecuritySupport securitySupport = new SecuritySupport("classpath:certs"); try { securitySupport.applySslSocketFactory(builder); OkHttpClient build = builder.build(); Request request = new Request.Builder() .url("https: .get() .build(); okhttp3.Response execute = build.newCall(request).execute(); } catch (Exception e) { fail("expected custom letsencrypt install to succeed " +e.getMessage()); } }
void applySslSocketFactory(OkHttpClient.Builder builder) throws NakadiException { 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"); } }
SecuritySupport { void applySslSocketFactory(OkHttpClient.Builder builder) throws NakadiException { 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"); } } }
SecuritySupport { void applySslSocketFactory(OkHttpClient.Builder builder) throws NakadiException { 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"); } } SecuritySupport(String certificatePath); }
SecuritySupport { void applySslSocketFactory(OkHttpClient.Builder builder) throws NakadiException { 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"); } } SecuritySupport(String certificatePath); SSLContext sslContext(); X509TrustManager trustManager(); }
SecuritySupport { void applySslSocketFactory(OkHttpClient.Builder builder) throws NakadiException { 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"); } } SecuritySupport(String certificatePath); SSLContext sslContext(); X509TrustManager trustManager();  }