티스토리 뷰
android native ssl client websocket wss://
안드로이드에서는 bks 사용함. jks->bks
private void connectWebSocketHttps() throws URISyntaxException, KeyStoreException ,Exception{
WebSocketChatClient chatclient = new WebSocketChatClient( new URI( "wss://xxx.xxx.kr/examples/websocket/chat" ) );
// load up the key store
String STORETYPE = "BKS";
// String KEYSTORE = "keystore.jks";
String STOREPASSWORD = "Pass123!";
String KEYPASSWORD = "Pass123!";
KeyStore ks = KeyStore.getInstance( STORETYPE );
//File kf = new File( KEYSTORE );
ks.load( getResources().openRawResource(R.raw.tomcat7), STOREPASSWORD.toCharArray() );
KeyManagerFactory kmf = KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm() );
kmf.init( ks, KEYPASSWORD.toCharArray() );
TrustManagerFactory tmf = TrustManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
tmf.init( ks );
SSLContext sslContext = null;
sslContext = SSLContext.getInstance( "TLS" );
sslContext.init( kmf.getKeyManagers(), tmf.getTrustManagers(), null );
// sslContext.init( null, null, null ); // will use java's default key and trust store which is sufficient unless you deal with self-signed certificates
SSLSocketFactory factory = sslContext.getSocketFactory();// (SSLSocketFactory) SSLSocketFactory.getDefault();
chatclient.setSocket( factory.createSocket() );
chatclient.connectBlocking();
/*
//exit program.. for java applicatoin
BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
while ( true ) {
String line = reader.readLine();
if( line!=null&&line.equals( "close" ) ) {
if(chatclient!=null)
chatclient.close();
} else {
if(line!=null)
chatclient.send( line );
}
}*/
}
- Total
- Today
- Yesterday
- 리눅스
- 서버주소
- 사용법
- Python
- SW대회
- 관련사이트
- signtool
- setup.py
- 안드로이드 화면 밝기 조절
- 프로젝트관리전문가
- 더불어 민주당
- 명령어
- 소프트웨어대회
- stamp
- IT-PMP
- 프로그래밍대회
- Android
- 타임스탬프
- 온라인저지
- 파이썬
- ORACLE 프로시져생성
- 자유한국당
- 코드스쿨
- WSS
- PyQt
- websocket
- .svn
- qwebview
- 디지털서명
- 파이썬프레임워크
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |