简体   繁体   English

Mac上的Xamarin / Visual Studio-iPhone-无法列出X509Store证书

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

Environment Device: . 环境设备: iPhone6s iPhone6s

Development Environment: .net Standard 1.5, Visual Studio on Mac Community Version 7.2.2 (build 7), Xamarin 开发环境: .net Standard 1.5,Mac Community版本7.2.2(内部版本7)上的Visual Studio,Xamarin

I have the following code to get/list Certificates that are installed on my iPhone. 我有以下代码来获取/列出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. 我正在使用开发配置文件在iPhone上运行代码。

I have 2 projects a portable Project and an iOS project. 我有2个项目,一个可移植项目和一个iOS项目。 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. 我也尝试过访问StoreName.Root,StoreName.CertificateAuthority以及OpenFlags的变体,例如.ReadWrite-相同结果没有数据。

Looking for input/thoughts. 寻找输入/想法。

Unfortunately, it is not supported on iOS, here's the explanation from Apple side: 不幸的是,iOS不支持它,这是Apple方面的解释:

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. 似乎您在乎通过MDM安装的数字身份。 Credentials installed that way are placed in an Apple keychain access group and, as such, are only accessible to Apple apps. 以这种方式安装的凭据将放置在Apple钥匙串访问组中,因此,仅Apple应用程序可以访问。 QA1745 Making Certificates and Keys Available To Your App discusses this in more detail. QA1745 使证书和密钥可用于您的应用程序对此进行了详细讨论。

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? 更多详细信息,请参阅Apple Developer Forum中的相关案例: 如何从iOS设备获取证书列表?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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