티스토리 뷰
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
- 사용법
- 명령어
- signtool
- websocket
- 타임스탬프
- 파이썬
- 코드스쿨
- ORACLE 프로시져생성
- qwebview
- PyQt
- SW대회
- 프로그래밍대회
- 리눅스
- 자유한국당
- Python
- 서버주소
- .svn
- 디지털서명
- IT-PMP
- Android
- stamp
- WSS
- 소프트웨어대회
- 파이썬프레임워크
- 관련사이트
- 온라인저지
- 더불어 민주당
- 프로젝트관리전문가
- 안드로이드 화면 밝기 조절
- setup.py
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |