从 Windows 服务访问智能卡所需的权限
我有一个 Windows 服务,它使用智能卡执行一些操作。智能卡的证书映射到本地机器的MY存储中。当该服务作为 System 运行时,访问智能卡的私钥没有问题,但当作为 NetworkService 运行时,访问智能卡的私钥会失败。
我已经使用证书 MMC(管理私钥...)向 NetworkService 授予了对证书的访问权限。
我收到的错误是:智能卡资源管理器未运行。
抛出该错误并伴有加密异常。
Stacktrace: at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()
您知道访问智能卡资源管理器需要哪些权限和/或权限吗?
亲切的问候,
亨宁·克劳斯
I have a Windows service which does some stuff using a Smartcard. The certificate of the smartcard is mapped into the MY store of the local machine. Accessing the private key of the smartcard is no problem when the service runs as System, but it fails when run as NetworkService.
I've already granted access to the certificate to the NetworkService using the Certificate MMC (Manage Private Keys...).
The error I get is: The Smart card resource manager is not running.
The error is thrown with a Cryptographic Exception.
Stacktrace: at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()
Any ideas which privileges and/or permissions are required to access the Smart card resource manager?
Kind regards,
Henning Krause
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
LocalService 有足够的权限来访问智能卡。这是我采用的解决方案。
The LocalService has enough permissions to access smartcards. This is the solution I went with.
X509Certificate2 引发“智能卡资源管理器未运行”异常
http://blogs.msdn.com/b/alejacma/archive/2011/05/19/x509certificate2-raises-quot-the-smart-card-resource-manager-is -not-running-quot-exception.aspx
X509Certificate2 raises "The Smart card resource manager is not running" exception
http://blogs.msdn.com/b/alejacma/archive/2011/05/19/x509certificate2-raises-quot-the-smart-card-resource-manager-is-not-running-quot-exception.aspx