当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Changing the Pin of a Virtual SmartCard in Windows 10

问题描述:

In our environment we need a virtual smart card for VPN authentication under Windows 10 and we need to create a little tool for the users to change the pin of the virtual smart cards.

I've downloaded the Smart card sample to see how to create a virtual smart card and change it's pin. But I'm having trouble with running the code.

My first problem is, that I'm getting a 'The request requires elevation' Exception on calling the method RequestVirtualSmartCardCreationAsync. I'm using the default parameters defined in the project. I tried to log-in as an Admin and Visual Studio is also started as Administrator. I also made sure that the 'Shared User Certificates' option is checked under Capabilities in the appxmanifest.

Next I tried to create a virtual smart card with the tpmsvcmgr.exe command line tool. The command line was: tpmvscmgr.exe create /name myVSC /pin prompt /adminkey default /generate

I made sure that the virtual smart card was generated successfully by finding it in the device manager under Smartcard-Readers.

Next I modified the code from the sample by setting the SmartCardReaderDeviceId in the ValidateTPMSmartCard() method just before the check whether the string is empty.

I tried different values for this variable but I'm still getting Exceptions in the GetSmartCard() method on SmartCardReader.FromIdAsync during code execution. Here are the values that I tried with the according Exceptions that I get:

//NO_SUCH_DEVICE_INTERFACE

SmartCardReaderDeviceId = "ROOT\\SMARTCARDREADER\\0000";

//NO_SUCH_DEVICE_INTERFACE

SmartCardReaderDeviceId = "\\ROOT\\SMARTCARDREADER\\0000";

//NO_SUCH_DEVICE_INTERFACE

SmartCardReaderDeviceId = "\\\\?\\ROOT#SMARTCARDREADER#0000";

//REQUEST_NOT_SUPPORTED

SmartCardReaderDeviceId = "\\\\?\\ROOT#SMARTCARDREADER#0000#{50dd5230-ba8a-11d1-bf5d-0000f805f530}";

//NO_SUCH_DEVICE_INTERFACE

SmartCardReaderDeviceId = "50dd5230-ba8a-11d1-bf5d-0000f805f530}";

Does anyone know either how to get this SDK sample to work or how to change the PIN of a virtual smart card programatically?

I'm running this Project under Windows 10.0.10586 with Visual Studio Enterprise 2015 on a Surface Pro 4.

分享给朋友:
您可能感兴趣的文章:
随机阅读: