title: Fetching the CA details from a x.509 certificate in Android
body: <p>I have initiated an HTTPS connection using something like </p>
  
  <pre><code>httpsCert.connect();
  </code></pre>
  
  <p>where httpsCert is <code>HttpsURLConnection httpsCert</code>.</p>
  
  <p>Now I do something like <code>Certificate[] certs = httpsCert.getServerCertificates();</code> to retrieve the server x.509 certificates. </p>
  
  <blockquote>
    <p>I want to retrieve which root CA or the intermediary CA signed the certificate received above. </p>
  </blockquote>
  
  <p>My approach has been to look at the issuer field in the certificate received above, but is it a good approach. I mean is there a better approach of doing this ?</p>
  
  <p>Secondly, from <a href="http://developer.android.com/reference/javax/net/ssl/HttpsURLConnection.html#getServerCertificates()" rel="nofollow">developer.android.com/HttpsUrlConnection</a>, it appears that getServerCertificates () would return <strong>the list of certificates identifying the peer with the peer's identity certificate followed by CAs.</strong> In this context, in case of some certificates, like certificates fetched by Google apps, there is a section of the certificate that says <strong>Authority Information Access: 
                                                                                CA Issuers - URI:<a href="http://pki.google.com/GIAG2.crt" rel="nofollow">http://pki.google.com/GIAG2.crt</a></strong> however this is not the case with other apps fetching certificates signed by other authorities. </p>
  
  <blockquote>
    <p>Second question is how does Android validate the certificate path for certificates signed by intermediary CAs ?</p>
  </blockquote>