Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 763a219

Browse files
Merge pull request #13 from hamilyon/customSslSocketFactory
add possibility to override ssl socket factory
2 parents 044c170 + 45dbfe0 commit 763a219

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

‎src/main/java/tech/gusavila92/websocketclient/WebSocketClient.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ public abstract class WebSocketClient {
134134
*/
135135
private volatile Thread reconnectionThread;
136136

137+
138+
private SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
139+
137140
/**
138141
* Initialize all the variables
139142
*
@@ -152,6 +155,11 @@ public WebSocketClient(URI uri) {
152155
webSocketConnection = new WebSocketConnection();
153156
}
154157

158+
159+
public void setSSLSocketFactory(SSLSocketFactory sslSocketFactory) {
160+
socketFactory = sslSocketFactory;
161+
}
162+
155163
/**
156164
* Called when the WebSocket handshake has been accepted and the WebSocket
157165
* is ready to send and receive data
@@ -648,7 +656,6 @@ private boolean createAndConnectTCPSocket() throws IOException {
648656
socket.connect(new InetSocketAddress(uri.getHost(), 80), connectTimeout);
649657
}
650658
} else if (scheme.equals("wss")) {
651-
SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
652659
socket = socketFactory.createSocket();
653660
socket.setSoTimeout(readTimeout);
654661

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /