Home Xamarin/Visual Studio on Mac - iPhone - Not able to list X509Store certificates
Reply: 1

Xamarin/Visual Studio on Mac - iPhone - Not able to list X509Store certificates

user1811107
1#
user1811107 Published in 2017-11-14 18:09:41Z

Environment Device: . iPhone6s

Development Environment: .net Standard 1.5, Visual Studio on Mac Community Version 7.2.2 (build 7), Xamarin

I have the following code to get/list Certificates that are installed on my iPhone. I have not been successful so far – I get an empty collection when I use the code below.

I am running the code on the iPhone using a development provisioning profile.

I have 2 projects a portable Project and an iOS project. The Code listed below is in the Portable Class library.

using System;
using System.Collections.Generic;
using Xamarin.Forms;

using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

    X509Store paramStore 

    paramStore  = new X509Store(StoreName.My, StoreLocation.CurrentUser) 

    paramStore.Open(OpenFlags.ReadOnly); 
    foreach (X509Certificate2 mCert in paramStore.Certificates)
    {
     numberOfCertificates = numberOfCertificates + 1;

    }

I have also tried accessing StoreName.Root, StoreName.CertificateAuthority along with variations of OpenFlags e.g. .ReadWrite - same result no data.

Looking for input/thoughts.

Kevin Li
2#
Kevin Li Reply to 2017-11-15 07:07:40Z

Unfortunately, it is not supported on iOS, here's the explanation from Apple side:

First, some clarifications:

  • Given that you’re talking about “client authentication” earlier, I presume you’re talking about digital identities rather than certificates. Note A digital identity is the combination of a private key and a certificate that contains the public key that matches that private key, and is what you need to present on the client side if you want the server to authenticate the client.

  • It seems that you care about digital identities installed via MDM. Credentials installed that way are placed in an Apple keychain access group and, as such, are only accessible to Apple apps. QA1745 Making Certificates and Keys Available To Your App discusses this in more detail.

Is there any way to check [whether a digital identity] is installed on [the device]?

Not in general.

More details, please refer to the related case in Apple Developer Forum: How to get Certificates list from iOS device?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.296229 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO