Skip to content

Issue in the way OkHttpClient is used in the Minio Java Client #628

@someshrathi02

Description

@someshrathi02

These seems to be an issue in the way OkHttpClient is used in the Minio Java Client

Context:
We are trying to connect to Minio using the Mimio-java client from a SpringBoot application.

  • JDK 1.8.0_112
  • Minio Client - 3.0.7

The SpringBoot application is using a custom PKI provider.

Issue faced:
It looks like Minio Java client is using the OKHTTPClient. And the problem appears to be how Minio Java client is using the OkHttPClient.

https://github.com/minio/minio-java/blob/master/api/src/main/java/io/minio/MinioClient.java

So even though Minio Java Client provides a constructor to pass the OkHttpClient (see below), it is already initializing the OkHttpClient at the Class level in line 202:

This is the constructor that we want to use
MinioClient(String endpoint, int port, String accessKey, String secretKey, String region, boolean secure, OkHttpClient httpClient)

line 202
private OkHttpClient httpClient = new OkHttpClient();

So if this httpClient initialization is moved to the relevant Constructors (& not at the class level), we think that the issue can be resolved.

The problem happens when the default OkHttpClient tries to set the default TrustManager:

Within the OkHttpClient
https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/OkHttpClient.java
Line 284
trustManagerFactory.init((KeyStore) null);
Not all the custom PKI providers handle this null gracefully.

Work around (used for now):
We switched from using the Minio Java Client to AmazonS3 Java client and everything works as expected.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions