1
1
/*
2
- * Copyright (c) 2013, 2020 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2013, 2021 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
35
35
import java .security .cert .*;
36
36
import java .util .*;
37
37
38
- public class CheckBlacklistedCerts {
38
+ public class CheckBlockedCerts {
39
39
public static void main (String [] args ) throws Exception {
40
40
41
41
String home = System .getProperty ("java.home" );
@@ -57,29 +57,30 @@ public static void main(String[] args) throws Exception {
57
57
}
58
58
59
59
// All certs in the pem files
60
- Set <Certificate > blacklisted = new HashSet <>();
60
+ Set <Certificate > blocked = new HashSet <>();
61
61
62
62
// Assumes the full src is available
63
- File blacklist = new File (System .getProperty ("test.src" ),
64
- "../../../../../make/data/blacklistedcertsconverter/blacklisted .certs.pem" );
63
+ File blockedCertsFile = new File (System .getProperty ("test.src" ),
64
+ "../../../../../make/data/blockedcertsconverter/blocked .certs.pem" );
65
65
66
66
CertificateFactory cf = CertificateFactory .getInstance ("X.509" );
67
- try (FileInputStream fis = new FileInputStream (blacklist )) {
67
+ try (FileInputStream fis = new FileInputStream (blockedCertsFile )) {
68
68
Collection <? extends Certificate > certs
69
69
= cf .generateCertificates (fis );
70
70
System .out .println (certs .size ());
71
71
for (Certificate c : certs ) {
72
- blacklisted .add (c );
72
+ blocked .add (c );
73
73
X509Certificate cert = ((X509Certificate )c );
74
74
if (!UntrustedCertificates .isUntrusted (cert )) {
75
- System .out .println (cert .getSubjectDN () + " is trusted" );
75
+ System .out .println (cert .getSubjectX500Principal () +
76
+ " is trusted" );
76
77
failed = true ;
77
78
}
78
79
}
79
80
}
80
81
81
- // Check the blacklisted .certs file itself
82
- file = new File (home , "lib/security/blacklisted .certs" );
82
+ // Check the blocked .certs file itself
83
+ file = new File (home , "lib/security/blocked .certs" );
83
84
System .out .print ("Check for " + file + ": " );
84
85
try (BufferedReader reader = new BufferedReader (
85
86
new InputStreamReader (new FileInputStream (file )))) {
@@ -100,11 +101,11 @@ public static void main(String[] args) throws Exception {
100
101
failed = true ;
101
102
}
102
103
// There are two unique fingerprints for each RSA certificate
103
- if (ccount != blacklisted .size () * 2
104
- && !blacklisted .isEmpty ()) {
105
- System .out .println ("Wrong blacklisted .certs size: "
104
+ if (ccount != blocked .size () * 2
105
+ && !blocked .isEmpty ()) {
106
+ System .out .println ("Wrong blocked .certs size: "
106
107
+ ccount + " fingerprints, "
107
- + blacklisted .size () + " certs" );
108
+ + blocked .size () + " certs" );
108
109
failed = true ;
109
110
}
110
111
}
0 commit comments