Hi all,
I have this code in my page ASPX, Page_Load method.
I have a certificate in certmgr.msc -> Personal -> Certificates.
I have imported this certificate in IExplorer. Now, I can see it in Tools -> Options -> Content -> Certificates -> Tab Personal
My code works right if execute the web application using "Cassini" (webserver in Visual Studio). In this case, store.Certificates.Count = 1.
If use IIS in Windows XP SP3 my code is wrong (store.Certificates.Count = 0)
Any suggestions, help, please ? Any help will be very appreciated.
Thanks in advance, regards,
// get cert from store
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(
OpenFlags.ReadOnly);
Response.Write(
"Total certificados: " + store.Certificates.Count + "<br>");
if (store.Certificates.Count > 0)
X509Certificate2 cert2 = store.Certificates[0];
Response.Write(
"<br>FriendlyName " + cert2.FriendlyName);
Response.Write(
"<br>SubjectName.Name " + cert2.SubjectName.Name);
Response.Write(
"<br>Subject " + cert2.Subject);
Response.Write(
"<br>SerialNumber " + cert2.SerialNumber);
string subject = "CN=Pxxxx Vxxxx Exxxx, OU=Proveedores, OU=Informatica Desarrollo, OU=Informtica, OU=EXTERNOS, OU=Personal, DC=rzzzz, DC=net";
X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName, subject, false);
if (col.Count > 0)
X509Certificate2 cert2 = col[0];
Response.Write(
"<br>FriendlyName " + cert2.FriendlyName);
Response.Write(
"<br>SubjectName.Name " + cert2.SubjectName.Name);
Response.Write(
"<br>Subject " + cert2.Subject);
Response.Write(
"<br>SerialNumber " + cert2.SerialNumber);
}
{
}
{