2014-11-29 2 views
0

https 연결을 처리하기 위해 사용자 정의 프록시 서버를 작성하려고합니다. Java에서 .NET SSLStream과 동일한 기능이 있습니까?Java와 동등한 .NET SSLStream

답변

0

SSL ServerSocket을 만들려면 SSLSocketFactory을 사용해야 할 수도 있습니다. 관련 서버 소켓은 (특정/구현 된 inout 스트림) 데이터 암호화 및 관련 프로세스를 처리합니다.
다음과 같이 시스템 등록 정보로 SSL 설정을 지정할 수 있습니다.

System.setProperty("javax.net.ssl.trustStore", "<<path of your key>>"); 
System.setProperty("javax.net.ssl.trustStorePassword", "<<store passwd if specified>>"); 
//System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); 
System.setProperty("javax.net.debug", "all"); 

나중에, 나머지 작업은 그냥 일반 (비 SSL) 과정처럼

int port=3128,backlog=32; 
ServerSocket ss=SSLServerSocketFactory.getDefault().createServerSocket(port, backlog, InetAddress.getLoopbackAddress()); 

을 다음과 같이 ServerSocket를 초기화 단지 요청을 수신하고 진행해야합니다.

while(ss.isBound()){ 
Socket s=ss.accept(); 
InputStram in=s.getInputStream(); 
OutputStream os=s.getOutputStream(); 
//.....rest of teh work 
}