You Are Here:

Community: Wiki


TSS001441 - Listing the certificates on the device using unified certificate store API

From Forum Nokia Wiki



ID TSS001441 Creation date June 23, 2009
Platform S60 3rd Edition, FP1
S60 3rd Edition, FP2
Devices Tested on Nokia N95
Category Symbian C++ Subcategory Signing and Certification


Keywords (APIs, classes, methods, functions): CUnifiedCertStore

Description

The CUnifiedCertStore class provides a certificate store whose contents are the sum of the contents of all certificate store implementations on the device. It is intended as the single point of access for clients wishing to use certificate stores.

Solution

The following sample code shows how to retrieve the certificates present on the device.

MyClass.h

#include <unifiedcertstore.h>     // link against certstore.lib 
#include <f32file.h> // link against efsrv.lib
#include <ccertattributefilter.h> // link against ctframework.lib
 
// Desclaration of CMyClass
 
class CMyClass : public CActive
{
public:
 
enum TState
{
EGetCerts,
EInitialize
};
 
static CMyClass* NewL();
~CMyClass();
 
void InitL();
void DoListL();
void PopulateListL();
 
protected: // From CActive
virtual void DoCancel();
virtual void RunL();
 
private: // Private constructors
CMyClass();
void ConstructL();
 
private: // Data
 
CUnifiedCertStore* iCertStore;
RMPointerArray<CCTCertInfo> iCerts;
CActiveSchedulerWait iWait;
 
TState iCertCmd;
RFs iFs;
};

MyClass.cpp

#include "MyClass.h"
 
 
CMyClass* CMyClass::NewL()
{
CMyClass* self = new (ELeave) CMyClass;
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(); // self
return self;
}
 
 
CMyClass::CMyClass()
: CActive(CActive::EPriorityStandard)
{
CActiveScheduler::Add( this );
}
 
 
CMyClass::~CMyClass()
{
Cancel();
 
delete iCertStore;
iFs.Close();
iCerts.Close();
}
 
 
void CMyClass::ConstructL()
{
User::LeaveIfError( iFs.Connect() );
iCertStore = CUnifiedCertStore::NewL( iFs, EFalse );
InitL();
}
 
 
void CMyClass::InitL()
{
if( IsActive() )
{
return;
}
 
iCertStore->Initialize( iStatus );
SetActive();
iCertCmd = EInitialize;
iWait.Start();
// RunL called when this completes
}
 
 
void CMyClass::DoListL()
{
CCertAttributeFilter* certFilter = CCertAttributeFilter::NewLC();
certFilter->SetFormat( EX509Certificate );
iCertStore->List(iCerts, *certFilter, iStatus);
SetActive();
iCertCmd = EGetCerts;
iWait.Start();
// RunL called when this completes
 
CleanupStack::PopAndDestroy(); // certFilter
}
 
 
void CMyClass::RunL()
{
iWait.AsyncStop();
if(iStatus == KErrNone)
{
switch(iCertCmd)
{
case EInitialize:
{
DoListL();
PopulateListL();
break;
}
default:
break;
}
}
}
 
 
void CMyClass::DoCancel()
{
switch(iCertCmd)
{
case EInitialize:
{
iCertStore->CancelInitialize();
break;
}
case EGetCerts:
{
iCertStore->CancelList();
break;
}
default:
break;
}
}
 
 
void CMyClass::PopulateListL()
{
for( TInt i = 0; i < iCerts.Count(); i++ )
{
TBuf<KMaxCertLabelLength> iCertLabel;
iCertLabel.Copy( iCerts[i]->Label() );
// ... process each cert label here
}
}

Required capabilities: ReadDeviceData

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTSS000709E5fE2dE5fManagingE5fVoIPE5fprofilesX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxTSS000709E20E2dE20ManagingE20VoIPE20profilesE20E2dE20ForumE20NokiaE20WikiX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2fX qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZupdatedQDx2008E2d10E2d02X qfnZuserE5ftagQSxpluginX qmarsZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ