Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have a application run in windows logon screen as self reset password, that'll allow user using smartcard to reset password. but what i receive is when open list of certifate just show some of cert (not all certificate in smartcard)

I using this code to list cert

C#
if (!NativeMethods.CryptAcquireContext(ref hProv, null, providerName, NativeMethods.PROV_RSA_FULL, NativeMethods.CRYPT_VERIFYCONTEXT))
           throw new Win32Exception(Marshal.GetLastWin32Error());
         uint pcbData = 0;

if (!NativeMethods.CryptGetProvParam(hProv, NativeMethods.PP_USER_CERTSTORE, null, ref pcbData, 0))
           throw new Win32Exception(Marshal.GetLastWin32Error());
         X509Certificate2 cert;

         X509Certificate2Collection certificate2Collection;

         X509Certificate2Collection certlist = new X509Certificate2Collection();

         List<X509Certificate2> certTempList = GetCertificates(providerName);

         foreach (var cer in certTempList)
         {                            
             certlist.Add(cer);                        
         }
certificate2Collection = X509Certificate2UI.SelectFromCollection(certlist, title, description, X509SelectionFlag.SingleSelection);


but in list are not show all certificate in smart card (i have 5 cert but just show 3 as example)

Anyone can help me?
Thanks
/Nguyen

What I have tried:

C#
<pre lang="C#">if (!NativeMethods.CryptAcquireContext(ref hProv, null, providerName, NativeMethods.PROV_RSA_FULL, NativeMethods.CRYPT_VERIFYCONTEXT))
           throw new Win32Exception(Marshal.GetLastWin32Error());
         uint pcbData = 0;

if (!NativeMethods.CryptGetProvParam(hProv, NativeMethods.PP_USER_CERTSTORE, null, ref pcbData, 0))
           throw new Win32Exception(Marshal.GetLastWin32Error());
         X509Certificate2 cert;

         X509Certificate2Collection certificate2Collection;

         X509Certificate2Collection certlist = new X509Certificate2Collection();

         List<X509Certificate2> certTempList = GetCertificates(providerName);

         foreach (var cer in certTempList)
         {                            
             certlist.Add(cer);                        
         }
certificate2Collection = X509Certificate2UI.SelectFromCollection(certlist, title, description, X509SelectionFlag.SingleSelection);

</pre>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900