Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions test/reproducers/emudra/CheckCerts.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import javax.net.ssl.*;
import java.security.*;
import java.security.cert.*;
import java.util.*;

import static java.lang.System.out;

Expand Down Expand Up @@ -65,7 +66,7 @@ public static void main(String ... args) throws Exception {
TrustManagerFactory tmf
= TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init((KeyStore)null);
boolean badroots = false;
ArrayList<String> badroots = new ArrayList<>();

for (String r : ROOTS) {
for (TrustManager tm : tmf.getTrustManagers()) {
Expand All @@ -74,15 +75,15 @@ public static void main(String ... args) throws Exception {
String nm = cert.getSubjectX500Principal().getName();
if (nm.contains("CN=" + r)) {
out.format("BAD ROOT: %s%n", nm);
badroots = true;
badroots.add(nm);
}
}
}
}
}

if (badroots)
throw new RuntimeException("Found bad roots");
if (badroots.size() > 0)
throw new RuntimeException(String.format("Found bad roots [%s]", String.join(";", badroots)));
else
out.format("No bad root certificates found%n");

Expand Down
9 changes: 5 additions & 4 deletions test/reproducers/emudra/CheckCertsStrict.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import javax.net.ssl.*;
import java.security.*;
import java.security.cert.*;
import java.util.*;

import static java.lang.System.out;

Expand All @@ -64,7 +65,7 @@ public static void main(String ... args) throws Exception {
TrustManagerFactory tmf
= TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init((KeyStore)null);
boolean badroots = false;
ArrayList<String> badroots = new ArrayList<>();

for (String r : ROOTS) {
for (TrustManager tm : tmf.getTrustManagers()) {
Expand All @@ -73,15 +74,15 @@ public static void main(String ... args) throws Exception {
String nm = cert.getSubjectX500Principal().getName();
if (nm.contains("CN=" + r)) {
out.format("BAD ROOT: %s%n", nm);
badroots = true;
badroots.add(nm);
}
}
}
}
}

if (badroots)
throw new RuntimeException("Found bad roots");
if (badroots.size() > 0)
throw new RuntimeException(String.format("Found bad roots [%s]", String.join(";", badroots)));
else
out.format("No bad root certificates found%n");

Expand Down