Skip to content

Commit

Permalink
Follow symbolic links.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakky54 committed Aug 4, 2023
1 parent f83605d commit eb602bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import nl.altindag.ssl.exception.GenericIOException;

import java.io.IOException;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -64,7 +65,7 @@ static List<Certificate> getCertificates() {
List<Certificate> certs = loadCertificate(path);
certificates.addAll(certs);
} else if (Files.isDirectory(path)) {
try(Stream<Path> files = Files.walk(path, 1)) {
try(Stream<Path> files = Files.walk(path, 1, FileVisitOption.FOLLOW_LINKS)) {
List<Certificate> certs = files
.filter(Files::isRegularFile)
.flatMap(file -> loadCertificate(file).stream())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,16 @@ void getCertificatesReturnsCertificatesWhenFileExistWithinDirectory() {
return true;
} else if ("isRegularFile".equals(methodName) && "/etc/ssl/certs".equals(path)) {
return false;
} else if ("isSymbolicLink".equals(methodName) && "/etc/ssl/certs".equals(path)) {
return false;
} else if ("isDirectory".equals(methodName) && "/etc/ssl/certs".equals(path)) {
return true;
} else if ("walk".equals(methodName)) {
return Stream.of(Paths.get("/etc/ssl/certs/some-certificate.pem"));
} else if ("isRegularFile".equals(methodName) && "/etc/ssl/certs/some-certificate.pem".equals(path)) {
return true;
} else if ("isSymbolicLink".equals(methodName) && "/etc/ssl/certs/some-certificate.pem".equals(path)) {
return true;
} else if ("exists".equals(methodName)) {
return false;
} else {
Expand Down

0 comments on commit eb602bd

Please sign in to comment.