X509Certificate certificate;
try {
certificate = CertUtil.readCertificate(bufferedReader);
} catch (IOException e) {
String message = "Failed to read certificates";
throw new XBayaRuntimeException(message, e);
} catch (GeneralSecurityException e) {
String message = "Certificates are invalid";
throw new XBayaRuntimeException(message, e);
}
if (certificate == null) {
break;
}
certificates.add(certificate);