4

I've got Windows Store/Phone universal app that will have to store certificates. I have no trouble loading the certificates into the app's CertificateStore, and using them. But when it comes to deleting them I have trouble.

For example, the following code works great to find my certificate in the Windows Store environment:

async Task<Certificate> FindMyCert()
{
    var query = new CertificateQuery();
    query.FriendlyName = "mytestcert";
    var certificates = await CertificateStores.FindAllAsync(query);

    if (certificates.Count != 1)
    {
        return null;
    }
    return certificates[0];
}

Now, lets say I want to remove that certificate from the store. The only "Delete" I know about is on the CertificateStore object. So I need to fetch the certificate store and then do the delete:

var s = CertificateStores.GetStoreByName("MY");
if (s != null)
    s.Delete(c);
Assert.IsNull(await FindMyCert());

There is only one problem. If you look at the documentation for GetStoreName1, however, it says that the name of the certificate store can't be "MY".

The irony is this works sometimes and other times it doesn't work. I would guess there is an accepted way to do something like remove a cert from the store. But I have not been able to figure it out.

Many thanks in advance!

Gordon
  • 2,600
  • 2
  • 21
  • 31

1 Answers1

0

We were facing the same problem recently and opened a support ticket on that case. According to MS, this is not possible in Windows Phone 8.1, I'm sorry. It should be supported in Windows 10 though.

Florian-Rh
  • 737
  • 8
  • 26