-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Description
Running on OpenJDK as an example, this behavior split violates the least-surprise principle IMO:
- utilizing default java trust that comes free with JVM - great
- ignoring default java identity that comes free with JVM - frustrating
I know some platforms/runtimes don't have this javax.net.ssl.keyStore identity concept available, but a builder flag like useDefaultSslContext() would be fantastic in any case. That would internally just use SSLContext.getDefault() and leave its trust/identity as-is, so API users don't have to reimplement the same boilerplate over and over. If that sounds like an acceptable path I'd be happy to work on a PR.
The existing builder sslSocketFactory() API accepts an SSLSocketFactory/TrustManager, this change would internalize the boilerplate.
Related, this documentation is.. questionable:
fun sslSocketFactory(sslSocketFactory: , trustManager: ): OkHttpClient.Builder
Sets the socket factory and trust manager used to secure HTTPS connections. If unset, the system defaults will be used.
I would think the system default referenced here implies SSLContext.getDefault().getSocketFactory() or SSLSocketFactory.getDefault(), which is not the case.