Created
March 13, 2017 11:44
-
-
Save mangadul/ade5881cf6f2fa15960aa9c252007785 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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