Issue 4726 - ldap_pvt_tls_init not called when new CTX requested
Summary: ldap_pvt_tls_init not called when new CTX requested
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-30 23:20 UTC by covener@gmail.com
Modified: 2014-08-01 21:05 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description covener@gmail.com 2006-10-30 23:20:54 UTC
Full_Name: Eric Covener
Version: 2.4.3
OS: ppc linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (129.33.49.251)


I'm using 2.4.3 and trying to set SSL client certificates on a per-connection
basis.  

A call to ldap_set_option(ld, LDAP_OPT_X_TLS_NEWCTX, &newctx) fails in my simple
test application because ldap_pvt_tls_init hasn't had a chance to call
SSLeay_add_ssl_algorithms() yet.

I'm not familiar enough w/ openldap to track down how this path occurs, but it
seems like the code in tls.c that handles the SSL_CTX_new() in the event of
LDAP_OPT_X_TLS_NEWCTX should make sure the initializer has been run by calling
ldap_pvt_tls_init()

(My simple test app works when I add SSLeay_add_ssl_algorithms() before
ldap_set_option).  The failure without the call is 

TLS: could not allocate default ctx (336236705).


Comment 1 covener@gmail.com 2006-11-09 21:40:27 UTC
FWIW, Another SDK I'm working with exposes a once-per-process SSL
initialization method, that would amount to ldap_pvt_tls_init();

Comment 2 Howard Chu 2006-11-09 22:01:07 UTC
covener@gmail.com wrote:
> FWIW, Another SDK I'm working with exposes a once-per-process SSL
> initialization method, that would amount to ldap_pvt_tls_init();

A fix for this is in HEAD, please test.

-- 
   -- Howard Chu
   Chief Architect, Symas Corp.  http://www.symas.com
   Director, Highland Sun        http://highlandsun.com/hyc
   OpenLDAP Core Team            http://www.openldap.org/project/

Comment 3 Howard Chu 2006-11-09 22:01:37 UTC
changed notes
changed state Open to Test
moved from Incoming to Software Bugs
Comment 4 covener@gmail.com 2006-11-10 00:20:18 UTC
On 11/9/06, Howard Chu <hyc@symas.com> wrote:
> covener@gmail.com wrote:
> > FWIW, Another SDK I'm working with exposes a once-per-process SSL
> > initialization method, that would amount to ldap_pvt_tls_init();
>
> A fix for this is in HEAD, please test.

Now working for me on HEAD:
ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, /CA.pem);
ldap_set_option(NULL, LDAP_OPT_X_TLS_CERTFILE, "/cert1.pem");
ldap_set_option(NULL, LDAP_OPT_X_TLS_KEYTFILE, "/cert1.key");

ld1 = ldap_init(h,p);
ldap_set_option(ld1, LDAP_OPT_X_TLS_CERTFILE, "/cert2.pem");
ldap_set_option(ld1, LDAP_OPT_X_TLS_KEYTFILE, "/cert2.key");
ldap_set_option(ld1, LDAP_OPT_X_NEW_CTX, &(is_server));

ld2 = ldap_init(h,p);

and connections to ld1 and ld2 send the right client cert over the
wire.  Hope this is a resonable API usage -- Much appreciated!

-- 
Eric Covener
covener@gmail.com

Comment 5 Howard Chu 2006-11-10 00:26:25 UTC
Eric Covener wrote:
> On 11/9/06, Howard Chu <hyc@symas.com> wrote:
>> covener@gmail.com wrote:
>> > FWIW, Another SDK I'm working with exposes a once-per-process SSL
>> > initialization method, that would amount to ldap_pvt_tls_init();
>>
>> A fix for this is in HEAD, please test.
> 
> Now working for me on HEAD:
> ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, /CA.pem);
> ldap_set_option(NULL, LDAP_OPT_X_TLS_CERTFILE, "/cert1.pem");
> ldap_set_option(NULL, LDAP_OPT_X_TLS_KEYTFILE, "/cert1.key");
> 
> ld1 = ldap_init(h,p);
> ldap_set_option(ld1, LDAP_OPT_X_TLS_CERTFILE, "/cert2.pem");
> ldap_set_option(ld1, LDAP_OPT_X_TLS_KEYTFILE, "/cert2.key");
> ldap_set_option(ld1, LDAP_OPT_X_NEW_CTX, &(is_server));
> 
> ld2 = ldap_init(h,p);
> 
> and connections to ld1 and ld2 send the right client cert over the
> wire.  Hope this is a resonable API usage -- Much appreciated!
> 
Thanks for the confirmation.

The is_server flag only needs to be set non-zero if you are going to be 
accepting incoming TLS sessions with that context.

-- 
   -- Howard Chu
   Chief Architect, Symas Corp.  http://www.symas.com
   Director, Highland Sun        http://highlandsun.com/hyc
   OpenLDAP Core Team            http://www.openldap.org/project/

Comment 6 Howard Chu 2007-01-25 02:22:07 UTC
moved from Software Bugs to Development
Comment 7 Howard Chu 2007-02-18 16:05:16 UTC
changed notes
changed state Test to Release
Comment 8 Howard Chu 2007-02-21 14:45:03 UTC
changed state Release to Closed
Comment 9 Howard Chu 2009-02-17 06:56:04 UTC
moved from Development to Archive.Development
Comment 10 OpenLDAP project 2014-08-01 21:05:24 UTC
fixed in HEAD/re24