1

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 ?

BrosseAdan
  • 31
  • 1
  • 7
  • Maybe the key that your customer is using, is stored in a place, where your GetRSAPrivateKey() method doesn't have access to and you need to use different one for this one? Or try to use Desktop Bridge. Just throwing ideas. – Michal Kania Dec 14 '18 at 11:07
  • Thanks for your ideas.Actually, to solve the case, we're using Desktop Bridge, but we were thinking we could not use it anymore, as it seems to be more complicated to get the approval from Microsoft. – BrosseAdan Dec 14 '18 at 11:15
  • Have you checked this [reply](https://stackoverflow.com/a/44584826/7254781)? – Nico Zhu Dec 17 '18 at 07:41
  • Yes, I did and unfortunately it doesn't solve my issue. – BrosseAdan Dec 17 '18 at 14:29
  • Could you share more detail about the usb key that work well? we want to exclude hardware cause this problem. – Nico Zhu Dec 19 '18 at 06:39
  • Sure! We're using keys from https://www.certigna.fr/ : those keys works very well with the code above, without the need to install specific drivers.... ... but, we also found a customer where the application doesn't work on a Win10 even if he's using the same usb keys : for him we had to install the vendor drivers, and use a desktop bridge application controlled by the UWP application (which is, in turn, what we did the keys from tuntrust). – BrosseAdan Dec 20 '18 at 09:08
  • Hi @BrosseAdan, I have escalate this issue, But we need more detail about this case, Please give a complete repro sample (MCVe) and instructions for setting up the repro along with what steps to follow in the sample repro app if it’s more than just launching the app. – Nico Zhu Dec 21 '18 at 07:00
  • Hi @NicoZhu-MSFT, thanks for the escalation! I'll give you that as soon as I can. What's your favorite solution to share the code ? – BrosseAdan Dec 21 '18 at 07:35
  • You could share the code sample with one-drive. – Nico Zhu Dec 21 '18 at 07:36
  • Ok, I'll do that! – BrosseAdan Dec 21 '18 at 07:38
  • @BrosseAdan Do you have any updates here ? – Nico Zhu Jan 08 '19 at 02:57
  • @NicoZhu-MSFT hello. yes sorry, I was in holidays, now I have to unstack some emails, and giving you the sample is my next task! – BrosseAdan Jan 08 '19 at 07:04
  • I haven’t seen any activity from the you since 8 Jan. I’ve archived this ticket. It will be marked as closed. A new ticket can be created when sufficient details are shared to reproduce the problem. – Nico Zhu Jan 14 '19 at 01:52
  • Hello @NicoZhu-MSFT, sorry for the delay, I was unable to work on getting you the MVCE earlier. Here is a link for the VS proj : https://1drv.ms/u/s!AlckMlG7KLGkaaczptwDEybV3po Thanks again for your help! – BrosseAdan Jan 15 '19 at 14:58
  • Ok, I receive your comment, And I will escalate this issue to related team. – Nico Zhu Jan 16 '19 at 02:38
  • @NicoZhu-MSFT : thank you ! – BrosseAdan Jan 16 '19 at 07:30
  • @NicoZhu-MSFT Hello, any news about this subject ? Thanks ! – BrosseAdan Feb 13 '19 at 09:35
  • We just back to work from holiday, I will check the case state. – Nico Zhu Feb 13 '19 at 09:39
  • @NicoZhu-MSFT Hi! Any news ? Thanks ! – BrosseAdan Mar 18 '19 at 09:32

0 Answers0