title: How to parse AuthoritiyInformation from X509Certificate object
body: <p>I want to retrieve the OCSP information from a given <code>X509Certificate</code> object. Since I don't know how to parse this information I am asking this question here.</p>
  
  <p>Here is what I got so far:</p>
  
  <pre><code>X509Certificate x509cert = ... //The Certificate
  ASN1Primitive obj = ASN1Primitive.fromByteArray(x509cert
                              .getExtensionValue(Extension.authorityInfoAccess
                                      .getId()));
  AuthorityInformationAccess aia = AuthorityInformationAccess.getInstance(obj);
  </code></pre>
  
  <p>an exception is thrown:</p>
  
  <pre><code>java.security.cert.CertificateParsingException: java.lang.IllegalArgumentException: unknown object in getInstance: org.bouncycastle.asn1.DEROctetString
  </code></pre>
  
  <p>How do I parse a <code>ASN1Primitive</code> into a valid <code>DEROctetString</code> to progress?</p>
  
  <p>The value of the <code>ASN1Primitive</code> in the example is: </p>
  
  <pre><code>3032303006082b060105050730018624687474703a2f2f6f6373702e616368656c6f732e64653a383038302f6f6373702f65676b
  </code></pre>
  
  <p>and seems to me to be a valid value.</p>