@Override
    public CertPath engineGenerateCertPath(List<? extends Certificate> certificates)
            throws CertificateException {
        final List<X509Certificate> filtered = new ArrayList<X509Certificate>(certificates.size());
        for (int i = 0; i < certificates.size(); i++) {
            final Certificate c = certificates.get(i);

            if (!(c instanceof X509Certificate)) {
                throw new CertificateException("Certificate not X.509 type at index " + i);
            }

            filtered.add((X509Certificate) c);
        }

        return new OpenSSLX509CertPath(filtered);
    }
The code for X509 Certificates and CRL is pretty much the same. We use
this abstract class to share the code between them. This makes it ugly,
but it's already written in this language anyway.
common/src/main/java/org/conscrypt/OpenSSLX509CertificateFactory.java