【问题标题】:How to access app's certificate store in Windows Phone 8.1 Runtime App如何在 Windows Phone 8.1 运行时应用程序中访问应用程序的证书存储
【发布时间】:2015-07-07 14:38:44
【问题描述】:

我想从另一个应用程序访问我的应用程序的证书存储。我已经在package.appmanifest 文件中启用了"sharedusercertificates"

Windows.Storage.StorageFile selectedCertFile = await folder.GetFileAsync(fileName);
IBuffer buffer = await FileIO.ReadBufferAsync(selectedCertFile);

string certificateData = CryptographicBuffer.EncodeToBase64String(buffer);
string password = "password";

await CertificateEnrollmentManager.ImportPfxDataAsync(
certificateData,
password,
ExportOption.NotExportable,
KeyProtectionLevel.ConsentWithPassword,
InstallOptions.None,
selectedCertFile.DisplayName);

在我自己的应用中,我可以毫无问题地列出已安装的证书:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    var task = CertificateStores.FindAllAsync();
    task.AsTask().Wait();
    var certlist = task.GetResults();
    Debug.WriteLine("Cert count: {0}", certlist.Count);
    LoadCertList(certlist);
}

private void LoadCertList(IReadOnlyList<Certificate> certificateList)
{
    listbox1.Items.Clear();

    foreach (Certificate cert in certificateList)
    {
        listbox1.Items.Add(cert.Subject);
    }
}

如果我尝试从其他应用程序访问它们,它将不会被列出。 在 Windows Phones 8.1 的邮件客户端设置中,安装的证书也丢失了。列出了定期安装的证书,而不是以编程方式安装的证书。

有没有办法将我的自定义证书安装到系统的证书存储中?所以它可以在其他应用程序中使用。

我已经在网上搜索了几天,但没有找到解决方案。

正因如此,应该是可以的。

“sharedUserCertificates 功能授予应用程序容器读取所有用户存储和智能卡受信任根存储中包含的证书和密钥的权限。” https://msdn.microsoft.com/en-us/library/windows/apps/hh465025.aspx

我错过了什么吗?非常感谢您的帮助。

恐龙

【问题讨论】:

    标签: windows-phone-8.1 certificate smime certificate-store


    【解决方案1】:

    如果您希望其他应用可以访问证书,则需要使用CertificateEnrollmentManager.UserCertificateEnrollmentManager.ImportPfxDataAsync 而不是CertificateEnrollmentManager.ImportPfxDataAsync 注册它。

    请注意,除非已过期,否则无法删除共享证书(使用InstallOptions.DeleteExpired 作为ImportPfxDataAsync 中的参数)。

    此外,您以这种方式共享的证书越多,对证书存储的查询就越慢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多