williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@2
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description:
|
williamr@2
|
15 |
* PKIXCERTCHAIN.H
|
williamr@2
|
16 |
* PKIX certificate chain implementation
|
williamr@2
|
17 |
*
|
williamr@2
|
18 |
*/
|
williamr@2
|
19 |
|
williamr@2
|
20 |
|
williamr@2
|
21 |
/**
|
williamr@2
|
22 |
@file
|
williamr@4
|
23 |
@publishedAll
|
williamr@4
|
24 |
@released
|
williamr@2
|
25 |
*/
|
williamr@2
|
26 |
|
williamr@2
|
27 |
#ifndef __PKIXCERTCHAIN_H__
|
williamr@2
|
28 |
#define __PKIXCERTCHAIN_H__
|
williamr@2
|
29 |
|
williamr@2
|
30 |
#include <e32std.h>
|
williamr@2
|
31 |
#include <x509certchain.h>
|
williamr@2
|
32 |
#include <pkixvalidationresult.h>
|
williamr@2
|
33 |
|
williamr@2
|
34 |
//implements key validation according to RFC 2459 (PKIX cert/CRL profile), section 6
|
williamr@2
|
35 |
class CPKIXValidationState;
|
williamr@2
|
36 |
class CPKIXChainBuilder;
|
williamr@2
|
37 |
class CPKIXCertChainAO;
|
williamr@2
|
38 |
class CPKIXCertChainHelper;
|
williamr@2
|
39 |
class MCertStore;
|
williamr@2
|
40 |
|
williamr@2
|
41 |
/**
|
williamr@2
|
42 |
* Base class for CPKIXCertChain
|
williamr@2
|
43 |
*/
|
williamr@2
|
44 |
class CPKIXCertChainBase : public CX509CertChain
|
williamr@2
|
45 |
{
|
williamr@2
|
46 |
public:
|
williamr@2
|
47 |
//constructors
|
williamr@2
|
48 |
/** Creates a certificate chain using the binary data in aEncodedCerts.
|
williamr@2
|
49 |
*
|
williamr@2
|
50 |
* @param aCertStore The certificate store to use when looking for root certificates.
|
williamr@2
|
51 |
* @param aEncodedCerts One or more concatenated DER encoded X.509 certificates.
|
williamr@2
|
52 |
* The first certificate will be interpreted as the end entity certificate to
|
williamr@2
|
53 |
* be validated; subsequent certificates may be in any order and may be used
|
williamr@2
|
54 |
* by the chain as intermediate certificates, but not root certificates. The
|
williamr@2
|
55 |
* individual certificates can be retrieved since each one contains its own length.
|
williamr@2
|
56 |
* @param aClient The Uid identifying the purpose for which the chain will be used.
|
williamr@2
|
57 |
* This value will be used to select a subset of stored certificates, by way of their trust
|
williamr@2
|
58 |
* settings, to be used as candidate root certificates. */
|
williamr@2
|
59 |
IMPORT_C static CPKIXCertChainBase* NewL(MCertStore& aCertStore, const TPtrC8& aEncodedCerts,
|
williamr@2
|
60 |
const TUid aClient);
|
williamr@2
|
61 |
|
williamr@2
|
62 |
/** Creates a certificate chain using the binary data in aEncodedCerts, and puts
|
williamr@2
|
63 |
* a pointer to the new object onto the cleanup stack.
|
williamr@2
|
64 |
*
|
williamr@2
|
65 |
* @param aCertStore The certificate store to use when looking for root certificates.
|
williamr@2
|
66 |
* @param aEncodedCerts One or more concatenated DER encoded X.509 certificates.
|
williamr@2
|
67 |
* The first certificate will be interpreted as the end entity certificate to
|
williamr@2
|
68 |
* be validated; subsequent certificates may be in any order and may be used
|
williamr@2
|
69 |
* by the chain as intermediate certificates, but not root certificates. The
|
williamr@2
|
70 |
* individual certificates can be retrieved since each one contains its own length.
|
williamr@2
|
71 |
* @param aClient The Uid identifying the purpose for which the chain will be used.
|
williamr@2
|
72 |
* This value will be used to select a subset of stored certificates, by way of their trust
|
williamr@2
|
73 |
* settings, to be used as candidate root certificates. */
|
williamr@2
|
74 |
IMPORT_C static CPKIXCertChainBase* NewLC(MCertStore& aCertStore, const TPtrC8& aEncodedCerts,
|
williamr@2
|
75 |
const TUid aClient);
|
williamr@2
|
76 |
|
williamr@2
|
77 |
/** Creates a certificate chain using the binary data in aEncodedCerts.
|
williamr@2
|
78 |
*
|
williamr@2
|
79 |
* @param aCertStore The certificate store to use when looking for root certificates.
|
williamr@2
|
80 |
* @param aEncodedCerts One or more concatenated DER encoded X.509 certificates.
|
williamr@2
|
81 |
* The first certificate will be interpreted as the end entity certificate to
|
williamr@2
|
82 |
* be validated; subsequent certificates may be in any order and may be used
|
williamr@2
|
83 |
* by the chain as intermediate certificates, but not root certificates. Any
|
williamr@2
|
84 |
* self signed certificates supplied here after the first one will be discarded,
|
williamr@2
|
85 |
* as self signed certificates cannot by definition be intermediate certificates.
|
williamr@2
|
86 |
* The individual certificates can be retrieved since each one contains its own
|
williamr@2
|
87 |
* length.
|
williamr@2
|
88 |
* @param aRootCerts An array of certificates which the chain will treat as candidate root
|
williamr@2
|
89 |
* certificates. If one of these overloads is used, the chain will not look in
|
williamr@2
|
90 |
* stores for root certificates, but will only use the certificates supplied here. */
|
williamr@2
|
91 |
IMPORT_C static CPKIXCertChainBase* NewL(MCertStore& aCertStore, const TPtrC8& aEncodedCerts,
|
williamr@2
|
92 |
const RPointerArray<CX509Certificate>& aRootCerts);
|
williamr@2
|
93 |
|
williamr@2
|
94 |
/** Creates a certificate chain using the binary data in aEncodedCerts and puts
|
williamr@2
|
95 |
* a pointer to the new object onto the cleanup stack.
|
williamr@2
|
96 |
*
|
williamr@2
|
97 |
* @param aCertStore The certificate store to use when looking for root certificates.
|
williamr@2
|
98 |
* @param aEncodedCerts One or more concatenated DER encoded X.509 certificates.
|
williamr@2
|
99 |
* The first certificate will be interpreted as the end entity certificate to
|
williamr@2
|
100 |
* be validated; subsequent certificates may be in any order and may be used
|
williamr@2
|
101 |
* by the chain as intermediate certificates, but not root certificates. Any
|
williamr@2
|
102 |
* self signed certificates supplied here after the first one will be discarded
|
williamr@2
|
103 |
* as self signed certificates cannot by definition be intermediate certificates.
|
williamr@2
|
104 |
* The individual certificates can be retrieved since each one contains its own
|
williamr@2
|
105 |
* length.
|
williamr@2
|
106 |
* @param aRootCerts An array of certificates which the chain will treat as candidate root
|
williamr@2
|
107 |
* certificates. If one of these overloads is used, the chain will not look in
|
williamr@2
|
108 |
* stores for root certificates, but will only use the certificates supplied here. */
|
williamr@2
|
109 |
IMPORT_C static CPKIXCertChainBase* NewLC(MCertStore& aCertStore, const TPtrC8& aEncodedCerts,
|
williamr@2
|
110 |
const RPointerArray<CX509Certificate>& aRootCerts);
|
williamr@2
|
111 |
|
williamr@2
|
112 |
/** Destructor.
|
williamr@2
|
113 |
*
|
williamr@2
|
114 |
* Frees all resources owned by the object. */
|
williamr@2
|
115 |
IMPORT_C ~CPKIXCertChainBase();
|
williamr@2
|
116 |
//validation
|
williamr@2
|
117 |
|
williamr@2
|
118 |
/** Validates the chain.
|
williamr@2
|
119 |
*
|
williamr@2
|
120 |
* @param aValidationResult On completion, this contains the result of the validation.
|
williamr@2
|
121 |
* @param aValidationTime The time that should be presumed to be the current time when checking timestamps.
|
williamr@2
|
122 |
* @param aStatus An asynchronous request status object. */
|
williamr@2
|
123 |
IMPORT_C void ValidateL(CPKIXValidationResultBase& aValidationResult,
|
williamr@2
|
124 |
const TTime& aValidationTime, TRequestStatus& aStatus);
|
williamr@2
|
125 |
|
williamr@2
|
126 |
/** Validates the chain.
|
williamr@2
|
127 |
*
|
williamr@2
|
128 |
* @param aValidationResult On completion, this contains the result of the validation.
|
williamr@2
|
129 |
* @param aValidationTime The time that should be presumed to be the current time when checking timestamps.
|
williamr@2
|
130 |
* @param aInitialPolicies The policies we want to be present in the certificate chain.
|
williamr@2
|
131 |
* @param aStatus An asynchronous request status object. */
|
williamr@2
|
132 |
IMPORT_C void ValidateL(CPKIXValidationResultBase& aValidationResult,
|
williamr@2
|
133 |
const TTime& aValidationTime, const CArrayPtr<HBufC>& aInitialPolicies,
|
williamr@2
|
134 |
TRequestStatus& aStatus);
|
williamr@2
|
135 |
|
williamr@2
|
136 |
/** Cancels an asynchronous ValidateL() operation. */
|
williamr@2
|
137 |
IMPORT_C void CancelValidate();
|
williamr@2
|
138 |
|
williamr@2
|
139 |
/** Adds one or more intermediate certificates to use when building the chain .
|
williamr@2
|
140 |
*
|
williamr@2
|
141 |
* Any self signed certs are ignored.
|
williamr@2
|
142 |
*
|
williamr@2
|
143 |
* @param aEncodedCerts The concatenation of one or more DER encoded X.509 certificates. */
|
williamr@2
|
144 |
IMPORT_C void AddCertL(const TPtrC8& aEncodedCerts);
|
williamr@2
|
145 |
|
williamr@2
|
146 |
/** Tests whether the root certificate of the chain is locatable.
|
williamr@2
|
147 |
*
|
williamr@2
|
148 |
* Note that the value is only significant after a successful call to ValidateL().
|
williamr@2
|
149 |
*
|
williamr@2
|
150 |
* @return ETrue if the chain has a root; EFalse, otherwise. */
|
williamr@2
|
151 |
IMPORT_C TBool ChainHasRoot() const;
|
williamr@2
|
152 |
|
williamr@2
|
153 |
/** Returns a list of the critical extension OIDs that are supported by the
|
williamr@2
|
154 |
* chain validator. If a critical extension is encountered in a certificate
|
williamr@2
|
155 |
* chain whose OID matches an element in this set then the chain validator
|
williamr@2
|
156 |
* shall treat this as a warning instead of an error.
|
williamr@2
|
157 |
*
|
williamr@2
|
158 |
* If CPKIXCertChain::SetSupportedCriticalExtensionsL() has not been called, this
|
williamr@2
|
159 |
* list will return the default set of supported critical extensions which
|
williamr@2
|
160 |
* includes the X.509 standard and Symbian specific SIS file critical extensions.
|
williamr@2
|
161 |
* These extensions may change in the future and should not be relied upon.
|
williamr@2
|
162 |
*
|
williamr@2
|
163 |
* @return The current list of supported critical extension OIDs. Ownership is not
|
williamr@2
|
164 |
* transferred to the caller. */
|
williamr@2
|
165 |
IMPORT_C const RPointerArray<TDesC>& SupportedCriticalExtensions() const;
|
williamr@2
|
166 |
|
williamr@2
|
167 |
/** Adds one or more critical extension OIDs to the list of supported critical
|
williamr@2
|
168 |
* extensions. Duplicate OID values are not added.
|
williamr@2
|
169 |
*
|
williamr@2
|
170 |
* @param aCriticalExtOids A list of the critical extensions OIDs to append to the supported
|
williamr@2
|
171 |
* list. Ownership is not transferred from the caller. */
|
williamr@2
|
172 |
IMPORT_C void AddSupportedCriticalExtensionsL(const RPointerArray<TDesC>& aCriticalExtOids);
|
williamr@2
|
173 |
|
williamr@2
|
174 |
/** Removes one or more critical extension OIDs from the list of supported critical extensions.
|
williamr@2
|
175 |
*
|
williamr@2
|
176 |
* @param aCriticalExts A list of the critical extensions OIDs to remove from the supported list.
|
williamr@2
|
177 |
* Ownership is with the original caller. Oids will not be destroyed. */
|
williamr@2
|
178 |
IMPORT_C void RemoveSupportedCriticalExtensions(const RPointerArray<TDesC>& aCriticalExtOids);
|
williamr@2
|
179 |
|
williamr@2
|
180 |
/** Completely replaces the set of supported critical extensions for certificate validation. If a critical
|
williamr@2
|
181 |
* extension is encountered matching one of these OIDs then its occurrence is treated as a warning rather
|
williamr@2
|
182 |
* than an error. The results of which can be queried through a call to CPKIXValidationResult::ValidationWarnings().
|
williamr@2
|
183 |
*
|
williamr@2
|
184 |
* @param aCriticalExtOids A list of the critical extensions OIDs for the class to support. Ownership is
|
williamr@2
|
185 |
* not transferred from the caller. */
|
williamr@2
|
186 |
IMPORT_C void SetSupportedCriticalExtensionsL(const RPointerArray<TDesC>& aCriticalExtOids);
|
williamr@2
|
187 |
|
williamr@2
|
188 |
/** Resets the current list of supported critical extensions and re-populates it with the default set
|
williamr@2
|
189 |
* which includes the X.509 standard and Symbian specific SIS file critical extensions. These extensions
|
williamr@2
|
190 |
* may change in the future and should not be relied upon. */
|
williamr@2
|
191 |
IMPORT_C void ResetSupportedCriticalExtsToDefaultL();
|
williamr@2
|
192 |
|
williamr@2
|
193 |
/** Specify if a failed check on the certificate validity date is treated as an error or a warning.
|
williamr@2
|
194 |
*
|
williamr@2
|
195 |
* @param aIsFatal ETrue for reporting as an error; EFalse for a warning.*/
|
williamr@2
|
196 |
IMPORT_C void SetValidityPeriodCheckFatal(TBool aIsFatal);
|
williamr@2
|
197 |
|
williamr@2
|
198 |
/** Returns whether or not validity period check failures will be reported as an error or a warning.
|
williamr@2
|
199 |
*
|
williamr@2
|
200 |
* @param aIsFatal ETrue if failure is reported as an error; EFalse for a warning.*/
|
williamr@2
|
201 |
IMPORT_C TBool ValidityPeriodCheckFatal() const;
|
williamr@2
|
202 |
|
williamr@2
|
203 |
protected:
|
williamr@2
|
204 |
IMPORT_C CPKIXCertChainBase();
|
williamr@2
|
205 |
IMPORT_C void ConstructL(MCertStore& aCertStore, const TPtrC8& aEncodedCerts, TUid aClient);
|
williamr@2
|
206 |
IMPORT_C void ConstructL(MCertStore& aCertStore, const TPtrC8& aEncodedCerts, const RPointerArray<CX509Certificate>& aRootCerts);
|
williamr@2
|
207 |
|
williamr@2
|
208 |
public:
|
williamr@2
|
209 |
// Public non-exported methods called by CPKIXCertChainAO
|
williamr@2
|
210 |
CArrayPtrFlat<CX509Certificate>& Chain();
|
williamr@2
|
211 |
const RPointerArray<CX509Certificate>& IntermediateCerts();
|
williamr@2
|
212 |
TBool ChainHasRoot();
|
williamr@2
|
213 |
void RemoveLastCerts(TInt aNumberOfCertsToRemove);
|
williamr@2
|
214 |
void SetChainHasRoot(TBool aHasRoot);
|
williamr@2
|
215 |
|
williamr@2
|
216 |
private:
|
williamr@2
|
217 |
void DoConstructL(const TPtrC8& aEncodedCerts);
|
williamr@2
|
218 |
|
williamr@2
|
219 |
/**
|
williamr@2
|
220 |
* This function adds certificates to the chain but only the ones that are not
|
williamr@2
|
221 |
* self-signed.
|
williamr@2
|
222 |
*
|
williamr@2
|
223 |
* @param aEncodedCerts The encoded certificates.
|
williamr@2
|
224 |
*/
|
williamr@2
|
225 |
void AddIntermediateCertsL(const TPtrC8& aEncodedCerts);
|
williamr@2
|
226 |
|
williamr@2
|
227 |
private:
|
williamr@2
|
228 |
/**
|
williamr@2
|
229 |
* Holds a list of candiate intermediate certs - these come from the encoded
|
williamr@2
|
230 |
* certs passed at construction time, and also any added with AddCertL().
|
williamr@2
|
231 |
*/
|
williamr@2
|
232 |
RPointerArray<CX509Certificate> iIntermediateCerts;
|
williamr@2
|
233 |
|
williamr@2
|
234 |
/**
|
williamr@2
|
235 |
* This is ETrue if the chain has a root and EFalse if it hasn't. The value
|
williamr@2
|
236 |
* is only significant after a successfull call to ValidateL().
|
williamr@2
|
237 |
*/
|
williamr@2
|
238 |
TBool iChainHasRoot;
|
williamr@2
|
239 |
|
williamr@2
|
240 |
/**
|
williamr@2
|
241 |
* Most of the fucntionality of the class is asynchronous and is in fact
|
williamr@2
|
242 |
* delegated to iActiveObject which will deal with all the asynchronous
|
williamr@2
|
243 |
* functions.
|
williamr@2
|
244 |
*/
|
williamr@2
|
245 |
CPKIXCertChainAO* iActiveObject;
|
williamr@2
|
246 |
|
williamr@2
|
247 |
/**
|
williamr@2
|
248 |
* Holds a list of supported critical extensions set by the client.
|
williamr@2
|
249 |
*/
|
williamr@2
|
250 |
RPointerArray<TDesC> iSupportedCriticalExts;
|
williamr@2
|
251 |
|
williamr@2
|
252 |
/**
|
williamr@2
|
253 |
* When true (the defaut) indicates that a failed check on the validity period of a
|
williamr@2
|
254 |
* certificate will result in a fatal error. When false this instead results in a
|
williamr@2
|
255 |
* warning.
|
williamr@2
|
256 |
*/
|
williamr@2
|
257 |
TBool iDateTimeCheckFatal;
|
williamr@2
|
258 |
};
|
williamr@2
|
259 |
|
williamr@2
|
260 |
|
williamr@2
|
261 |
/**
|
williamr@2
|
262 |
* This class implements a PKIX certificate chain.
|
williamr@2
|
263 |
*
|
williamr@2
|
264 |
* @since v6.0
|
williamr@2
|
265 |
*/
|
williamr@2
|
266 |
class CPKIXCertChain : public CPKIXCertChainBase
|
williamr@2
|
267 |
{
|
williamr@2
|
268 |
public:
|
williamr@2
|
269 |
|
williamr@2
|
270 |
//constructors
|
williamr@2
|
271 |
/** Creates a certificate chain using the binary data in aEncodedCerts.
|
williamr@2
|
272 |
*
|
williamr@2
|
273 |
* @param aFs An open file server session.
|
williamr@2
|
274 |
* @param aEncodedCerts One or more concatenated DER encoded X.509 certificates.
|
williamr@2
|
275 |
* The first certificate will be interpreted as the end entity certificate to
|
williamr@2
|
276 |
* be validated; subsequent certificates may be in any order and may be used
|
williamr@2
|
277 |
* by the chain as intermediate certificates, but not root certificates. The
|
williamr@2
|
278 |
* individual certificates can be retrieved since each one contains its own length.
|
williamr@2
|
279 |
* @param aClient The Uid identifying the purpose for which the chain will be used.
|
williamr@2
|
280 |
* This value will be used to select a subset of stored certificates, by way of their trust
|
williamr@2
|
281 |
* settings, to be used as candidate root certificates. */
|
williamr@2
|
282 |
IMPORT_C static CPKIXCertChain* NewL(RFs& aFs, const TPtrC8& aEncodedCerts,
|
williamr@2
|
283 |
const TUid aClient);
|
williamr@2
|
284 |
|
williamr@2
|
285 |
/** Creates a certificate chain using the binary data in aEncodedCerts, and puts
|
williamr@2
|
286 |
* a pointer to the new object onto the cleanup stack.
|
williamr@2
|
287 |
*
|
williamr@2
|
288 |
* @param aFs An open file server session
|
williamr@2
|
289 |
* @param aEncodedCerts One or more concatenated DER encoded X.509 certificates.
|
williamr@2
|
290 |
* The first certificate will be interpreted as the end entity certificate to
|
williamr@2
|
291 |
* be validated; subsequent certificates may be in any order and may be used
|
williamr@2
|
292 |
* by the chain as intermediate certificates, but not root certificates. The
|
williamr@2
|
293 |
* individual certificates can be retrieved since each one contains its own length.
|
williamr@2
|
294 |
* @param aClient The Uid identifying the purpose for which the chain will be used.
|
williamr@2
|
295 |
* This value will be used to select a subset of stored certificates, by way of their trust
|
williamr@2
|
296 |
* settings, to be used as candidate root certificates. */
|
williamr@2
|
297 |
IMPORT_C static CPKIXCertChain* NewLC(RFs& aFs, const TPtrC8& aEncodedCerts,
|
williamr@2
|
298 |
const TUid aClient);
|
williamr@2
|
299 |
|
williamr@2
|
300 |
/** Creates a certificate chain using the binary data in aEncodedCerts.
|
williamr@2
|
301 |
*
|
williamr@2
|
302 |
* @param aFs An open file server session.
|
williamr@2
|
303 |
* @param aEncodedCerts One or more concatenated DER encoded X.509 certificates.
|
williamr@2
|
304 |
* The first certificate will be interpreted as the end entity certificate to
|
williamr@2
|
305 |
* be validated; subsequent certificates may be in any order and may be used
|
williamr@2
|
306 |
* by the chain as intermediate certificates, but not root certificates. Any
|
williamr@2
|
307 |
* self signed certificates supplied here after the first one will be discarded,
|
williamr@2
|
308 |
* as self signed certificates cannot by definition be intermediate certificates.
|
williamr@2
|
309 |
* The individual certificates can be retrieved since each one contains its own
|
williamr@2
|
310 |
* length.
|
williamr@2
|
311 |
* @param aRootCerts An array of certificates which the chain will treat as candidate root
|
williamr@2
|
312 |
* certificates. If one of these overloads is used, the chain will not look in
|
williamr@2
|
313 |
* stores for root certificates, but will only use the certificates supplied here. */
|
williamr@2
|
314 |
IMPORT_C static CPKIXCertChain* NewL(RFs& aFs, const TPtrC8& aEncodedCerts,
|
williamr@2
|
315 |
const RPointerArray<CX509Certificate>& aRootCerts);
|
williamr@2
|
316 |
|
williamr@2
|
317 |
/** Creates a certificate chain using the binary data in aEncodedCerts and puts
|
williamr@2
|
318 |
* a pointer to the new object onto the cleanup stack.
|
williamr@2
|
319 |
*
|
williamr@2
|
320 |
* @param aFs An open file server session.
|
williamr@2
|
321 |
* @param aEncodedCerts One or more concatenated DER encoded X.509 certificates.
|
williamr@2
|
322 |
* The first certificate will be interpreted as the end entity certificate to
|
williamr@2
|
323 |
* be validated; subsequent certificates may be in any order and may be used
|
williamr@2
|
324 |
* by the chain as intermediate certificates, but not root certificates. Any
|
williamr@2
|
325 |
* self signed certificates supplied here after the first one will be discarded
|
williamr@2
|
326 |
* as self signed certificates cannot by definition be intermediate certificates.
|
williamr@2
|
327 |
* The individual certificates can be retrieved since each one contains its own
|
williamr@2
|
328 |
* length.
|
williamr@2
|
329 |
* @param aRootCerts An array of certificates which the chain will treat as candidate root
|
williamr@2
|
330 |
* certificates. If one of these overloads is used, the chain will not look in
|
williamr@2
|
331 |
* stores for root certificates, but will only use the certificates supplied here. */
|
williamr@2
|
332 |
IMPORT_C static CPKIXCertChain* NewLC(RFs& aFs, const TPtrC8& aEncodedCerts,
|
williamr@2
|
333 |
const RPointerArray<CX509Certificate>& aRootCerts);
|
williamr@2
|
334 |
|
williamr@2
|
335 |
//destructor
|
williamr@2
|
336 |
/** Destructor.
|
williamr@2
|
337 |
*
|
williamr@2
|
338 |
* Frees all resources owned by the object. */
|
williamr@2
|
339 |
IMPORT_C ~CPKIXCertChain();
|
williamr@2
|
340 |
//validation
|
williamr@2
|
341 |
|
williamr@2
|
342 |
/** Validates the chain.
|
williamr@2
|
343 |
*
|
williamr@2
|
344 |
* @param aValidationResult On completion, this contains the result of the validation.
|
williamr@2
|
345 |
* @param aValidationTime The time that should be presumed to be the current time when checking timestamps.
|
williamr@2
|
346 |
* @param aStatus An asynchronous request status object. */
|
williamr@2
|
347 |
IMPORT_C void ValidateL(CPKIXValidationResult& aValidationResult,
|
williamr@2
|
348 |
const TTime& aValidationTime, TRequestStatus& aStatus);
|
williamr@2
|
349 |
|
williamr@2
|
350 |
/** Validates the chain.
|
williamr@2
|
351 |
*
|
williamr@2
|
352 |
* @param aValidationResult On completion, this contains the result of the validation.
|
williamr@2
|
353 |
* @param aValidationTime The time that should be presumed to be the current time when checking timestamps.
|
williamr@2
|
354 |
* @param aInitialPolicies The policies we want to be present in the certificate chain.
|
williamr@2
|
355 |
* @param aStatus An asynchronous request status object. */
|
williamr@2
|
356 |
IMPORT_C void ValidateL(CPKIXValidationResult& aValidationResult,
|
williamr@2
|
357 |
const TTime& aValidationTime, const CArrayPtr<HBufC>& aInitialPolicies,
|
williamr@2
|
358 |
TRequestStatus& aStatus);
|
williamr@2
|
359 |
|
williamr@2
|
360 |
/** Cancels an asynchronous ValidateL() operation. */
|
williamr@2
|
361 |
IMPORT_C void CancelValidate();
|
williamr@2
|
362 |
|
williamr@2
|
363 |
/** Adds a certificate (if it is not self-signed) to the chain .
|
williamr@2
|
364 |
*
|
williamr@2
|
365 |
* @param aEncodedCerts A DER encoded X.509 certificate. */
|
williamr@2
|
366 |
IMPORT_C void AddCertL(const TPtrC8& aEncodedCerts);
|
williamr@2
|
367 |
|
williamr@2
|
368 |
/** Tests whether the root certificate of the chain is locatable.
|
williamr@2
|
369 |
*
|
williamr@2
|
370 |
* Note that the value is only significant after a successfull call to ValidateL().
|
williamr@2
|
371 |
*
|
williamr@2
|
372 |
* @return ETrue if the chain has a root; EFalse, otherwise. */
|
williamr@2
|
373 |
IMPORT_C TBool ChainHasRoot() const;
|
williamr@2
|
374 |
|
williamr@2
|
375 |
/** Returns a list of the critical extension OIDs that are supported by the
|
williamr@2
|
376 |
* chain validator. If a critical extension is encountered in a certificate
|
williamr@2
|
377 |
* chain whose OID matches an element in this set then the chain validator
|
williamr@2
|
378 |
* shall treat this as a warning instead of an error.
|
williamr@2
|
379 |
*
|
williamr@2
|
380 |
* If CPKIXCertChain::SetSupportedCriticalExtensionsL() has not been called, this
|
williamr@2
|
381 |
* list will return the default set of supported critical extensions which
|
williamr@2
|
382 |
* includes the X.509 standard and Symbian specific SIS file critical extensions.
|
williamr@2
|
383 |
* These extensions may change in the future and should not be relied upon.
|
williamr@2
|
384 |
*
|
williamr@2
|
385 |
* @return The current list of supported critical extension OIDs. Ownership is not
|
williamr@2
|
386 |
* transferred to the caller. */
|
williamr@2
|
387 |
IMPORT_C const RPointerArray<TDesC>& SupportedCriticalExtensions() const;
|
williamr@2
|
388 |
|
williamr@2
|
389 |
/** Adds one or more critical extension OIDs to the list of supported critical
|
williamr@2
|
390 |
* extensions. Duplicate OID values are not added.
|
williamr@2
|
391 |
*
|
williamr@2
|
392 |
* @param aCriticalExtOids A list of the critical extensions OIDs to append to the supported
|
williamr@2
|
393 |
* list. Ownership is not transferred from the caller. */
|
williamr@2
|
394 |
IMPORT_C void AddSupportedCriticalExtensionsL(const RPointerArray<TDesC>& aCriticalExtOids);
|
williamr@2
|
395 |
|
williamr@2
|
396 |
/** Removes one or more critical extension OIDs from the list of supported critical extensions.
|
williamr@2
|
397 |
*
|
williamr@2
|
398 |
* @param aCriticalExts A list of the critical extensions OIDs to remove from the supported list.
|
williamr@2
|
399 |
* Ownership is with the original caller. Oids will not be destroyed. */
|
williamr@2
|
400 |
IMPORT_C void RemoveSupportedCriticalExtensions(const RPointerArray<TDesC>& aCriticalExtOids);
|
williamr@2
|
401 |
|
williamr@2
|
402 |
/** Completely replaces the set of supported critical extensions for certificate validation. If a critical
|
williamr@2
|
403 |
* extension is encountered matching one of these OIDs then its occurrence is treated as a warning rather
|
williamr@2
|
404 |
* than an error. The results of which can be queried through a call to CPKIXValidationResult::ValidationWarnings().
|
williamr@2
|
405 |
*
|
williamr@2
|
406 |
* @param aCriticalExtOids A list of the critical extensions OIDs for the class to support. Ownership is
|
williamr@2
|
407 |
* not transferred from the caller. */
|
williamr@2
|
408 |
IMPORT_C void SetSupportedCriticalExtensionsL(const RPointerArray<TDesC>& aCriticalExtOids);
|
williamr@2
|
409 |
|
williamr@2
|
410 |
/** Resets the current list of supported critical extensions and re-populates it with the default set
|
williamr@2
|
411 |
* which includes the X.509 standard and Symbian specific SIS file critical extensions. These extensions
|
williamr@2
|
412 |
* may change in the future and should not be relied upon. */
|
williamr@2
|
413 |
IMPORT_C void ResetSupportedCriticalExtsToDefaultL();
|
williamr@2
|
414 |
|
williamr@2
|
415 |
/** Specify if a failed check on the certificate validity date is treated as an error or a warning.
|
williamr@2
|
416 |
*
|
williamr@2
|
417 |
* @param aIsFatal ETrue for reporting as an error; EFalse for a warning.*/
|
williamr@2
|
418 |
IMPORT_C void SetValidityPeriodCheckFatal(TBool aIsFatal);
|
williamr@2
|
419 |
|
williamr@2
|
420 |
private:
|
williamr@2
|
421 |
CPKIXCertChain();
|
williamr@2
|
422 |
void ConstructL(RFs& aFs, const TPtrC8& aEncodedCerts, TUid aClient);
|
williamr@2
|
423 |
void ConstructL(RFs& aFs, const TPtrC8& aEncodedCerts,
|
williamr@2
|
424 |
const RPointerArray<CX509Certificate>& aRootCerts);
|
williamr@2
|
425 |
|
williamr@2
|
426 |
private:
|
williamr@2
|
427 |
CPKIXCertChainHelper* iHelper;
|
williamr@2
|
428 |
};
|
williamr@2
|
429 |
|
williamr@2
|
430 |
#endif
|