How to clear the certificate cache in Universal Windows Platform apps?

Application data for UWP apps are stored in C:\Users\[username]\AppData\Local\Packages\[package_id]

The subfolder AC\Microsoft\CryptnetFlushCache\MetaData appears to contain a record of websites accessed securely via an HttpClient. Research indicates that this folder and its siblings are a cache for SSL/TLS.

How can this cache be cleared from within my own program?

Answers


In UWP app, there is API related to ApplicationData, for example ApplicationData.ClearAsync method, but it can only removes all application data from the local, roaming, and temporary app data stores.

We can use Directory.Delete method to delete this AC folder.

For example:

public static void Clean()
{
    try
    {
        StorageFolder localDirectory = ApplicationData.Current.LocalFolder;
        string path = localDirectory.Path;
        path = path.Substring(0, path.LastIndexOf("\\")) + @"\AC\Microsoft\CryptnetFlushCache\MetaData";
        Directory.Delete(path, true);
    }
    catch (Exception ex)
    {
        Debug.WriteLine("ERROR CLEANING CACHE: " + ex.Message);
    }
}

But there is no document to describe the detailed files stored in this folder, so this may cause unexpected behavior/result in your app.


Need Your Help

Angular filter with typescript is not working after minification

javascript angularjs typescript minify angularjs-filter

I wrote an angular filter with typescript which works fine until I minify the source code.