[Mono-dev] System.Security.Cryptography.X509Certificates Mono-2.10.2
Sebastien Pouliot
sebastien.pouliot at gmail.com
Thu Dec 22 14:43:13 EST 2011
Hello Will,
Mono was written for Linux where no such system/user store existed. As such
mono implemented it's own certificate and key storage. The same code is
executed when you run under Windows so you'll need to import what you need
into them (using mono tools).
Sebastien
On Thu, Dec 22, 2011 at 12:54 PM, will.omalley <omalley.william at gmail.com>wrote:
> I have posted this in Mono-General as well:
> I'm new here so I wanted to make sure I reached people.
>
>
> The following code does not work correctly. When running MonoDevelop on
> Windows XP using the Mono-2.10.2 libraries.
> I have several certificates in AuthRoot, CA, My and TrustedPublisher.
> However, no results get printed to the screen for any store and the
> certificate count is always 0
>
> Full Console Program -- Mono-2.10.2
> OS: Microsoft Windows XP 32
> SP: 3
>
> <CODE>
>
> using System;
> using System.Security;
> using System.Security.Cryptography;
> using System.Security.Cryptography.X509Certificates;
>
> namespace MonoConsoleProject
> {
> class MainClass
> {
> private static X509Store certStore;
>
> public static void Main (string[] args)
> {
> certStore = new X509Store(StoreName.AddressBook,
> StoreLocation.CurrentUser);
> FindCertInStore(certStore, "StoreName.AddressBook,
> StoreLocation.CurrentUser");
> //
> certStore = new X509Store(StoreName.AuthRoot,
> StoreLocation.CurrentUser);
> FindCertInStore(certStore, "StoreName.AuthRoot,
> StoreLocation.CurrentUser");
> //
> certStore = new X509Store(StoreName.CertificateAuthority,
> StoreLocation.CurrentUser);
> FindCertInStore(certStore, "StoreName.CertificateAuthority,
> StoreLocation.CurrentUser");
> //
> certStore = new X509Store(StoreName.Disallowed,
> StoreLocation.CurrentUser);
> FindCertInStore(certStore, "StoreName.Disallowed,
> StoreLocation.CurrentUser");
> //
> certStore = new X509Store(StoreName.My,
> StoreLocation.CurrentUser);
> FindCertInStore(certStore, "StoreName.My,
> StoreLocation.CurrentUser");
> //
> certStore = new X509Store(StoreName.Root,
> StoreLocation.CurrentUser);
> FindCertInStore(certStore, "StoreName.Root,
> StoreLocation.CurrentUser");
> //
> certStore = new X509Store(StoreName.TrustedPeople,
> StoreLocation.CurrentUser);
> FindCertInStore(certStore, "StoreName.TrustedPeople,
> StoreLocation.CurrentUser");
> //
> certStore = new X509Store(StoreName.TrustedPublisher,
> StoreLocation.CurrentUser);
> FindCertInStore(certStore, "StoreName.TrustedPublisher,
> StoreLocation.CurrentUser");
> //
> }
>
> private static void FindCertInStore(X509Store store, string
> storeName)
> {
>
>
> Console.WriteLine("-------------------------------------------------------");
> Console.WriteLine("Listing certs in store: " + storeName);
> Console.WriteLine("Number of certs in store: " +
> store.Certificates.Count.ToString());
> store.Open(OpenFlags.ReadOnly);
> foreach (X509Certificate2 cert in store.Certificates)
> {
> string certName = cert.Subject.ToString();
> Console.WriteLine("Certificate: " + certName);
> }
> store.Close();
>
>
> Console.WriteLine("-------------------------------------------------------");
> Console.WriteLine();
> Console.WriteLine();
> }
>
> }
> }
> </CODE>
>
> --
> View this message in context:
> http://mono.1490590.n4.nabble.com/System-Security-Cryptography-X509Certificates-Mono-2-10-2-tp4226108p4226108.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20111222/0e272f11/attachment.html
More information about the Mono-devel-list
mailing list