8211969: test/jdk/lib/security/CheckBlacklistedCerts.java searching for wrong paths
Reviewed-by: mullan
This commit is contained in:
parent
a2d1b6b720
commit
1e887a901e
@ -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,38 +60,20 @@ 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) {
|
try (FileInputStream fis = new FileInputStream(blacklist)) {
|
||||||
System.out.print("Check for " + blacklist + ": ");
|
Collection<? extends Certificate> certs
|
||||||
if (!blacklist.exists()) {
|
= cf.generateCertificates(fis);
|
||||||
System.out.println("does not exist");
|
System.out.println(certs.size());
|
||||||
} else {
|
for (Certificate c: certs) {
|
||||||
try (FileInputStream fis = new FileInputStream(blacklist)) {
|
blacklisted.add(c);
|
||||||
Collection<? extends Certificate> certs
|
X509Certificate cert = ((X509Certificate)c);
|
||||||
= cf.generateCertificates(fis);
|
if (!UntrustedCertificates.isUntrusted(cert)) {
|
||||||
System.out.println(certs.size());
|
System.out.println(cert.getSubjectDN() + " is trusted");
|
||||||
for (Certificate c: certs) {
|
failed = true;
|
||||||
blacklisted.add(c);
|
|
||||||
X509Certificate cert = ((X509Certificate)c);
|
|
||||||
if (!UntrustedCertificates.isUntrusted(cert)) {
|
|
||||||
System.out.println(cert.getSubjectDN() + " is trusted");
|
|
||||||
failed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user