in src/main/java/org/jetbrains/nativecerts/linux/LinuxTrustedCertificatesUtil.java [89:124]
private static List<X509Certificate> tryReadFromFile(@NotNull Path file) {
try {
if (!Files.exists(file)) {
LOGGER.fine("Not reading certificates from " + file + ": file does not exist");
return Collections.emptyList();
}
if (!Files.isRegularFile(file)) {
LOGGER.warning("Not reading certificates from " + file + ": not a regular file");
return Collections.emptyList();
}
try (InputStream stream = Files.newInputStream(file)) {
List<X509Certificate> list = PemReaderUtil.readPemBundle(stream, file.toString());
if (LOGGER.isLoggable(Level.FINE)) {
StringBuilder message = new StringBuilder();
message.append("Received ").append(list.size()).append(" certificates from ").append(file);
for (X509Certificate certificate : list) {
message.append("\n ").append(certificate.getSubjectDN());
}
LOGGER.fine(message.toString());
}
return list;
}
} catch (AccessDeniedException t) {
LOGGER.warning("Not reading certificates from " + file + ": access denied");
return Collections.emptyList();
} catch (Throwable t) {
LOGGER.warning(renderExceptionMessage("Unable to read certificates from " + file, t));
return Collections.emptyList();
}
}