Re: Problem calling CryptSignHash for certificate open in worker thread.
From: Sergio Dutra [MS] (sergiod_at_online.microsoft.com)
Date: Thu, 2 Oct 2003 12:11:31 -0700
These APIs are thread safe and should not be affected by whether it's being
run from a primary thread or worker thread.
The error being returned here is NTE_BAD_KEYSET, which means the private key
with which that certificate is associated with does not exist, or the
current user for the thread does not have access to that key.
I'm not sure what you mean by "the certificate is registered by CryptoAPI".
-- This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm "Jeremy Lloyd" <Jeremy.Lloyd@icsasoftware.com> wrote in message news:euiBXxLiDHA.2420@TK2MSFTNGP10.phx.gbl... > The threads are both running under the same context. At this stage that is > my logon account (I'm a local administrator). Later the process will be > running within a service started with a nominated user account (not the > local system account). > > The worker thread is started with the C++ MFC library function > AfxBeginThread. > > Thanks > Jeremy > > > "Vishal Agarwal[MSFT]" <email@example.com> wrote in message > news:O6jIAxDiDHA.3324@TK2MSFTNGP11.phx.gbl... > > Could you please clarify what you mean by Worker Thread and Primary > Thread? > > Are these threads running under different user context? > > > > Thanks, > > Vishal[MSFT] > > > > -- > > This posting is provided "AS IS" with no warranties, and confers no rights > > "Jeremy Lloyd" <Jeremy.Lloyd@icsasoftware.com> wrote in message > > news:OpDkXODiDHA.1952@TK2MSFTNGP10.phx.gbl... > > > Hi All > > > > > > Hope someone can help with this. I'm finding a certificate in the > > > certificate store and using it to create a context from which I hash > some > > > data and then sign the hash. > > > > > > Signing the hash fails with error 80090016 when the code is run in a > > worker > > > thread and the certificate has been imported through Internet Explorer. > > > > > > The code works fine when executed from the primary thread, *or* when > > > executed from a worker thread with the certificate loaded from a > SmartCard > > > where the certificate has been registered with the CryptoAPI. > > > > > > Is there a problem accessing certain Crypto functions from within a > worker > > > thread. > > > > > > Many thanks > > > Jeremy > > > > > > > > > > > >