2016-06-17 3 views
0

I 있어요 - 다음으로 아래의 코드 변경 - 초안 [email protected] 악수, 거짓 거부 연결 -1을 폐쇄 :WSS 웹 소켓의 작성 문제

소켓 생성 coode

webClient = new APICWebClient(new URI(getWebSocketUrl(currentApic.IPAddress, port)), new Draft_17()); 
       webClient.connect(); 

Constructor: 
    public APICWebClient(URI serverURI, Draft draft) { 
     super(serverURI, draft); 

     SSLContext sslContext = null; 
     try { 
      sslContext = SSLContext.getDefault(); 
     } catch (NoSuchAlgorithmException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
     setWebSocketFactory(new DefaultSSLWebSocketClientFactory(sslContext)); 
     logger.info("Socket object created"); 
    } 

Draft_17. 내가 얻을 : 폐쇄 연결 -1,, 사실. 어떤 도움이라도 여기에서. 이것은 소켓 생성 중에 발생합니다.

+0

어떻게 인증서를 찾지 않습니까? – Prakash

답변

0

다음과 같이 sslcontext를 작성해야합니다. 인증서를 건너 뜁니다. 인증서없이 연결할 수있었습니다.

SSLContext sslContext = SSLContext.getInstance("SSL"); 

// set up a TrustManager that trusts everything 
sslContext.init(null, new TrustManager[] { new X509TrustManager() { 
      public X509Certificate[] getAcceptedIssuers() { 
        System.out.println("getAcceptedIssuers ============="); 
        return null; 
      } 

      public void checkClientTrusted(X509Certificate[] certs, 
          String authType) { 
        System.out.println("checkClientTrusted ============="); 
      } 

      public void checkServerTrusted(X509Certificate[] certs, 
          String authType) { 
        System.out.println("checkServerTrusted ============="); 
      } 
} }, new SecureRandom());