[Mono-dev] System.Security.Cryptography.X509Certificates Mono-2.10.2
will.omalley
omalley.william at gmail.com
Thu Dec 22 12:54:02 EST 2011
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.
More information about the Mono-devel-list
mailing list