7

In android, I want to make a URL connection to a HTTPS URL. After the connection is opened I want to be able to read the certificate from the server and obtain the issued common name and organisation strings?

Is this possible? If so what is the best approach?

So far I have been using HttpsUrlConnection as:

HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.getInputStream();
X509Certificate cert = (X509Certificate) urlConnection.getServerCertificates()[0];

But after this point, I am not sure how to get the specific certificate details? I am not even sure, if this is the right approach.

FlashAsh80
  • 1,357
  • 1
  • 16
  • 27

0 Answers0