http://bugs.winehq.org/show_bug.cgi?id=27168
--- Comment #23 from Ilya Konovalov aragaer@gmail.com 2011-09-18 05:41:56 CDT --- (In reply to comment #18)
Probably the certificate should increase the reference count on the store, and decrement it when it's freed. This might take a bit of work to get right.
Trying to do it... And finding all the certificate store stuff is a bit overcomplicated. Duplicating, freeing, duplicating again... Seems quite a mess really.
I've wrote a simple app (https://gist.github.com/a0531270636f407b4a1d) that queries certificate from a google (and it also brings an intermediate certificate) then frees the certificate explicitly using CertFreeCertificateContext. The temporary store is freed (on windows). I'm trying to implement the same in wine but that's where the problem is - removing a certificate from store calls the same CertFreeCertificateContext. What's worse - enumerating certificates in store calls CertFreeCertificateContext.
Looks like it'll take more time to get my head around all the machinery here.