Skip to content

Commit

Permalink
Use SystemSocketFactory instead of the default factory for SSL socket…
Browse files Browse the repository at this point in the history
… factory (#2592)

* Solving #2585
* Using ApacheHttpTransport.newDefaultHttpClientBuilder() instead of constructing a complete new instance.
* Applied formatting.
  • Loading branch information
jacksierkstra authored and louismurerwa committed Jul 20, 2020
1 parent 454a0d5 commit a4e689f
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -39,6 +39,7 @@
import java.util.function.Supplier;
import javax.net.ssl.SSLException;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.HttpClientBuilder;

/**
Expand Down Expand Up @@ -97,7 +98,10 @@ private static HttpTransport getSecureHttpTransport() {
//
// A new ApacheHttpTransport needs to be created for each connection because otherwise HTTP
// connection persistence causes the connection to throw NoHttpResponseException.
return new ApacheHttpTransport();
HttpClientBuilder httpClientBuilder =
ApacheHttpTransport.newDefaultHttpClientBuilder()
.setSSLSocketFactory(SSLConnectionSocketFactory.getSystemSocketFactory());
return new ApacheHttpTransport(httpClientBuilder.build());
}

private static HttpTransport getInsecureHttpTransport() {
Expand Down

0 comments on commit a4e689f

Please sign in to comment.