8211969: test/jdk/lib/security/CheckBlacklistedCerts.java searching for wrong paths

Reviewed-by: mullan
This commit is contained in:
Weijun Wang 2018-10-10 22:13:30 +08:00
parent a2d1b6b720
commit 1e887a901e

View File

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8011402 * @bug 8011402 8211969
* @summary Move blacklisting certificate logic from hard code to data * @summary Move blacklisting certificate logic from hard code to data
* @modules java.base/sun.security.util * @modules java.base/sun.security.util
*/ */
@ -60,26 +60,10 @@ public class CheckBlacklistedCerts {
Set<Certificate> blacklisted = new HashSet<>(); Set<Certificate> blacklisted = new HashSet<>();
// Assumes the full src is available // Assumes the full src is available
File[] blacklists = { File blacklist = new File(System.getProperty("test.src"),
new File(System.getProperty("test.src"), "../../../../make/data/blacklistedcertsconverter/blacklisted.certs.pem");
"../../../make/data/blacklistedcertsconverter/blacklisted.certs.pem"),
new File(System.getProperty("test.src"),
"../../../make/closed/data/blacklistedcertsconverter/blacklisted.certs.pem")
};
// Is this an OPENJDK build?
String prop = System.getProperty("java.runtime.name");
if (prop != null && prop.startsWith("OpenJDK")) {
System.out.println("This is a OpenJDK build.");
blacklists = Arrays.copyOf(blacklists, 1);
}
CertificateFactory cf = CertificateFactory.getInstance("X.509"); CertificateFactory cf = CertificateFactory.getInstance("X.509");
for (File blacklist: blacklists) {
System.out.print("Check for " + blacklist + ": ");
if (!blacklist.exists()) {
System.out.println("does not exist");
} else {
try (FileInputStream fis = new FileInputStream(blacklist)) { try (FileInputStream fis = new FileInputStream(blacklist)) {
Collection<? extends Certificate> certs Collection<? extends Certificate> certs
= cf.generateCertificates(fis); = cf.generateCertificates(fis);
@ -93,8 +77,6 @@ public class CheckBlacklistedCerts {
} }
} }
} }
}
}
// Check the blacklisted.certs file itself // Check the blacklisted.certs file itself
file = new File(home, "lib/security/blacklisted.certs"); file = new File(home, "lib/security/blacklisted.certs");