0

I'd like to access my app's certificate store from another app. I have already enabled "sharedusercertificates" in the package.appmanifest file.

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);

In my own app, I can list the installed certificates without a problem:

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);
    }
}

If I try to access those from another app, It will not be listed. In the Windows Phones 8.1's mail client settings, the installed certificate is missing, too. Certificates which have been installed regularly, not programmaticaly, are listed.

Is there a way to install my custom certificates to the system's certificate store? So it can be used in other apps.

I have been searching the web for days now, but I didn't find a solution.

Due to this, it should be possible.

"The sharedUserCertificates capability grants an app container read access to the certificates and keys contained in all user stores and the Smart Card Trusted Roots store. " https://msdn.microsoft.com/en-us/library/windows/apps/hh465025.aspx

Did I miss something? Help will be much appreciated.

Dino

ptCoder
  • 2,229
  • 3
  • 24
  • 38
dino
  • 1
  • 2

1 Answers1

0

If you want a certificate to be accessible for other Apps, you need to enroll it using CertificateEnrollmentManager.UserCertificateEnrollmentManager.ImportPfxDataAsync rather then CertificateEnrollmentManager.ImportPfxDataAsync.

Please note that there is no way of deleting the shared certificate unless it's expired (using InstallOptions.DeleteExpired as a Parameter in ImportPfxDataAsync).

Also, the more certificates you share this way, the slower the queries against the certificate stores get.

Florian-Rh
  • 777
  • 8
  • 26