Skip to content

Commit 5c54633

Browse files
committed
Fix: Add configurable TLS version support to PusherOptions in test files
1 parent 178a1f0 commit 5c54633

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/main/java/com/pusher/client/util/BaseHttpAuthClient.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.pusher.client.util;
22

3+
import javax.net.ssl.SSLSocketFactory;
34
import java.io.BufferedReader;
45
import java.io.DataOutputStream;
56
import java.io.IOException;
@@ -22,6 +23,7 @@ abstract class BaseHttpAuthClient {
2223
private final URL endPoint;
2324
private Map<String, String> mHeaders = new HashMap<>();
2425
protected ConnectionFactory mConnectionFactory;
26+
protected SSLSocketFactory mSslSocketFactory = null;
2527

2628
/**
2729
* Creates a new auth client.
@@ -61,6 +63,15 @@ public void setHeaders(final Map<String, String> headers) {
6163
mHeaders = headers;
6264
}
6365

66+
/**
67+
* Set the SSL socket factory that is used for the connection. This allows to
68+
* configure custom certificate handling (self-signed certificates, mutual TLS, ...)
69+
* @param sslSocketFactory The SSL socket factory to use
70+
*/
71+
public void setSslSocketFactory(final SSLSocketFactory sslSocketFactory) {
72+
mSslSocketFactory = sslSocketFactory;
73+
}
74+
6475
/**
6576
* Identifies if the HTTP request will be sent over HTTPS.
6677
*
@@ -92,6 +103,10 @@ protected String performAuthRequest() {
92103
HttpURLConnection connection;
93104
if (isSSL()) {
94105
connection = (HttpsURLConnection) endPoint.openConnection();
106+
if(mSslSocketFactory != null) {
107+
((HttpsURLConnection) connection)
108+
.setSSLSocketFactory(mSslSocketFactory);
109+
}
95110
} else {
96111
connection = (HttpURLConnection) endPoint.openConnection();
97112
}

0 commit comments

Comments
 (0)