Skip to content

Instantly share code, notes, and snippets.

@uchagani
uchagani / ClientFactory.java
Created July 21, 2023 21:41
Ignore SSL OKHTTP3 Configuration
// Add this when creating an OKHttp3 Client
var trustManager = new IgnoreSslTrustManager[]{new IgnoreSslTrustManager()};
var sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustManager, new java.security.SecureRandom());
var okHttpClient = clientBuilder.addInterceptor(new AuthenticationInterceptor())
.sslSocketFactory(sslContext.getSocketFactory(), trustManager[0])
.hostnameVerifier((hostname, session) -> true)
.build();