0

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

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

我错过了什么?帮助将不胜感激。

迪诺

4

1 回答 1

0

如果您希望其他应用程序可以访问证书,则需要使用CertificateEnrollmentManager.UserCertificateEnrollmentManager.ImportPfxDataAsyncthen注册它CertificateEnrollmentManager.ImportPfxDataAsync

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

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

于 2015-09-29T08:58:42.217 回答