Skip to content

Instantly share code, notes, and snippets.

@mangadul
Created March 13, 2017 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mangadul/ade5881cf6f2fa15960aa9c252007785 to your computer and use it in GitHub Desktop.
Save mangadul/ade5881cf6f2fa15960aa9c252007785 to your computer and use it in GitHub Desktop.
// connect to websocket
if (!kurentoRoomAPI.isWebSocketConnected()) {
try {
kurentoRoomAPI.connectWebSocket();
} catch (OpeningHandshakeException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (WebSocketException e) {
e.printStackTrace();
}
}
// using custom ssl
if (kurentoRoomAPI == null) {
String STORETYPE = Constants.STORETYPE;
String STOREPASSWORD = Constants.STOREPASSWORD;
String KEYPASSWORD = Constants.KEYPASSWORD;
try {
InputStream inputStream = new BufferedInputStream(getResources().openRawResource(R.raw.tatapmuka));
KeyStore ks = null;
ks = KeyStore.getInstance( STORETYPE );
ks.load(inputStream, STOREPASSWORD.toCharArray() );
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init( ks, KEYPASSWORD.toCharArray() );
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ks);
SSLContext sslContext = null;
sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null );
KurentoAPI.setSSLContext(sslContext);
kurentoRoomAPI = new KurentoRoomAPI(executor, wsUri, this);
} catch (KeyStoreException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (CertificateException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnrecoverableKeyException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
}
}
// disconnect
kurentoRoomAPI.disconnectWebSocket();
kurentoRoomAPI = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment