[Xamarin Mac] Get installed SSL Certificates on a mac RRS feed

  • Question

  • User268308 posted

    Hello, is there a way to get all certificates on a machine using Xamarin.Mac? Something like C# and stores

    Example in C#: public static X509Certificate2Collection getInstalledCertificates() { X509Store store = new X509Store(StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); X509Certificate2Collection currentCerts = store.Certificates.Find(X509FindType.FindByTimeValid, DateTime.Now, false); return currentCerts; }

    Monday, May 22, 2017 11:43 AM

All replies

  • User35201 posted

    Unfortunately, we currently don't appear to have many useful samples exercising X509Certificate2Collection.

    Here is one internal test that uses it.


    Searching for "macos get all installed SSL Certificates' on google gives


    however, that uses a number of APIs not currently bound on Xamarin.Mac.

    You have two options:

    • P/Invoke into the SecKeychain APIs yourself. Most of them should be straight forward, as they are C, if you are knowledgable with p/invokes and C.
    • Write a small unmanaged library which handles this and exposes a simplified API, compile it into a static or dynamic lib, add that as a native reference, and call into that.

    I've filed a bug here: https://bugzilla.xamarin.com/show_bug.cgi?id=56724 but I would not suggest delaying for a binding on our end.

    Monday, May 22, 2017 2:18 PM