Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. TrustManagerFactory tmf1 = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
  2. tmf1.init(keyStore);
  3.  
  4. KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
  5. kmf.init(keyStore, password);
  6.  
  7. SSLContext sslContext = SSLContext.getInstance("TLS");
  8.  
  9.  
  10. sslContext.init(kmf.getKeyManagers(), tmf1.getTrustManagers(), null);
  11.  
  12.  
  13. // Tell the URLConnection to use a SocketFactory from our SSLContext
  14. URL url =new URL("https://172.20.175.1/kani/");
  15. HttpsURLConnection urlConnection = (HttpsURLConnection)url.openConnection();
  16. urlConnection.setSSLSocketFactory(sslContext.getSocketFactory());
  17.  
  18. InputStream in = new BufferedInputStream(urlConnection.getInputStream());
  19.  
  20. 04-11 11:35:30.123: W/System.err(4880): javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
  21. 04-11 11:35:30.133: W/System.err(4880): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:401)
  22. 04-11 11:35:30.133: W/System.err(4880): at libcore.net.http.HttpConnection.setupSecureSocket(HttpConnection.java:209)
  23. 04-11 11:35:30.133: W/System.err(4880): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:478)
  24. 04-11 11:35:30.133: W/System.err(4880): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433)
  25. etc...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement