Subject: Try initializing Context to NULLSCMCTX
Try initializing Context to NULLSCMCTX and see if that solves the problem.
If you call SECManipulateSC with a non-null, non-initialized context for any function but SC_manip_GetVersion, it should return ERR_BSAFE_BADCTX (0x1708). However, if Context points to an invalid section of memory, you’ll probably get an access violation.
SCMCTX Context = NULLSCMCTX;
error = SECManipulateSC (SC_manip_InitializeContext, &Context, NULL, NULL, NULL);
A check of the documentation shows that it does state that the context must be initialized to NULLSCMCTX, but it could definitely be clearer. I’ll see if I can get that wording improved…
“pContext - Address of a NULLSCMCTX. See NULLSCMCTX”
by the way, extension manager is! called with smartcard-enabled ids.
The extension manager may be called, but you probably won’t have much luck unlocking a smartcard-protected ID through that route, at least not currently. Would you find it useful to be able to unlock a smartcard-protected ID file by placing the PIN in an extension manager callout, should that functionality be added to a future release?
what i also really need is an easy way to tell, if an id-file has been sc-enabled.
I don’t believe that there are currently any single functions in the C API that will reveal if an ID file is smartcard-protected. That being said, you can call SC_manip_InitializeContext, then SC_manip_EnterIDFile, then SC_manip_PushInetKey to achieve the same purpose. SC_manip_PushInetKey will fail, because the smartcard was never unlocked with SC_manip_EnterPIN. However, if the ID file is not smartcard-enabled, PushInetKey will return “The password for this ID file is not stored on a smartcard.” If the ID file is smartcard-enabled, PushInetKey will return “Incorrect PIN”.
Hope that helps,
dave