简体   繁体   中英

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

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 eg .ReadWrite - same result no data.

Looking for input/thoughts.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM