c# - Scanning certificates store does not show all certificates -


i created c#.net console program listed below scan certificate stores , show certificate information. problem is not showing certificates.

for example, command line shows certificates in personal store:

certutil.exe -store 

however test program shows having no personal certificates. using windows 2008 r2. here abbreviated console app. idea might doing wrong? tried both in regular cmd window, , administrator same results.

using system; using system.linq; using system.security.cryptography.x509certificates; using system.collections;  namespace certview {     class program     {         static int main(string[] args)         {             var stores = enum.getvalues(typeof(storename));             ienumerator enumstores = stores.getenumerator();             foreach (storename sn in stores)             {                 x509store str = new x509store(sn.tostring());                 str.open(openflags.readonly);                 int count = str.certificates.count;                 if (count > 0)                 {                     console.writeline("store: " + sn.tostring() + environment.newline);                     foreach (x509certificate2 x509 in str.certificates)                     {                         console.writeline("friendly name: {0}", x509.friendlyname);                         console.writeline("issued to: " + x509.getnameinfo(x509nametype.simplename, false));                         console.writeline("issued by: " + x509.getnameinfo(x509nametype.simplename, true));                         console.writeline("thumbprint: " + x509.thumbprint);                         x509.reset();                     }                 }                 str.close();             }         }     } } 

this because certutil default focuses on localmachine store, while x509store focuses on currentuser store. read remarks section on x509store constructor: https://msdn.microsoft.com/en-us/library/h16bc8wd(v=vs.110).aspx

you need use different constructor specify store location. example, one: x509store(storename, storelocation)


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -