Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. X509Certificate rootCertificate = ...;
  2. X509Certificate intermediateCertificate = ...;
  3. X509Certificate myPublicCertificate = ...;
  4. KeyStore myPrivateKey = ...;
  5.  
  6.  
  7. KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
  8. keyManagerFactory.init(myPrivateKey, "password");
  9. SSLContext context = SSLContext.getInstance("TLSv1.2");
  10. context.init(keyManagerFactory.getKeyManagers(), null, new SecureRandom());
  11.  
  12. SSLSocketFactory socketFactory = context.getSocketFactory();
  13. HttpsURLConnection.setDefaultSSLSocketFactory(socketFactory);
  14. URL url = new URL(urlPath);
  15. HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
  16.  
  17. *** ServerHelloDone
  18. Warning: no suitable certificate found - continuing without client authentication
  19. *** Certificate chain
  20. <Empty>
  21. ***
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement