X509Certificate certificate;
try {
certificate = CertUtil.loadCertificate(stream);
}catch (GeneralSecurityException e) {
String message = "Certificates are invalid";
throw new GfacRuntimeException(message, e);
}
if (certificate == null) {
break;
}
certificates.add(certificate);