I can't seem to get rid of a memory leak when I create a proxyCertInfo extension. I've tried calling X509_EXTENSION_free, and then X509_EXT_cleanup. I don't think I need to do that because it is not a custom extension, I'm using
openssl-0.9.8a.

Here's what I've discovered so far.

The X509_EXTENSION_free is a macro that is defined by IMPLEMENT_ASN1_FUNCTIONS. This gives you functions to encode,decode, allocate and deallocate an ASN1 structure. With gdb I can see it stepping through ASN1_item_free, but I don't know why that isn't freeing the memory.

Thanks,
Matt Rodriguez
#include <openssl/x509v3.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
static char * pci_value = "critical, language:Inherit all";

int 
main(int argc, char **argv){
	X509_EXTENSION *ext =NULL;
	X509V3_CTX *ctx; 
	LHASH *lhash;
	SSL_library_init();
	OpenSSL_add_all_ciphers();
	OpenSSL_add_all_algorithms();
	SSL_load_error_strings();
	lhash = lh_new(NULL, NULL); 
    X509V3_set_conf_lhash(ctx, lhash); 
	ext = X509V3_EXT_conf(NULL, ctx, "proxyCertInfo", pci_value);
	if (ext == NULL){
        ERR_print_errors_fp(stderr);
		exit(-1);
	}
    X509V3_EXT_print_fp(stdout, ext, 0, 0);
    X509_EXTENSION_free(ext);
	X509V3_EXT_cleanup();
	/*PROXY_CERT_INFO_EXTENSION_free(ext);*/
	return 0;
}

Reply via email to