author | mullan |
Thu, 25 Jul 2013 10:58:00 -0400 | |
changeset 19045 | bc9a25fff6c5 |
parent 17729 | 90a2bf654c4f |
child 19820 | 9ee1d7810f50 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
17044
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
2 |
* Copyright (c) 2003, 2013, 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 |
||
28 |
import java.io.*; |
|
29 |
import java.security.*; |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
30 |
import java.security.cert.CertificateException; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
31 |
import java.security.cert.CertificateParsingException; |
2 | 32 |
import java.security.cert.CertPathValidatorException; |
19045
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
33 |
import java.security.cert.CertPathValidatorException.BasicReason; |
2 | 34 |
import java.security.cert.CRLReason; |
7040
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
35 |
import java.security.cert.TrustAnchor; |
2 | 36 |
import java.security.cert.X509Certificate; |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
37 |
import java.util.ArrayList; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
38 |
import java.util.Arrays; |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
39 |
import java.util.Collections; |
2 | 40 |
import java.util.Date; |
41 |
import java.util.HashMap; |
|
42 |
import java.util.List; |
|
43 |
import java.util.Map; |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
44 |
import javax.security.auth.x500.X500Principal; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
45 |
|
2 | 46 |
import sun.misc.HexDumpEncoder; |
17044
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
47 |
import sun.security.action.GetIntegerAction; |
2 | 48 |
import sun.security.x509.*; |
49 |
import sun.security.util.*; |
|
50 |
||
51 |
/** |
|
52 |
* This class is used to process an OCSP response. |
|
53 |
* The OCSP Response is defined |
|
54 |
* in RFC 2560 and the ASN.1 encoding is as follows: |
|
55 |
* <pre> |
|
56 |
* |
|
57 |
* OCSPResponse ::= SEQUENCE { |
|
58 |
* responseStatus OCSPResponseStatus, |
|
59 |
* responseBytes [0] EXPLICIT ResponseBytes OPTIONAL } |
|
60 |
* |
|
61 |
* OCSPResponseStatus ::= ENUMERATED { |
|
62 |
* successful (0), --Response has valid confirmations |
|
63 |
* malformedRequest (1), --Illegal confirmation request |
|
64 |
* internalError (2), --Internal error in issuer |
|
65 |
* tryLater (3), --Try again later |
|
66 |
* --(4) is not used |
|
67 |
* sigRequired (5), --Must sign the request |
|
68 |
* unauthorized (6) --Request unauthorized |
|
69 |
* } |
|
70 |
* |
|
71 |
* ResponseBytes ::= SEQUENCE { |
|
72 |
* responseType OBJECT IDENTIFIER, |
|
73 |
* response OCTET STRING } |
|
74 |
* |
|
75 |
* BasicOCSPResponse ::= SEQUENCE { |
|
76 |
* tbsResponseData ResponseData, |
|
77 |
* signatureAlgorithm AlgorithmIdentifier, |
|
78 |
* signature BIT STRING, |
|
79 |
* certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } |
|
80 |
* |
|
81 |
* The value for signature SHALL be computed on the hash of the DER |
|
82 |
* encoding ResponseData. |
|
83 |
* |
|
84 |
* ResponseData ::= SEQUENCE { |
|
85 |
* version [0] EXPLICIT Version DEFAULT v1, |
|
86 |
* responderID ResponderID, |
|
87 |
* producedAt GeneralizedTime, |
|
88 |
* responses SEQUENCE OF SingleResponse, |
|
89 |
* responseExtensions [1] EXPLICIT Extensions OPTIONAL } |
|
90 |
* |
|
91 |
* ResponderID ::= CHOICE { |
|
92 |
* byName [1] Name, |
|
93 |
* byKey [2] KeyHash } |
|
94 |
* |
|
95 |
* KeyHash ::= OCTET STRING -- SHA-1 hash of responder's public key |
|
96 |
* (excluding the tag and length fields) |
|
97 |
* |
|
98 |
* SingleResponse ::= SEQUENCE { |
|
99 |
* certID CertID, |
|
100 |
* certStatus CertStatus, |
|
101 |
* thisUpdate GeneralizedTime, |
|
102 |
* nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, |
|
103 |
* singleExtensions [1] EXPLICIT Extensions OPTIONAL } |
|
104 |
* |
|
105 |
* CertStatus ::= CHOICE { |
|
106 |
* good [0] IMPLICIT NULL, |
|
107 |
* revoked [1] IMPLICIT RevokedInfo, |
|
108 |
* unknown [2] IMPLICIT UnknownInfo } |
|
109 |
* |
|
110 |
* RevokedInfo ::= SEQUENCE { |
|
111 |
* revocationTime GeneralizedTime, |
|
112 |
* revocationReason [0] EXPLICIT CRLReason OPTIONAL } |
|
113 |
* |
|
114 |
* UnknownInfo ::= NULL -- this can be replaced with an enumeration |
|
115 |
* |
|
116 |
* </pre> |
|
117 |
* |
|
118 |
* @author Ram Marti |
|
119 |
*/ |
|
120 |
||
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
121 |
public final class OCSPResponse { |
2 | 122 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
123 |
public enum ResponseStatus { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
124 |
SUCCESSFUL, // Response has valid confirmations |
19045
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
125 |
MALFORMED_REQUEST, // Illegal request |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
126 |
INTERNAL_ERROR, // Internal error in responder |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
127 |
TRY_LATER, // Try again later |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
128 |
UNUSED, // is not used |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
129 |
SIG_REQUIRED, // Must sign the request |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
130 |
UNAUTHORIZED // Request unauthorized |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
131 |
}; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
132 |
private static ResponseStatus[] rsvalues = ResponseStatus.values(); |
2 | 133 |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
134 |
private static final Debug debug = Debug.getInstance("certpath"); |
2 | 135 |
private static final boolean dump = false; |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
136 |
private static final ObjectIdentifier OCSP_BASIC_RESPONSE_OID = |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
137 |
ObjectIdentifier.newInternal(new int[] { 1, 3, 6, 1, 5, 5, 7, 48, 1, 1}); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
138 |
private static final int CERT_STATUS_GOOD = 0; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
139 |
private static final int CERT_STATUS_REVOKED = 1; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
140 |
private static final int CERT_STATUS_UNKNOWN = 2; |
2 | 141 |
|
142 |
// ResponderID CHOICE tags |
|
143 |
private static final int NAME_TAG = 1; |
|
144 |
private static final int KEY_TAG = 2; |
|
145 |
||
146 |
// Object identifier for the OCSPSigning key purpose |
|
147 |
private static final String KP_OCSP_SIGNING_OID = "1.3.6.1.5.5.7.3.9"; |
|
148 |
||
17044
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
149 |
// Default maximum clock skew in milliseconds (15 minutes) |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
150 |
// allowed when checking validity of OCSP responses |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
151 |
private static final int DEFAULT_MAX_CLOCK_SKEW = 900000; |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
152 |
|
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
153 |
/** |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
154 |
* Integer value indicating the maximum allowable clock skew, in seconds, |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
155 |
* to be used for the OCSP check. |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
156 |
*/ |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
157 |
private static final int MAX_CLOCK_SKEW = initializeClockSkew(); |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
158 |
|
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
159 |
/** |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
160 |
* Initialize the maximum allowable clock skew by getting the OCSP |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
161 |
* clock skew system property. If the property has not been set, or if its |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
162 |
* value is negative, set the skew to the default. |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
163 |
*/ |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
164 |
private static int initializeClockSkew() { |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
165 |
Integer tmp = java.security.AccessController.doPrivileged( |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
166 |
new GetIntegerAction("com.sun.security.ocsp.clockSkew")); |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
167 |
if (tmp == null || tmp < 0) { |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
168 |
return DEFAULT_MAX_CLOCK_SKEW; |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
169 |
} |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
170 |
// Convert to milliseconds, as the system property will be |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
171 |
// specified in seconds |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
172 |
return tmp * 1000; |
c67bf062ca30
8013228: Create new system properties to control allowable OCSP clock skew and CRL connection timeout
mullan
parents:
13402
diff
changeset
|
173 |
} |
1567
58ef474069d7
6744888: OCSP validation code should permit some clock skew when checking validity of OCSP responses
mullan
parents:
2
diff
changeset
|
174 |
|
2 | 175 |
// an array of all of the CRLReasons (used in SingleResponse) |
176 |
private static CRLReason[] values = CRLReason.values(); |
|
177 |
||
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
178 |
private final ResponseStatus responseStatus; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
179 |
private final Map<CertId, SingleResponse> singleResponseMap; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
180 |
private final List<X509CertImpl> certs; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
181 |
private final AlgorithmId sigAlgId; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
182 |
private final byte[] signature; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
183 |
private final byte[] tbsResponseData; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
184 |
private final byte[] responseNonce; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
185 |
|
2 | 186 |
/* |
187 |
* Create an OCSP response from its ASN.1 DER encoding. |
|
188 |
*/ |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
189 |
OCSPResponse(byte[] bytes) throws IOException { |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
190 |
if (dump) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
191 |
HexDumpEncoder hexEnc = new HexDumpEncoder(); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
192 |
System.out.println("OCSPResponse bytes are..."); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
193 |
System.out.println(hexEnc.encode(bytes)); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
194 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
195 |
DerValue der = new DerValue(bytes); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
196 |
if (der.tag != DerValue.tag_Sequence) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
197 |
throw new IOException("Bad encoding in OCSP response: " + |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
198 |
"expected ASN.1 SEQUENCE tag."); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
199 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
200 |
DerInputStream derIn = der.getData(); |
2 | 201 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
202 |
// responseStatus |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
203 |
int status = derIn.getEnumerated(); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
204 |
if (status >= 0 && status < rsvalues.length) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
205 |
responseStatus = rsvalues[status]; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
206 |
} else { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
207 |
// unspecified responseStatus |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
208 |
throw new IOException("Unknown OCSPResponse status: " + status); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
209 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
210 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
211 |
debug.println("OCSP response status: " + responseStatus); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
212 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
213 |
if (responseStatus != ResponseStatus.SUCCESSFUL) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
214 |
// no need to continue, responseBytes are not set. |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
215 |
singleResponseMap = Collections.emptyMap(); |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
216 |
certs = Collections.<X509CertImpl>emptyList(); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
217 |
sigAlgId = null; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
218 |
signature = null; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
219 |
tbsResponseData = null; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
220 |
responseNonce = null; |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
221 |
return; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
222 |
} |
2 | 223 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
224 |
// responseBytes |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
225 |
der = derIn.getDerValue(); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
226 |
if (!der.isContextSpecific((byte)0)) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
227 |
throw new IOException("Bad encoding in responseBytes element " + |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
228 |
"of OCSP response: expected ASN.1 context specific tag 0."); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
229 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
230 |
DerValue tmp = der.data.getDerValue(); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
231 |
if (tmp.tag != DerValue.tag_Sequence) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
232 |
throw new IOException("Bad encoding in responseBytes element " + |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
233 |
"of OCSP response: expected ASN.1 SEQUENCE tag."); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
234 |
} |
2 | 235 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
236 |
// responseType |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
237 |
derIn = tmp.data; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
238 |
ObjectIdentifier responseType = derIn.getOID(); |
10336
0bb1999251f8
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
7040
diff
changeset
|
239 |
if (responseType.equals((Object)OCSP_BASIC_RESPONSE_OID)) { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
240 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
241 |
debug.println("OCSP response type: basic"); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
242 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
243 |
} else { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
244 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
245 |
debug.println("OCSP response type: " + responseType); |
2 | 246 |
} |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
247 |
throw new IOException("Unsupported OCSP response type: " + |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
248 |
responseType); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
249 |
} |
2 | 250 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
251 |
// BasicOCSPResponse |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
252 |
DerInputStream basicOCSPResponse = |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
253 |
new DerInputStream(derIn.getOctetString()); |
2 | 254 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
255 |
DerValue[] seqTmp = basicOCSPResponse.getSequence(2); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
256 |
if (seqTmp.length < 3) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
257 |
throw new IOException("Unexpected BasicOCSPResponse value"); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
258 |
} |
2 | 259 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
260 |
DerValue responseData = seqTmp[0]; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
261 |
|
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
262 |
// Need the DER encoded ResponseData to verify the signature later |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
263 |
tbsResponseData = seqTmp[0].toByteArray(); |
2 | 264 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
265 |
// tbsResponseData |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
266 |
if (responseData.tag != DerValue.tag_Sequence) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
267 |
throw new IOException("Bad encoding in tbsResponseData " + |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
268 |
"element of OCSP response: expected ASN.1 SEQUENCE tag."); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
269 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
270 |
DerInputStream seqDerIn = responseData.data; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
271 |
DerValue seq = seqDerIn.getDerValue(); |
2 | 272 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
273 |
// version |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
274 |
if (seq.isContextSpecific((byte)0)) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
275 |
// seq[0] is version |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
276 |
if (seq.isConstructed() && seq.isContextSpecific()) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
277 |
//System.out.println ("version is available"); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
278 |
seq = seq.data.getDerValue(); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
279 |
int version = seq.getInteger(); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
280 |
if (seq.data.available() != 0) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
281 |
throw new IOException("Bad encoding in version " + |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
282 |
" element of OCSP response: bad format"); |
2 | 283 |
} |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
284 |
seq = seqDerIn.getDerValue(); |
2 | 285 |
} |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
286 |
} |
2 | 287 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
288 |
// responderID |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
289 |
short tag = (byte)(seq.tag & 0x1f); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
290 |
if (tag == NAME_TAG) { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
291 |
if (debug != null) { |
13402
794d9fb379d2
7179715: OCSP revocation checking fails if the signer certificate is identified using the key ID
mullan
parents:
12860
diff
changeset
|
292 |
X500Principal responderName = |
794d9fb379d2
7179715: OCSP revocation checking fails if the signer certificate is identified using the key ID
mullan
parents:
12860
diff
changeset
|
293 |
new X500Principal(seq.getData().toByteArray()); |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
294 |
debug.println("OCSP Responder name: " + responderName); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
295 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
296 |
} else if (tag == KEY_TAG) { |
13402
794d9fb379d2
7179715: OCSP revocation checking fails if the signer certificate is identified using the key ID
mullan
parents:
12860
diff
changeset
|
297 |
if (debug != null) { |
794d9fb379d2
7179715: OCSP revocation checking fails if the signer certificate is identified using the key ID
mullan
parents:
12860
diff
changeset
|
298 |
byte[] responderKey = seq.getData().getOctetString(); |
794d9fb379d2
7179715: OCSP revocation checking fails if the signer certificate is identified using the key ID
mullan
parents:
12860
diff
changeset
|
299 |
debug.println("OCSP Responder key: " + |
794d9fb379d2
7179715: OCSP revocation checking fails if the signer certificate is identified using the key ID
mullan
parents:
12860
diff
changeset
|
300 |
Debug.toString(responderKey)); |
794d9fb379d2
7179715: OCSP revocation checking fails if the signer certificate is identified using the key ID
mullan
parents:
12860
diff
changeset
|
301 |
} |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
302 |
} else { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
303 |
throw new IOException("Bad encoding in responderID element of " + |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
304 |
"OCSP response: expected ASN.1 context specific tag 0 or 1"); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
305 |
} |
2 | 306 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
307 |
// producedAt |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
308 |
seq = seqDerIn.getDerValue(); |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
309 |
if (debug != null) { |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
310 |
Date producedAtDate = seq.getGeneralizedTime(); |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
311 |
debug.println("OCSP response produced at: " + producedAtDate); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
312 |
} |
2 | 313 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
314 |
// responses |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
315 |
DerValue[] singleResponseDer = seqDerIn.getSequence(1); |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
316 |
singleResponseMap = new HashMap<>(singleResponseDer.length); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
317 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
318 |
debug.println("OCSP number of SingleResponses: " |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
319 |
+ singleResponseDer.length); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
320 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
321 |
for (int i = 0; i < singleResponseDer.length; i++) { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
322 |
SingleResponse singleResponse = |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
323 |
new SingleResponse(singleResponseDer[i]); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
324 |
singleResponseMap.put(singleResponse.getCertId(), singleResponse); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
325 |
} |
2 | 326 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
327 |
// responseExtensions |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
328 |
byte[] nonce = null; |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
329 |
if (seqDerIn.available() > 0) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
330 |
seq = seqDerIn.getDerValue(); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
331 |
if (seq.isContextSpecific((byte)1)) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
332 |
DerValue[] responseExtDer = seq.data.getSequence(3); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
333 |
for (int i = 0; i < responseExtDer.length; i++) { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
334 |
Extension ext = new Extension(responseExtDer[i]); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
335 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
336 |
debug.println("OCSP extension: " + ext); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
337 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
338 |
// Only the NONCE extension is recognized |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
339 |
if (ext.getExtensionId().equals((Object) |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
340 |
OCSP.NONCE_EXTENSION_OID)) |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
341 |
{ |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
342 |
nonce = ext.getExtensionValue(); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
343 |
} else if (ext.isCritical()) { |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
344 |
throw new IOException( |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
345 |
"Unsupported OCSP critical extension: " + |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
346 |
ext.getExtensionId()); |
2 | 347 |
} |
348 |
} |
|
349 |
} |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
350 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
351 |
responseNonce = nonce; |
2 | 352 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
353 |
// signatureAlgorithmId |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
354 |
sigAlgId = AlgorithmId.parse(seqTmp[1]); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
355 |
|
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
356 |
// signature |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
357 |
signature = seqTmp[2].getBitString(); |
2 | 358 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
359 |
// if seq[3] is available , then it is a sequence of certificates |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
360 |
if (seqTmp.length > 3) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
361 |
// certs are available |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
362 |
DerValue seqCert = seqTmp[3]; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
363 |
if (!seqCert.isContextSpecific((byte)0)) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
364 |
throw new IOException("Bad encoding in certs element of " + |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
365 |
"OCSP response: expected ASN.1 context specific tag 0."); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
366 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
367 |
DerValue[] derCerts = seqCert.getData().getSequence(3); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
368 |
certs = new ArrayList<X509CertImpl>(derCerts.length); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
369 |
try { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
370 |
for (int i = 0; i < derCerts.length; i++) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
371 |
certs.add(new X509CertImpl(derCerts[i].toByteArray())); |
2 | 372 |
} |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
373 |
} catch (CertificateException ce) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
374 |
throw new IOException("Bad encoding in X509 Certificate", ce); |
2 | 375 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
376 |
} else { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
377 |
certs = Collections.<X509CertImpl>emptyList(); |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
378 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
379 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
380 |
|
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
381 |
void verify(List<CertId> certIds, X509Certificate responderCert, |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
382 |
Date date, byte[] nonce) |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
383 |
throws CertPathValidatorException |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
384 |
{ |
19045
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
385 |
switch (responseStatus) { |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
386 |
case SUCCESSFUL: |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
387 |
break; |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
388 |
case UNAUTHORIZED: |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
389 |
case TRY_LATER: |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
390 |
case INTERNAL_ERROR: |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
391 |
throw new CertPathValidatorException( |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
392 |
"OCSP response error: " + responseStatus, null, null, -1, |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
393 |
BasicReason.UNDETERMINED_REVOCATION_STATUS); |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
394 |
default: |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
395 |
throw new CertPathValidatorException("OCSP response error: " + |
bc9a25fff6c5
8010748: Add PKIXRevocationChecker NO_FALLBACK option and improve SOFT_FAIL option
mullan
parents:
17729
diff
changeset
|
396 |
responseStatus); |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
397 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
398 |
|
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
399 |
// Check that the response includes a response for all of the |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
400 |
// certs that were supplied in the request |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
401 |
for (CertId certId : certIds) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
402 |
SingleResponse sr = getSingleResponse(certId); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
403 |
if (sr == null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
404 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
405 |
debug.println("No response found for CertId: " + certId); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
406 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
407 |
throw new CertPathValidatorException( |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
408 |
"OCSP response does not include a response for a " + |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
409 |
"certificate supplied in the OCSP request"); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
410 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
411 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
412 |
debug.println("Status of certificate (with serial number " + |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
413 |
certId.getSerialNumber() + ") is: " + sr.getCertStatus()); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
414 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
415 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
416 |
|
2 | 417 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
418 |
// Check whether the cert returned by the responder is trusted |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
419 |
if (!certs.isEmpty()) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
420 |
X509CertImpl cert = certs.get(0); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
421 |
// First check if the cert matches the expected responder cert |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
422 |
if (cert.equals(responderCert)) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
423 |
// cert is trusted, now verify the signed response |
2 | 424 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
425 |
// Next check if the cert was issued by the responder cert |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
426 |
// which was set locally. |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
427 |
} else if (cert.getIssuerX500Principal().equals( |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
428 |
responderCert.getSubjectX500Principal())) { |
2 | 429 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
430 |
// Check for the OCSPSigning key purpose |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
431 |
try { |
2 | 432 |
List<String> keyPurposes = cert.getExtendedKeyUsage(); |
433 |
if (keyPurposes == null || |
|
434 |
!keyPurposes.contains(KP_OCSP_SIGNING_OID)) { |
|
435 |
throw new CertPathValidatorException( |
|
436 |
"Responder's certificate not valid for signing " + |
|
437 |
"OCSP responses"); |
|
438 |
} |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
439 |
} catch (CertificateParsingException cpe) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
440 |
// assume cert is not valid for signing |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
441 |
throw new CertPathValidatorException( |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
442 |
"Responder's certificate not valid for signing " + |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
443 |
"OCSP responses", cpe); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
444 |
} |
2281
34fd38495efa
6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
1639
diff
changeset
|
445 |
|
7040
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
446 |
// Check algorithm constraints specified in security property |
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
447 |
// "jdk.certpath.disabledAlgorithms". |
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
448 |
AlgorithmChecker algChecker = new AlgorithmChecker( |
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
449 |
new TrustAnchor(responderCert, null)); |
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
450 |
algChecker.init(false); |
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
451 |
algChecker.check(cert, Collections.<String>emptySet()); |
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
452 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
453 |
// check the validity |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
454 |
try { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
455 |
if (date == null) { |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
456 |
cert.checkValidity(); |
2281
34fd38495efa
6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
1639
diff
changeset
|
457 |
} else { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
458 |
cert.checkValidity(date); |
2281
34fd38495efa
6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
1639
diff
changeset
|
459 |
} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
460 |
} catch (CertificateException e) { |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
461 |
throw new CertPathValidatorException( |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
462 |
"Responder's certificate not within the " + |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
463 |
"validity period", e); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
464 |
} |
2281
34fd38495efa
6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
1639
diff
changeset
|
465 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
466 |
// check for revocation |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
467 |
// |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
468 |
// A CA may specify that an OCSP client can trust a |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
469 |
// responder for the lifetime of the responder's |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
470 |
// certificate. The CA does so by including the |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
471 |
// extension id-pkix-ocsp-nocheck. |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
472 |
// |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
473 |
Extension noCheck = |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
474 |
cert.getExtension(PKIXExtensions.OCSPNoCheck_Id); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
475 |
if (noCheck != null) { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
476 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
477 |
debug.println("Responder's certificate includes " + |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
478 |
"the extension id-pkix-ocsp-nocheck."); |
2 | 479 |
} |
2281
34fd38495efa
6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
1639
diff
changeset
|
480 |
} else { |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
481 |
// we should do the revocation checking of the |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
482 |
// authorized responder in a future update. |
2 | 483 |
} |
484 |
||
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
485 |
// verify the signature |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
486 |
try { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
487 |
cert.verify(responderCert.getPublicKey()); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
488 |
responderCert = cert; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
489 |
// cert is trusted, now verify the signed response |
2 | 490 |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
491 |
} catch (GeneralSecurityException e) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
492 |
responderCert = null; |
2 | 493 |
} |
494 |
} else { |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
495 |
throw new CertPathValidatorException( |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
496 |
"Responder's certificate is not authorized to sign " + |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
497 |
"OCSP responses"); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
498 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
499 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
500 |
|
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
501 |
// Confirm that the signed response was generated using the public |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
502 |
// key from the trusted responder cert |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
503 |
if (responderCert != null) { |
7040
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
504 |
// Check algorithm constraints specified in security property |
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
505 |
// "jdk.certpath.disabledAlgorithms". |
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
506 |
AlgorithmChecker.check(responderCert.getPublicKey(), sigAlgId); |
659824c2a550
6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
5506
diff
changeset
|
507 |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
508 |
if (!verifySignature(responderCert)) { |
2 | 509 |
throw new CertPathValidatorException( |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
510 |
"Error verifying OCSP Response's signature"); |
2 | 511 |
} |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
512 |
} else { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
513 |
// Need responder's cert in order to verify the signature |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
514 |
throw new CertPathValidatorException( |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
515 |
"Unable to verify OCSP Response's signature"); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
516 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
517 |
|
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
518 |
// Check freshness of OCSPResponse |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
519 |
if (nonce != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
520 |
if (responseNonce != null && !Arrays.equals(nonce, responseNonce)) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
521 |
throw new CertPathValidatorException("Nonces don't match"); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
522 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
523 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
524 |
|
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
525 |
long now = (date == null) ? System.currentTimeMillis() : date.getTime(); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
526 |
Date nowPlusSkew = new Date(now + MAX_CLOCK_SKEW); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
527 |
Date nowMinusSkew = new Date(now - MAX_CLOCK_SKEW); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
528 |
for (SingleResponse sr : singleResponseMap.values()) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
529 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
530 |
String until = ""; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
531 |
if (sr.nextUpdate != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
532 |
until = " until " + sr.nextUpdate; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
533 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
534 |
debug.println("Response's validity interval is from " + |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
535 |
sr.thisUpdate + until); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
536 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
537 |
|
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
538 |
// Check that the test date is within the validity interval |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
539 |
if ((sr.thisUpdate != null && nowPlusSkew.before(sr.thisUpdate)) || |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
540 |
(sr.nextUpdate != null && nowMinusSkew.after(sr.nextUpdate))) |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
541 |
{ |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
542 |
throw new CertPathValidatorException( |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
543 |
"Response is unreliable: its validity " + |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
544 |
"interval is out-of-date"); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
545 |
} |
2 | 546 |
} |
547 |
} |
|
548 |
||
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
549 |
/** |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
550 |
* Returns the OCSP ResponseStatus. |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
551 |
*/ |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
552 |
ResponseStatus getResponseStatus() { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
553 |
return responseStatus; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
554 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
555 |
|
2 | 556 |
/* |
557 |
* Verify the signature of the OCSP response. |
|
558 |
* The responder's cert is implicitly trusted. |
|
559 |
*/ |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
560 |
private boolean verifySignature(X509Certificate cert) |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
561 |
throws CertPathValidatorException { |
2 | 562 |
|
563 |
try { |
|
564 |
Signature respSignature = Signature.getInstance(sigAlgId.getName()); |
|
17729
90a2bf654c4f
7174966: With OCSP enabled on Java 7 get error 'Wrong key usage' with Comodo certificate
vinnie
parents:
17044
diff
changeset
|
565 |
respSignature.initVerify(cert.getPublicKey()); |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
566 |
respSignature.update(tbsResponseData); |
2 | 567 |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
568 |
if (respSignature.verify(signature)) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
569 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
570 |
debug.println("Verified signature of OCSP Response"); |
2 | 571 |
} |
572 |
return true; |
|
573 |
||
574 |
} else { |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
575 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
576 |
debug.println( |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
577 |
"Error verifying signature of OCSP Response"); |
2 | 578 |
} |
579 |
return false; |
|
580 |
} |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
581 |
} catch (InvalidKeyException | NoSuchAlgorithmException | |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
582 |
SignatureException e) |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
583 |
{ |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
584 |
throw new CertPathValidatorException(e); |
2 | 585 |
} |
586 |
} |
|
587 |
||
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
588 |
/** |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
589 |
* Returns the SingleResponse of the specified CertId, or null if |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
590 |
* there is no response for that CertId. |
2 | 591 |
*/ |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
592 |
SingleResponse getSingleResponse(CertId certId) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
593 |
return singleResponseMap.get(certId); |
2 | 594 |
} |
595 |
||
596 |
/* |
|
597 |
* A class representing a single OCSP response. |
|
598 |
*/ |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
599 |
final static class SingleResponse implements OCSP.RevocationStatus { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
600 |
private final CertId certId; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
601 |
private final CertStatus certStatus; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
602 |
private final Date thisUpdate; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
603 |
private final Date nextUpdate; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
604 |
private final Date revocationTime; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
605 |
private final CRLReason revocationReason; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
606 |
private final Map<String, java.security.cert.Extension> singleExtensions; |
2 | 607 |
|
608 |
private SingleResponse(DerValue der) throws IOException { |
|
609 |
if (der.tag != DerValue.tag_Sequence) { |
|
610 |
throw new IOException("Bad ASN.1 encoding in SingleResponse"); |
|
611 |
} |
|
612 |
DerInputStream tmp = der.data; |
|
613 |
||
614 |
certId = new CertId(tmp.getDerValue().data); |
|
615 |
DerValue derVal = tmp.getDerValue(); |
|
616 |
short tag = (byte)(derVal.tag & 0x1f); |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
617 |
if (tag == CERT_STATUS_REVOKED) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
618 |
certStatus = CertStatus.REVOKED; |
2 | 619 |
revocationTime = derVal.data.getGeneralizedTime(); |
620 |
if (derVal.data.available() != 0) { |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
621 |
DerValue dv = derVal.data.getDerValue(); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
622 |
tag = (byte)(dv.tag & 0x1f); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
623 |
if (tag == 0) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
624 |
int reason = dv.data.getEnumerated(); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
625 |
// if reason out-of-range just leave as UNSPECIFIED |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
626 |
if (reason >= 0 && reason < values.length) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
627 |
revocationReason = values[reason]; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
628 |
} else { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
629 |
revocationReason = CRLReason.UNSPECIFIED; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
630 |
} |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
631 |
} else { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
632 |
revocationReason = CRLReason.UNSPECIFIED; |
2 | 633 |
} |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
634 |
} else { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
635 |
revocationReason = CRLReason.UNSPECIFIED; |
2 | 636 |
} |
637 |
// RevokedInfo |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
638 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
639 |
debug.println("Revocation time: " + revocationTime); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
640 |
debug.println("Revocation reason: " + revocationReason); |
2 | 641 |
} |
642 |
} else { |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
643 |
revocationTime = null; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
644 |
revocationReason = CRLReason.UNSPECIFIED; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
645 |
if (tag == CERT_STATUS_GOOD) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
646 |
certStatus = CertStatus.GOOD; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
647 |
} else if (tag == CERT_STATUS_UNKNOWN) { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
648 |
certStatus = CertStatus.UNKNOWN; |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
649 |
} else { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
650 |
throw new IOException("Invalid certificate status"); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
651 |
} |
2 | 652 |
} |
653 |
||
654 |
thisUpdate = tmp.getGeneralizedTime(); |
|
655 |
||
656 |
if (tmp.available() == 0) { |
|
657 |
// we are done |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
658 |
nextUpdate = null; |
2 | 659 |
} else { |
660 |
derVal = tmp.getDerValue(); |
|
661 |
tag = (byte)(derVal.tag & 0x1f); |
|
662 |
if (tag == 0) { |
|
663 |
// next update |
|
664 |
nextUpdate = derVal.data.getGeneralizedTime(); |
|
665 |
||
666 |
if (tmp.available() == 0) { |
|
667 |
// we are done |
|
668 |
} else { |
|
669 |
derVal = tmp.getDerValue(); |
|
670 |
tag = (byte)(derVal.tag & 0x1f); |
|
671 |
} |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
672 |
} else { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
673 |
nextUpdate = null; |
2 | 674 |
} |
675 |
} |
|
676 |
// singleExtensions |
|
677 |
if (tmp.available() > 0) { |
|
678 |
derVal = tmp.getDerValue(); |
|
679 |
if (derVal.isContextSpecific((byte)1)) { |
|
680 |
DerValue[] singleExtDer = derVal.data.getSequence(3); |
|
681 |
singleExtensions = |
|
682 |
new HashMap<String, java.security.cert.Extension> |
|
683 |
(singleExtDer.length); |
|
684 |
for (int i = 0; i < singleExtDer.length; i++) { |
|
685 |
Extension ext = new Extension(singleExtDer[i]); |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
686 |
if (debug != null) { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
10336
diff
changeset
|
687 |
debug.println("OCSP single extension: " + ext); |
2 | 688 |
} |
4673
1536565aebcc
6915939: Exception should be thrown if OCSP SingleResponses contain unresolved critical extensions
mullan
parents:
4209
diff
changeset
|
689 |
// We don't support any extensions yet. Therefore, if it |
1536565aebcc
6915939: Exception should be thrown if OCSP SingleResponses contain unresolved critical extensions
mullan
parents:
4209
diff
changeset
|
690 |
// is critical we must throw an exception because we |
1536565aebcc
6915939: Exception should be thrown if OCSP SingleResponses contain unresolved critical extensions
mullan
parents:
4209
diff
changeset
|
691 |
// don't know how to process it. |
1536565aebcc
6915939: Exception should be thrown if OCSP SingleResponses contain unresolved critical extensions
mullan
parents:
4209
diff
changeset
|
692 |
if (ext.isCritical()) { |
1536565aebcc
6915939: Exception should be thrown if OCSP SingleResponses contain unresolved critical extensions
mullan
parents:
4209
diff
changeset
|
693 |
throw new IOException( |
1536565aebcc
6915939: Exception should be thrown if OCSP SingleResponses contain unresolved critical extensions
mullan
parents:
4209
diff
changeset
|
694 |
"Unsupported OCSP critical extension: " + |
1536565aebcc
6915939: Exception should be thrown if OCSP SingleResponses contain unresolved critical extensions
mullan
parents:
4209
diff
changeset
|
695 |
ext.getExtensionId()); |
1536565aebcc
6915939: Exception should be thrown if OCSP SingleResponses contain unresolved critical extensions
mullan
parents:
4209
diff
changeset
|
696 |
} |
1536565aebcc
6915939: Exception should be thrown if OCSP SingleResponses contain unresolved critical extensions
mullan
parents:
4209
diff
changeset
|
697 |
singleExtensions.put(ext.getId(), ext); |
2 | 698 |
} |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
699 |
} else { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
700 |
singleExtensions = Collections.emptyMap(); |
2 | 701 |
} |
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
702 |
} else { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
703 |
singleExtensions = Collections.emptyMap(); |
2 | 704 |
} |
705 |
} |
|
706 |
||
707 |
/* |
|
708 |
* Return the certificate's revocation status code |
|
709 |
*/ |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
710 |
@Override public CertStatus getCertStatus() { |
2 | 711 |
return certStatus; |
712 |
} |
|
713 |
||
714 |
private CertId getCertId() { |
|
715 |
return certId; |
|
716 |
} |
|
717 |
||
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
718 |
@Override public Date getRevocationTime() { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
719 |
return (Date) revocationTime.clone(); |
2 | 720 |
} |
721 |
||
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
722 |
@Override public CRLReason getRevocationReason() { |
2 | 723 |
return revocationReason; |
724 |
} |
|
725 |
||
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
726 |
@Override |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
727 |
public Map<String, java.security.cert.Extension> getSingleExtensions() { |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
728 |
return Collections.unmodifiableMap(singleExtensions); |
2 | 729 |
} |
730 |
||
731 |
/** |
|
732 |
* Construct a string representation of a single OCSP response. |
|
733 |
*/ |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
734 |
@Override public String toString() { |
2 | 735 |
StringBuilder sb = new StringBuilder(); |
736 |
sb.append("SingleResponse: \n"); |
|
737 |
sb.append(certId); |
|
3841
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
738 |
sb.append("\nCertStatus: "+ certStatus + "\n"); |
6738c111d48f
6745437: Add option to only check revocation of end-entity certificate in a chain of certificates
mullan
parents:
3314
diff
changeset
|
739 |
if (certStatus == CertStatus.REVOKED) { |
2 | 740 |
sb.append("revocationTime is " + revocationTime + "\n"); |
741 |
sb.append("revocationReason is " + revocationReason + "\n"); |
|
742 |
} |
|
743 |
sb.append("thisUpdate is " + thisUpdate + "\n"); |
|
744 |
if (nextUpdate != null) { |
|
745 |
sb.append("nextUpdate is " + nextUpdate + "\n"); |
|
746 |
} |
|
747 |
return sb.toString(); |
|
748 |
} |
|
749 |
} |
|
750 |
} |