I have some java-app, and i want to establish a connection to some https Site, how can i do this, using URLConnection? Should i use trust store, when certificate from this site was signed using a valid certificate authority?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes. URLConnection should work. For example,
URL a = new URL("https://login.yahoo.com");
conn = a.openConnection();
InputStream is = conn.getInputStream();
JRE comes with a default trust store with most of the CA certs. As long as the cert is signed by one of them, you don't need to do anything special.