Re: Problem calling CryptSignHash for certificate open in worker thread.

From: Sergio Dutra [MS] (sergiod_at_online.microsoft.com)
Date: 10/02/03


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".
Please elaborate.

-- 
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]" <vishala@online.microsoft.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
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: Problem calling CryptSignHash for certificate open in worker thread.
    ... The threads are both running under the same context. ... my logon account. ... > Could you please clarify what you mean by Worker Thread and Primary ... >> certificate store and using it to create a context from which I hash ...
    (microsoft.public.platformsdk.security)
  • Re: Problem calling CryptSignHash for certificate open in worker thread.
    ... certificate through IE, are you importing the PFX or just the certificate? ... > my logon account. ... >> Could you please clarify what you mean by Worker Thread and Primary ...
    (microsoft.public.platformsdk.security)
  • Re: Query related to Worker Thread & MessageBox?
    ... I don't see any issue with your primary thread popping up the message box. ... > In my application i am doing heavy processing using worker threads so that ... > Is this display of msg box by the main thread fine while the worker thread ... But here in my case the msg box is thrown ...
    (microsoft.public.vc.mfc)
  • Re: Too many Post Messages causing app not to refresh
    ... Take a look at my example of using an I/O Completion Port and the OnIdle ... handler to avoid ... penalty (unlike in your case where perhaps the primary thread needs to know ... so my worker thread just called GetTickCount ...
    (microsoft.public.vc.mfc)
  • Re: Threading in ASP.NET
    ... for another account in order for it to run under an impersonated account? ... > | I have an aspx page that runs a whole lot of batch reports. ... > | The ASP.NET worker thread is using impersonation - set in the WEB.CONFIG ...
    (microsoft.public.dotnet.framework.aspnet)