Skip to content

Add method to client builder to use default SSLContext #9221

@DSmithVA

Description

@DSmithVA

Running on OpenJDK as an example, this behavior split violates the least-surprise principle IMO:

  1. utilizing default java trust that comes free with JVM - great
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions