I know that using a single instance of OkHttpClient for the entire app is a best practice. But I came across with TrustKit and I needed to implement the next code:
OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
URL url = new URL("https://www.url.com");
String serverHostname = url.getHost();
builder.sslSocketFactory(TrustKit.getInstance().getSSLSocketFactory(serverHostname),
TrustKit.getInstance().getTrustManager(serverHostname)).build();
Then I realized that maybe the right way is to have a single instance per domain. Currently I have to implement cert pinning and I have inside my application multiple domains where I fetch the information my app needs.
So the question is: what is the best practice in case you have multiple domains when you try to instantiate a OkHttpClient? One instance per domain?