class CertUtils {

    public static X509Certificate[] readCertificateChain(String filename) throws CertificateException, IOException {
        CertificateFactory fact = CertificateFactory.getInstance("X.509");
        try (FileInputStream is = new FileInputStream(filename)) {
            final Collection<? extends Certificate> certs = fact.generateCertificates(is);
            return certs.toArray(new X509Certificate[0]);
        }
    }

    private  CertUtils();

}