How to use CertDuplicateCertificateContext and CertFreeCertificateContext

engp5567_at_yahoo.com
Date: 01/28/05


Date: 28 Jan 2005 13:00:18 -0800

Hi there,

I just start using Microsoft Crypto API. Some functions, like
CertDuplicateCertificateContext and CertFreeCertificateContext make me
confused. My questions are:

1) should I call CertDuplicateXXX() and CertFreeXXX() in pairs in my
application to balance the reference count? If I call
CertDuplicateXXX() more than CertFreeXXX(), will it lead to memory
leak?

2) Since I want to
A) pass the cert. context handle to some other called functions,
B) return the cert. context handle to the caller functions, or
C) assign the cert. context handle to another variable,
should I call CertDuplicateXXX() and CertFreeXXX() for thess three
cases? How?

Thanks in advance.

Jason