I can't get the certificate from my website (neither other website). I tried some solutions with HttpsURLConnection
and the method getServerCertificates
but nothing solves the problem.
URL httpsURL = new URL("https://www.google.com.br/");
HttpsURLConnection connection = (HttpsURLConnection)httpsURL.openConnection();
Certificate[] certs = connection.getServerCertificates();
I get an exception saying that "getServerCertificates cannot be resolved."
I don't think its necessary to use keystore, is it??
That's strange. Are you sure you are using the proper classes? If I run this code:
I get a result like:
Verify what SSL socket factory you are using, maybe there is something wrong with that. Add this to you code and see what results from it (as an example, for me is
com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl
):