cryptoservices/certificateandkeymgmt/pkixcertbase/Pkixchainbuilder.cpp
branchRCL_3
changeset 60 f18401adf8e1
parent 8 35751d3474b7
equal deleted inserted replaced
58:a5e05e7296f9 60:f18401adf8e1
     1 /*
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   148 					}
   148 					}
   149 				}
   149 				}
   150 			}
   150 			}
   151 		CleanupStack::PopAndDestroy();//aki
   151 		CleanupStack::PopAndDestroy();//aki
   152 		}
   152 		}
       
   153 	
       
   154 	// If more then one subject matching candidates are found and they doesn't contain SKI/AKI,
       
   155 	// consider the most recently imported/added candidate as the issuer.
       
   156 	for(TInt index = count - 1; index >= 0; --index)
       
   157 		{
       
   158 		TTime currentTime;
       
   159 		// if secure time is not available then fall back to the insecure version.
       
   160 		if(currentTime.UniversalTimeSecure() == KErrNoSecureTime)
       
   161 			{
       
   162 			currentTime.UniversalTime();
       
   163 			}
       
   164 
       
   165 		CX509Certificate* cert = CX509Certificate::NewLC(*aCandidates[index]);
       
   166 		// SKI/AKI are optional in versions lower than 3. So, relax the candidate selection rules only for version 1 & 2
       
   167 		// If the recent candidate is not valid enough(cert expired), consider it's previous valid candidate.
       
   168 		if((cert->Version() < 3) && (cert->ValidityPeriod().Valid(currentTime)))
       
   169 			{				
       
   170 			aChain.AppendL(cert);
       
   171 			++(*iNumberOfCertsAdded);
       
   172 			CleanupStack::Pop(cert);
       
   173 			return ETrue;				
       
   174 			}
       
   175 		else
       
   176 			{
       
   177 			CleanupStack::PopAndDestroy(cert);
       
   178 			continue;
       
   179 			}			
       
   180 		}
   153 
   181 
   154 	return EFalse;
   182 	return EFalse;
   155 	}
   183 	}
   156 
   184 
   157 
   185