CryptAcquireContext and Windows Services...

From: Steve H (netspam_at_shic.co.uk)
Date: 09/30/03


Date: 30 Sep 2003 09:24:34 -0700


I'm running into difficulties trying to retrieve a certificate from
the certificate store for use with GSS_SCHANNEL for an "NT Service"
(Written in VC++ 7 with ATL 7) under XP.

When I run MMC with the Certificates snap-in I see there are three
different containers:
  * My user account
  * Service account
  * Computer account

I have a working program (executed as a straightforward executable by
the current user which calls (omitting error checking for brevity):

    CryptAcquireContext(&provider,NULL,NULL,PROV_RSA_SCHANNEL,0);
    cert_store=CertOpenSystemStore(provider,L"My");
    cert=CertFindCertificateInStore(cert_store,
        X509_ASN_ENCODING|PKCS_7_ASN_ENCODING,0,
        CERT_FIND_ANY,NULL,NULL);

Which works fine to retrieve certificates from "My user account" –
however problems ensure when I use a similar technique for a service.
It doesn't seem to matter if the service is running as the same user
as my executable, or as the local system account,
CryptAcquireContext() returns "Keyset does not exist"
(NTE_KEYSET_NOT_DEF)

I've tried substituting various strings for the second parameter, as
well as setting the CRYPT_MACHINE_KEYSET flag – all to no avail… how
should I determine what the name of the container is for the container
I've already populated using the MMC snapin?

Can anyone offer sample code or a pointer to good documentation on the
subject?

Steve



Relevant Pages

  • Re: IIS 6 Directory Services Mapping ACL Problems
    ... It would appear that you can not delegate Certificate based credentials. ... IIS does not have the user's password, so it can't just logon to the remote ... file server as the user directly. ... Lastly - if you want to see what account is being used to access the remote ...
    (microsoft.public.inetserver.iis.security)
  • Re: How do I deal with "Password Synchronization is not supported"
    ... It just means that you need to select a local account (an account local to ... You can not allocate an SSL Certificate to a single folder. ... and then click Default Web Site. ... In the Anonymous User Account dialog box, ...
    (microsoft.public.inetserver.iis.security)
  • Re: Protecting Directories
    ... If you do, then only your account, and an optionally ... If you select to use EFS, then you should be certain that you ... For this your machine needs a smart card ... an issueing authority for the certificate on the card. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: X509 digital certificate for offline solution
    ... > license blind signatures at that time (great that the patent expired now ... giving the person's current account balance (at the time the ...
    (microsoft.public.dotnet.security)
  • Re: EFS and transparent file sharing on XP pro
    ... As the account is an admin it has two ways available to ... EFS encrypted files of that account. ... then the next attempt to encrypt a file ... XP pro added a new> certificate for EFS for my userid. ...
    (microsoft.public.windows.server.security)