cryptoservices/certificateandkeymgmt/tcertstore/t_filter.cpp
branchRCL_3
changeset 42 eb9b28acd381
parent 8 35751d3474b7
child 61 641f389e9157
--- a/cryptoservices/certificateandkeymgmt/tcertstore/t_filter.cpp	Sat Feb 20 00:36:18 2010 +0200
+++ b/cryptoservices/certificateandkeymgmt/tcertstore/t_filter.cpp	Fri Mar 12 15:51:07 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
@@ -22,6 +22,7 @@
 #include "t_certstoredefs.h"
 
 #include <ccertattributefilter.h>
+#include <x509cert.h>
 
 CCertAttributeFilter* CFilter::NewL(Output& aOut, 
 									const TDesC8& aFilter)
@@ -81,6 +82,10 @@
 	
 	// Set subjetkeyid filter
 	SetIssuerKeyIdFilter(Input::ParseElement(aFilter, KIssuerKeyIdStart));
+	
+	// Set subjetkeyid using the certificate details
+	SetSubjectKeyIdFromCertFilterL(Input::ParseElement(aFilter, KUseSubjectKeyIdStart));
+		
 	}
 
 void CFilter::SetLabelFilter(const TDesC8& aLabel)
@@ -386,4 +391,22 @@
 		}
 	}
 
+void CFilter::SetSubjectKeyIdFromCertFilterL(const TDesC8& aCertPath)
+	{
+	if(aCertPath != KNullDesC8)
+		{
+		RFs fs;
+		User::LeaveIfError(fs.Connect());
+		CleanupClosePushL(fs);
+		TFileName filename;
+		filename.Copy(aCertPath);
+		HBufC8* buf = Input::ReadFileL(filename, fs);
+		CleanupStack::PushL(buf);
+		CX509Certificate* cert = CX509Certificate::NewLC(buf->Des());
+		TKeyIdentifier id = cert->SubjectKeyIdL();
+		CleanupStack::PopAndDestroy(3, &fs); // buf, cert, fs
+		iFilter->SetSubjectKeyId(id);
+		}
+	}
+
 CCertAttributeFilter* CFilter::iFilter = NULL;