开发者

Accessing current user personal certificate store within windows service

I am working on an application which accesses a x.509 certificate from the current user store. This works fine when the application is run as an executable.

However, when I try running the app as a windows service, it fails to find the certificate开发者_JAVA百科. I tried changing the LogOn property for the windowsservice console to set the right user, but that did not help.

Is there any way I can access the particular user's (Administrator) certificate store? I am bound to use the certificate in the user store - else I can easily use the local machine store.

Any help will be appreciated.

I am using this particular piece of code to retrieve certificate:

                        serviceHost.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "My-CertificateName");

This works fine when running as an executable - but fails to find a certificate when running as a windows service


When I've run into problems like this in the past it's had to do with user permissions, although if you have set your service to run as Administrator, and running the app as an exe as Administrator works then I'm a bit skeptical.

That said, try these two links to start - they're written from a WCF point of view, but easily apply to any type of service:

Working with Certificates

How to: Make X.509 Certificates Accessible to WCF

If neither of those help, please edit your question to include the code that you are using to access the x.509 cert.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜