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
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:
<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>