Bug 1011217

Summary: OpenLDAP ignores TLS options
Product: Red Hat Enterprise Linux 6 Reporter: Daniel Sands <dnsands>
Component: openldapAssignee: Jan Synacek <jsynacek>
Status: CLOSED NOTABUG QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.5CC: dspurek, jsynacek
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-24 12:43:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Daniel Sands 2013-09-23 19:51:26 UTC
Description of problem:
When ldap_set_option is used to set the TLS parameters such as CACERTDIR, CERTFILE, and KEYFILE, the settings are unused.  This is because in tls2.c, alloc_handle is called with a null context.  In case of null context, alloc_handle will use the global options to initialize the TLS parameters -- the LDAP handle's options are not available.

OpenLDAP on RHEL6 seems to be using Mozilla NSS, and its deferred initializer function is called only on this initial alloc_handle.  Therefore it only loads certificate authorities from the global default location and does not define a client certificate or key at all.

Setting these values through the environment is the only workaround.

Version-Release number of selected component (if applicable):
Current as of bug report (2.4.23-32)

How reproducible:
Always

Steps to Reproduce:
1.  Set the TLS options programmatically through ldap_set_option
2.  Attempt to connect to a SSL LDAP server

Actual results:
Failure to exchange proper certificates.  If the server certificate is self-signed and not stored in the default CA certificates location, server certificate verification will fail.

Expected results:
Proper SSL negotiation with the expected certificate and CA trusts.

Additional info:
This may be the cause of Bug 760856

Comment 1 Daniel Sands 2013-09-23 22:13:51 UTC
Further trawling through the code shows that if ldap_set_option is called with LDAP_OPT_X_TLS_NEWCTX after setting the other TLS values, it will finally take effect.  The documentation does not say this, though.  So either it's an unintended workaround, or the documentation should be improved to say that this step is necessary.

Comment 2 Jan Synacek 2013-09-24 12:43:14 UTC
Not a bug. See http://www.openldap.org/its/index.cgi?findid=4726.

If you believe the documentation should be updated, please file an RFE.