.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Certificates in asp.net
 

Certificates in asp.net


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);

}

{

}

{

Alhambra Eidos Development
Try installing the certificate under LocalMachine instead of under CurrentUser account.
AnanthR
Try installing the certificate under LocalMachine instead of under CurrentUser account.
AnanthR

You can use google to search for other answers

Custom Search

More Threads

• Process cannot access file because it is being used by another process...
• accessing the call stack via reflection: find the EventInfo object
• Knowing the control which caused the post back at Page_Load
• backgroundworker thread and soap call.
• ConfigurationErrorsException on Saving
• How do I get a user's domain name?
• Accessing folders in windows 2003 server.
• How to setup x509 certificate store and exchange public and private keys with recipent
• Accesing a command line interface
• How to Secure Delete a file?