Skip to content

Commit

Permalink
Fix SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
NaikSoftware committed Apr 5, 2017
1 parent 81916e9 commit 14c468b
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ua.naiksoftware.stomp;

import android.os.Looper;
import android.util.Log;

import org.java_websocket.WebSocket;
Expand All @@ -17,6 +18,9 @@
import java.util.Map;
import java.util.TreeMap;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;

import rx.Observable;
import rx.Subscriber;

Expand Down Expand Up @@ -112,6 +116,17 @@ public void onError(Exception ex) {
}
};

if(mUri.startsWith("wss")) {
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, null, null);
SSLSocketFactory factory = sc.getSocketFactory();
mWebSocketClient.setSocket(factory.createSocket());
} catch (Exception e) {
e.printStackTrace();
}
}

mWebSocketClient.connect();
haveConnection = true;
}
Expand Down

0 comments on commit 14c468b

Please sign in to comment.