public static List<String> getAIALocations(X509Certificate cert) throws CertificateVerificationException {

        //Gets the DER-encoded OCTET string for the extension value for Authority information access points.
        byte[] aiaExtensionValue = cert.getExtensionValue(Extension.authorityInfoAccess.getId());
        if (aiaExtensionValue == null) {
            throw new CertificateVerificationException("Certificate doesn't have Authority Information Access points");
        }
        AuthorityInformationAccess authorityInformationAccess;
        ASN1InputStream asn1InputStream = null;

        try {
            DEROctetString oct = (DEROctetString) (new ASN1InputStream(new ByteArrayInputStream(aiaExtensionValue))
                    .readObject());
            asn1InputStream = new ASN1InputStream(oct.getOctets());
            authorityInformationAccess = AuthorityInformationAccess.getInstance(asn1InputStream.readObject());
        } catch (IOException e) {
            throw new CertificateVerificationException("Cannot read certificate to get OSCP urls", e);
        } finally {
            try {
                if (asn1InputStream != null) {
                    asn1InputStream.close();
                }
            } catch (IOException e) {
                LOG.error("Cannot close ASN1InputStream", e);
            }
        }

        List<String> ocspUrlList = new ArrayList<>();
        AccessDescription[] accessDescriptions = authorityInformationAccess.getAccessDescriptions();
        for (AccessDescription accessDescription : accessDescriptions) {

            GeneralName gn = accessDescription.getAccessLocation();
            if (gn.getTagNo() == GeneralName.uniformResourceIdentifier) {
                DERIA5String str = DERIA5String.getInstance(gn.getName());
                String accessLocation = str.getString();
                ocspUrlList.add(accessLocation);
            }
        }
        if (ocspUrlList.isEmpty()) {
            throw new CertificateVerificationException("Cannot get OCSP urls from certificate");
        }
        return ocspUrlList;
    }
public static List < String > getAIALocations ( X509Certificate cert ) throws CertificateVerificationException { byte [ ] aiaExtensionValue = cert . getExtensionValue ( Extension . authorityInfoAccess . getId ( ) ) ; if ( aiaExtensionValue == null ) { throw new CertificateVerificationException ( "Certificate doesn't have Authority Information Access points" ) ; } AuthorityInformationAccess authorityInformationAccess ; ASN1InputStream asn1InputStream = null ; try { DEROctetString oct = ( DEROctetString ) ( new ASN1InputStream ( new ByteArrayInputStream ( aiaExtensionValue ) ) . readObject ( ) ) ; asn1InputStream = new ASN1InputStream ( oct . getOctets ( ) ) ; authorityInformationAccess = AuthorityInformationAccess . getInstance ( asn1InputStream . readObject ( ) ) ; } catch ( IOException e ) { throw new CertificateVerificationException ( "Cannot read certificate to get OSCP urls" , e ) ; } finally { try { if ( asn1InputStream != null ) { asn1InputStream . close ( ) ; } } catch ( IOException e ) { LOG . error ( "Cannot close ASN1InputStream" , e ) ; } } List < String > ocspUrlList = new ArrayList < > ( ) ; AccessDescription [ ] accessDescriptions = authorityInformationAccess . getAccessDescriptions ( ) ; for ( AccessDescription accessDescription : accessDescriptions ) { GeneralName gn = accessDescription . getAccessLocation ( ) ; if ( gn . getTagNo ( ) == GeneralName . uniformResourceIdentifier ) { DERIA5String str = DERIA5String . getInstance ( gn . getName ( ) ) ; String accessLocation = str . getString ( ) ; ocspUrlList . add ( accessLocation ) ; } } if ( ocspUrlList . isEmpty ( ) ) { throw new CertificateVerificationException ( "Cannot get OCSP urls from certificate" ) ; } return ocspUrlList ; }
Authority Information Access (AIA) is a non-critical extension in an X509 Certificate. This contains the
URL of the OCSP endpoint if one is available.

@param cert is the certificate
@return a lit of URLs in AIA extension of the certificate which will hopefully contain an OCSP endpoint.
@throws CertificateVerificationException if any error occurs while retrieving authority access points from the
certificate.