Does STACK_OF(X509_NAME) need to be free'd when using SSL_load_client_CA_file?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, May 09, 2015 at 05:16:22AM -0400, Jeffrey Walton wrote:

> Does STACK_OF(X509_NAME) need to be free'd when using SSL_load_client_CA_file?

Yes, unless it is passed to SSL_CTX_set_client_CA_list() which
takes ownership of the stack.  That is, you must not free a stack
that is passed to that function, because the stack will be freed
when the context is freed.

> s_server.c uses it like so, but I'm not sure if its correct:
> 
>     if (caFile != NULL) {
>         SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(caFile));

This is correct.

> Or does SSL_CTX_set_client_CA_list take ownership or assign ownership
> to the context?

It takes ownership.  

By the way, there is an implementation oddity in SSL_load_client_CA_file().
It builds two stacks, one of which is always freed.  I don't know
why.  The second seems to be used for duplicate detection, but I
fail to see why the returned stack can't be used for that.

-- 
	Viktor.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux