locked
Programmatically getting a Certificate from the Window Certificate Store RRS feed

  • Question

  • From another thread, I pieced together the following code, which looked like it would work. The problem is that it's looking for the MyClient.1.cer certificate file in InstalledLocation. Funny, in development I haven't installed my app yet.

    I need to get the certificate from the Windows certificate store. I'd like to believe there's an API in C# to do this. Any pointers?

    Thanks...

    StorageFolder packageLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
    StorageFolder certificateFolder = await packageLocation.GetFolderAsync("Certificates");
    StorageFile certificate = await certificateFolder.GetFileAsync("MyClient.1.cer");
    
    IBuffer buffer = await Windows.Storage.FileIO.ReadBufferAsync(certificate);
    
    HttpBaseProtocolFilter baseFilter = new HttpBaseProtocolFilter();
    baseFilter.ClientCertificate = new Windows.Security.Cryptography.Certificates.Certificate(buffer);
    HttpClient httpClient = new HttpClient(baseFilter);



    Randy

    Thursday, December 12, 2013 8:03 PM

Answers