I'm working on a UWP application where I need to sign data with certificates stored on a usb key.
Here is an extract of my code :
X509Certificate2 myCertificate;
using (var privateKey = cert.GetRSAPrivateKey())
{
if (privateKey == null)
{
return null;
}
[...]
var signedData = privateKey.SignData(dataToBeSigned, algoToUsedToHashData, RSASignaturePadding.Pkcs1);
}
We tested our code with usb keys from a vendor and this works fine. But one of our customer is working with keys from tuntrust (http://www.tuntrust.tn/). With those keys, the test privateKey == null
is true in a UWP project (with the corresponding capacity checked in the appxmanifest) and so we can't sign data, but works fine in a WPF project.
I've tried the certutil -user -repairstore my ""
command line as suggested here : https://stackoverflow.com/a/36734804/2367226 and it's not working better...
Any idea how to fix this ?