author | coffeys |
Tue, 20 Nov 2018 13:12:48 +0000 | |
changeset 52621 | f7309a1491d9 |
parent 49776 | 40a012dc4cee |
permissions | -rw-r--r-- |
2 | 1 |
/* |
43701
fe8c324ba97c
8160655: Fix denyAfter and usage types for security properties
ascarpino
parents:
39465
diff
changeset
|
2 |
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.security.provider.certpath; |
|
27 |
||
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
28 |
import java.io.IOException; |
2 | 29 |
import java.security.InvalidAlgorithmParameterException; |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
30 |
import java.security.cert.*; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
31 |
import java.util.*; |
52621
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
32 |
import java.util.concurrent.atomic.AtomicLong; |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
33 |
|
52621
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
34 |
import jdk.internal.event.X509ValidationEvent; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
35 |
import jdk.internal.event.EventHelper; |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
36 |
import sun.security.provider.certpath.PKIX.ValidatorParams; |
49776 | 37 |
import sun.security.validator.Validator; |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
38 |
import sun.security.x509.X509CertImpl; |
2 | 39 |
import sun.security.util.Debug; |
40 |
||
41 |
/** |
|
42 |
* This class implements the PKIX validation algorithm for certification |
|
43 |
* paths consisting exclusively of <code>X509Certificates</code>. It uses |
|
44 |
* the specified input parameter set (which must be a |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
45 |
* <code>PKIXParameters</code> object). |
2 | 46 |
* |
47 |
* @since 1.4 |
|
48 |
* @author Yassir Elley |
|
49 |
*/ |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
50 |
public final class PKIXCertPathValidator extends CertPathValidatorSpi { |
2 | 51 |
|
52 |
private static final Debug debug = Debug.getInstance("certpath"); |
|
52621
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
53 |
private static final AtomicLong validationCounter = new AtomicLong(); |
2 | 54 |
|
55 |
/** |
|
56 |
* Default constructor. |
|
57 |
*/ |
|
58 |
public PKIXCertPathValidator() {} |
|
59 |
||
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
60 |
@Override |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
61 |
public CertPathChecker engineGetRevocationChecker() { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
62 |
return new RevocationChecker(); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
63 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
64 |
|
2 | 65 |
/** |
66 |
* Validates a certification path consisting exclusively of |
|
67 |
* <code>X509Certificate</code>s using the PKIX validation algorithm, |
|
68 |
* which uses the specified input parameter set. |
|
69 |
* The input parameter set must be a <code>PKIXParameters</code> object. |
|
70 |
* |
|
71 |
* @param cp the X509 certification path |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
72 |
* @param params the input PKIX parameter set |
2 | 73 |
* @return the result |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
74 |
* @throws CertPathValidatorException if cert path does not validate. |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
75 |
* @throws InvalidAlgorithmParameterException if the specified |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
76 |
* parameters are inappropriate for this CertPathValidator |
2 | 77 |
*/ |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
78 |
@Override |
2 | 79 |
public CertPathValidatorResult engineValidate(CertPath cp, |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
80 |
CertPathParameters params) |
2 | 81 |
throws CertPathValidatorException, InvalidAlgorithmParameterException |
82 |
{ |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
83 |
ValidatorParams valParams = PKIX.checkParams(cp, params); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
84 |
return validate(valParams); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
85 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
86 |
|
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
87 |
private static PKIXCertPathValidatorResult validate(ValidatorParams params) |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
88 |
throws CertPathValidatorException |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
89 |
{ |
2 | 90 |
if (debug != null) |
91 |
debug.println("PKIXCertPathValidator.engineValidate()..."); |
|
92 |
||
93 |
// Retrieve the first certificate in the certpath |
|
94 |
// (to be used later in pre-screening) |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
95 |
AdaptableX509CertSelector selector = null; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
96 |
List<X509Certificate> certList = params.certificates(); |
2 | 97 |
if (!certList.isEmpty()) { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
98 |
selector = new AdaptableX509CertSelector(); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
99 |
X509Certificate firstCert = certList.get(0); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
100 |
// check trusted certificate's subject |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
101 |
selector.setSubject(firstCert.getIssuerX500Principal()); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
102 |
/* |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
103 |
* Facilitate certification path construction with authority |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
104 |
* key identifier and subject key identifier. |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
105 |
*/ |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
106 |
try { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
107 |
X509CertImpl firstCertImpl = X509CertImpl.toImpl(firstCert); |
22977
f8f315760941
8025708: Certificate Path Building problem with AKI serial number
mullan
parents:
19045
diff
changeset
|
108 |
selector.setSkiAndSerialNumber( |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
109 |
firstCertImpl.getAuthorityKeyIdentifierExtension()); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
110 |
} catch (CertificateException | IOException e) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
111 |
// ignore |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
112 |
} |
2 | 113 |
} |
114 |
||
115 |
CertPathValidatorException lastException = null; |
|
116 |
||
117 |
// We iterate through the set of trust anchors until we find |
|
118 |
// one that works at which time we stop iterating |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
119 |
for (TrustAnchor anchor : params.trustAnchors()) { |
2 | 120 |
X509Certificate trustedCert = anchor.getTrustedCert(); |
121 |
if (trustedCert != null) { |
|
122 |
// if this trust anchor is not worth trying, |
|
123 |
// we move on to the next one |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
124 |
if (selector != null && !selector.match(trustedCert)) { |
44920
5b66112437ba
8176457: Add verbose option to java.security.debug
ascarpino
parents:
44158
diff
changeset
|
125 |
if (debug != null && Debug.isVerbose()) { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
126 |
debug.println("NO - don't try this trustedCert"); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
127 |
} |
2 | 128 |
continue; |
129 |
} |
|
130 |
||
131 |
if (debug != null) { |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
132 |
debug.println("YES - try this trustedCert"); |
2 | 133 |
debug.println("anchor.getTrustedCert()." |
134 |
+ "getSubjectX500Principal() = " |
|
135 |
+ trustedCert.getSubjectX500Principal()); |
|
136 |
} |
|
137 |
} else { |
|
138 |
if (debug != null) { |
|
139 |
debug.println("PKIXCertPathValidator.engineValidate(): " |
|
140 |
+ "anchor.getTrustedCert() == null"); |
|
141 |
} |
|
142 |
} |
|
143 |
||
144 |
try { |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
145 |
return validate(anchor, params); |
2 | 146 |
} catch (CertPathValidatorException cpe) { |
147 |
// remember this exception |
|
148 |
lastException = cpe; |
|
149 |
} |
|
150 |
} |
|
151 |
||
152 |
// could not find a trust anchor that verified |
|
153 |
// (a) if we did a validation and it failed, use that exception |
|
154 |
if (lastException != null) { |
|
155 |
throw lastException; |
|
156 |
} |
|
157 |
// (b) otherwise, generate new exception |
|
158 |
throw new CertPathValidatorException |
|
1238
6d1f4b722acd
6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents:
2
diff
changeset
|
159 |
("Path does not chain with any of the trust anchors", |
6d1f4b722acd
6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents:
2
diff
changeset
|
160 |
null, null, -1, PKIXReason.NO_TRUST_ANCHOR); |
2 | 161 |
} |
162 |
||
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
163 |
private static PKIXCertPathValidatorResult validate(TrustAnchor anchor, |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
164 |
ValidatorParams params) |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
165 |
throws CertPathValidatorException |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
166 |
{ |
31688
42c9b194a469
8073894: Getting to the root of certificate chains
mullan
parents:
25859
diff
changeset
|
167 |
// check if anchor is untrusted |
42c9b194a469
8073894: Getting to the root of certificate chains
mullan
parents:
25859
diff
changeset
|
168 |
UntrustedChecker untrustedChecker = new UntrustedChecker(); |
42c9b194a469
8073894: Getting to the root of certificate chains
mullan
parents:
25859
diff
changeset
|
169 |
X509Certificate anchorCert = anchor.getTrustedCert(); |
42c9b194a469
8073894: Getting to the root of certificate chains
mullan
parents:
25859
diff
changeset
|
170 |
if (anchorCert != null) { |
42c9b194a469
8073894: Getting to the root of certificate chains
mullan
parents:
25859
diff
changeset
|
171 |
untrustedChecker.check(anchorCert); |
42c9b194a469
8073894: Getting to the root of certificate chains
mullan
parents:
25859
diff
changeset
|
172 |
} |
42c9b194a469
8073894: Getting to the root of certificate chains
mullan
parents:
25859
diff
changeset
|
173 |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
174 |
int certPathLen = params.certificates().size(); |
8163
d9bcc1208691
7011497: new CertPathValidatorException.BasicReason enum constant for constrained algorithm
xuelei
parents:
7040
diff
changeset
|
175 |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
176 |
// create PKIXCertPathCheckers |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
177 |
List<PKIXCertPathChecker> certPathCheckers = new ArrayList<>(); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
178 |
// add standard checkers that we will be using |
31688
42c9b194a469
8073894: Getting to the root of certificate chains
mullan
parents:
25859
diff
changeset
|
179 |
certPathCheckers.add(untrustedChecker); |
44158
49deb8a1ed3f
8176350: Usage constraints don't take effect when using PKIX
ascarpino
parents:
43701
diff
changeset
|
180 |
certPathCheckers.add(new AlgorithmChecker(anchor, null, params.date(), |
49deb8a1ed3f
8176350: Usage constraints don't take effect when using PKIX
ascarpino
parents:
43701
diff
changeset
|
181 |
params.timestamp(), params.variant())); |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
182 |
certPathCheckers.add(new KeyChecker(certPathLen, |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
183 |
params.targetCertConstraints())); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
184 |
certPathCheckers.add(new ConstraintsChecker(certPathLen)); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
185 |
PolicyNodeImpl rootNode = |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
186 |
new PolicyNodeImpl(null, PolicyChecker.ANY_POLICY, null, false, |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
187 |
Collections.singleton(PolicyChecker.ANY_POLICY), |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
188 |
false); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
189 |
PolicyChecker pc = new PolicyChecker(params.initialPolicies(), |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
190 |
certPathLen, |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
191 |
params.explicitPolicyRequired(), |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
192 |
params.policyMappingInhibited(), |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
193 |
params.anyPolicyInhibited(), |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
194 |
params.policyQualifiersRejected(), |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
195 |
rootNode); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
196 |
certPathCheckers.add(pc); |
49776 | 197 |
|
198 |
// the time that the certificate validity period should be |
|
199 |
// checked against |
|
200 |
Date timeToCheck = null; |
|
201 |
// use timestamp if checking signed code that is timestamped, otherwise |
|
202 |
// use date parameter from PKIXParameters |
|
203 |
if ((params.variant() == Validator.VAR_CODE_SIGNING || |
|
204 |
params.variant() == Validator.VAR_PLUGIN_CODE_SIGNING) && |
|
205 |
params.timestamp() != null) { |
|
206 |
timeToCheck = params.timestamp().getTimestamp(); |
|
207 |
} else { |
|
208 |
timeToCheck = params.date(); |
|
209 |
} |
|
210 |
BasicChecker bc = new BasicChecker(anchor, timeToCheck, |
|
211 |
params.sigProvider(), false); |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
212 |
certPathCheckers.add(bc); |
2 | 213 |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
214 |
boolean revCheckerAdded = false; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
215 |
List<PKIXCertPathChecker> checkers = params.certPathCheckers(); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
216 |
for (PKIXCertPathChecker checker : checkers) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
217 |
if (checker instanceof PKIXRevocationChecker) { |
19045
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
12861
diff
changeset
|
218 |
if (revCheckerAdded) { |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
12861
diff
changeset
|
219 |
throw new CertPathValidatorException( |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
12861
diff
changeset
|
220 |
"Only one PKIXRevocationChecker can be specified"); |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
12861
diff
changeset
|
221 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
222 |
revCheckerAdded = true; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
223 |
// if it's our own, initialize it |
19045
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
12861
diff
changeset
|
224 |
if (checker instanceof RevocationChecker) { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
225 |
((RevocationChecker)checker).init(anchor, params); |
19045
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
12861
diff
changeset
|
226 |
} |
8163
d9bcc1208691
7011497: new CertPathValidatorException.BasicReason enum constant for constrained algorithm
xuelei
parents:
7040
diff
changeset
|
227 |
} |
2 | 228 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
229 |
// only add a RevocationChecker if revocation is enabled and |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
230 |
// a PKIXRevocationChecker has not already been added |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
231 |
if (params.revocationEnabled() && !revCheckerAdded) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
232 |
certPathCheckers.add(new RevocationChecker(anchor, params)); |
2 | 233 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
234 |
// add user-specified checkers |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
235 |
certPathCheckers.addAll(checkers); |
2 | 236 |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
237 |
PKIXMasterCertPathValidator.validate(params.certPath(), |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
238 |
params.certificates(), |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
239 |
certPathCheckers); |
2 | 240 |
|
52621
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
241 |
X509ValidationEvent xve = new X509ValidationEvent(); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
242 |
if (xve.shouldCommit() || EventHelper.isLoggingSecurity()) { |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
243 |
int[] certIds = params.certificates().stream() |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
244 |
.mapToInt(x -> x.hashCode()) |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
245 |
.toArray(); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
246 |
int anchorCertId = |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
247 |
anchor.getTrustedCert().hashCode(); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
248 |
if (xve.shouldCommit()) { |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
249 |
xve.certificateId = anchorCertId; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
250 |
int certificatePos = 1; //anchor cert |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
251 |
xve.certificatePosition = certificatePos; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
252 |
xve.validationCounter = validationCounter.incrementAndGet(); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
253 |
xve.commit(); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
254 |
// now, iterate through remaining |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
255 |
for (int id : certIds) { |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
256 |
xve.certificateId = id; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
257 |
xve.certificatePosition = ++certificatePos; |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
258 |
xve.commit(); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
259 |
|
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
260 |
} |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
261 |
} |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
262 |
if (EventHelper.isLoggingSecurity()) { |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
263 |
EventHelper.logX509ValidationEvent(anchorCertId, certIds); |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
264 |
} |
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
265 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
266 |
return new PKIXCertPathValidatorResult(anchor, pc.getPolicyTree(), |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
267 |
bc.getPublicKey()); |
2 | 268 |
} |
52621
f7309a1491d9
8148188: Enhance the security libraries to record events of interest
coffeys
parents:
49776
diff
changeset
|
269 |
|
2 | 270 |
} |