There is a tiny bug in code above which causes some memory leak. To prevent
that, the line below inside the do {...} while(0) loop:
X509_STORE_CTX *pCertContext =
X509_STORE_CTX_new();
needs to be changed to:
pCertContext = X509_STORE_CTX_new();
