从 Windows 服务访问智能卡所需的权限

发布于 2024-10-02 07:41:49 字数 991 浏览 4 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

亣腦蒛氧 2024-10-09 07:41:49

LocalService 有足够的权限来访问智能卡。这是我采用的解决方案。

The LocalService has enough permissions to access smartcards. This is the solution I went with.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文