vpnengine/vpnmanager/src/pkiutil.cpp
branchRCL_3
changeset 44 735de8341ce4
parent 0 33413c0669b9
equal deleted inserted replaced
41:e06095241a65 44:735de8341ce4
     1 /*
     1 /*
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2003-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 "Eclipse Public License v1.0"
     5 * under the terms of "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".
   249     TRequestStatus status;
   249     TRequestStatus status;
   250     TCertStatus certStatus;
   250     TCertStatus certStatus;
   251 
   251 
   252     HBufC8* certData = HBufC8::NewL(KExpectedMaxCertSize);
   252     HBufC8* certData = HBufC8::NewL(KExpectedMaxCertSize);
   253     HBufC8* subjectNameString;
   253     HBufC8* subjectNameString;
       
   254     
   254     _LIT8(KEmptyString, "");
   255     _LIT8(KEmptyString, "");
       
   256     
   255     CleanupStack::PushL(certData);
   257     CleanupStack::PushL(certData);
   256 
   258 
   257     TPtr8 certDataPtr = certData->Des();
   259     TPtr8 certDataPtr = certData->Des();
   258 
   260 
   259     aPkiService.ReadCertificateL(aTrustedCaDn, aSubjectDnSuffix, aRfc822NameFqdn, EPKIUserCertificate,
   261     aPkiService.ReadCertificateL(aTrustedCaDn, aSubjectDnSuffix, aRfc822NameFqdn, EPKIUserCertificate,
   281         User::WaitForRequest(status);
   283         User::WaitForRequest(status);
   282 
   284 
   283         aPkiService.Finalize(opContext);
   285         aPkiService.Finalize(opContext);
   284         }
   286         }
   285 
   287 
   286 
       
   287     // Make sure that the cert, if found, is valid
   288     // Make sure that the cert, if found, is valid
   288     if (status.Int() == KErrNone)
   289     if (status.Int() == KErrNone)
   289         {
   290         {
   290         certStatus = PkiUtil::CertStatusL(*certData, aCertRenewalThreshold);
   291         certStatus = PkiUtil::CertStatusL(*certData, aCertRenewalThreshold);
   291         }
   292         }
   292     else //if not found, check wether certificate chain exists
   293     else //if not found, check wether certificate chain exists
   293         {
   294         {
   294         certStatus = ECertNotFound;
   295         certStatus = ECertNotFound;
       
   296         
   295         //checking if certificate chain is found
   297         //checking if certificate chain is found
   296         CleanupStack::PopAndDestroy(); //  certData
   298         CleanupStack::PopAndDestroy(); //  certData
   297         
   299         
   298         certData=NULL;
   300         certData=NULL;
   299         certData = HBufC8::NewL(KExpectedMaxCertSize);
   301         certData = HBufC8::NewL(KExpectedMaxCertSize);
   709                 User::Leave(KErrNotFound);
   711                 User::Leave(KErrNotFound);
   710                 }
   712                 }
   711 
   713 
   712             for (TInt i = 0; i < certListArray->Count(); ++i)
   714             for (TInt i = 0; i < certListArray->Count(); ++i)
   713                 {
   715                 {
   714                 TCertificateListEntry entry = (*certListArray)[i];
   716                 TCertificateListEntry& entry = (*certListArray)[i];
   715                 if (entry.iOwnerType == EPKICACertificate)
   717                 if (entry.iOwnerType == EPKICACertificate)
   716                     {
   718                     {
   717                     CX509Certificate* cert = ReadCertificateLC(aPkiService,
   719                     CX509Certificate* cert = ReadCertificateLC(aPkiService,
   718                                                                KEmptyString,
   720                                                                KEmptyString,
   719                                                                entry.iIdentitySubjectName,
   721                                                                entry.iIdentitySubjectName,
   845                 if (status != ECertNotFound)
   847                 if (status != ECertNotFound)
   846                     {
   848                     {
   847                     break;
   849                     break;
   848                     }
   850                     }
   849                 }
   851                 }
       
   852             
   850 
   853 
   851             CleanupStack::PopAndDestroy(rfc822Name);
   854             CleanupStack::PopAndDestroy(rfc822Name);
   852             CleanupStack::PopAndDestroy(subjectName);
   855             CleanupStack::PopAndDestroy(subjectName);
   853         }
   856         }
   854 
   857