ID: 17738 Comment by: michael at akatose dot de Reported By: benoit at gide dot net Status: No Feedback Bug Type: LDAP related Operating System: Redhat 6.2 7.1 7.2 PHP Version: 4.2.1 New Comment:
Ok, this problem vanished, as soon as I replaced the wildcard-certificate at the LDAP server (CN=*.example.com) with a "simple" certificate (CN=ldap.example.com). I double-checked this with another wildcard-certificate, which is also accepted by the command line utilities. Again, PHP's ldap_start_tls() returns false and gives its warning "Unable to start TLS: Connect error". A capture of the network traffic to the LDAP server reveals, that even though ldap_start_tls() returns false, the connection is encrypted afterwards. So it seems, that the handling of the return code is wrong, when using wildcard-certificates. Previous Comments: ------------------------------------------------------------------------ [2006-10-01 02:35:13] michael at akatose dot de This error not only happens with SSL (ldaps), but also when using StartTLS. On my system, the correct CA certificate is referenced in /etc/ldap/ldap.conf and command line utilities can connect without problems: ~# ldapsearch -v -x -ZZ "(objectClass=*)" ldap_initialize( <DEFAULT> ) filter: (objectClass=*) requesting: ALL # extended LDIF # ... But the following PHP script fails (on PHP-5.1.2 from Ubuntu-6.06): <?php $server = ldap_connect("ldap://ldap.example.com"); ldap_set_option($server, LDAP_OPT_PROTOCOL_VERSION, 3); $result = ldap_read($server, "dc=example,dc=com", "(objectclass=*)"); $entry = ldap_get_entries($server, $result); print_r($entry); // everything works fine up to this point // no network problems, we are really talking to the server ldap_start_tls($server); // this fails: // Warning: ldap_start_tls() [function.ldap-start-tls]: // Unable to start TLS: Connect error in /var/www/ldaptest.php on line 10 ldap_close($server); ?> As you can see a "Connect error" is returned, altough this seems to be an error while checking the server certificate. I can get the command line utilities to throw the same error by making the CA certificate unreadable: ~# ldapsearch -v -x -ZZ "(objectClass=*)" ldap_initialize( <DEFAULT> ) ldap_start_tls: Connect error (-11) The PHP script will work, if I disable the verification of the server certificate by putting the already mentioned "TLS_REQCERT never" in /etc/ldap/ldap.conf ------------------------------------------------------------------------ [2004-12-09 09:54:25] sami at sipponen dot com "phpdeveloper at chinese dot university dot hk"'s problem seems to be related an issue with PHP Windows build's "not so good documented features"... See the link below: http://www.ldaphelp.com/viewtopic.php?t=6 It seems that there are some hard coded config file issues with PHP's ldap extension. Copy&paste from the site which link is above: create the directory: C:\OpenLDAP\sysconf\ and put there a ldap.conf file which contains in its first line: TLS_REQCERT never ------------------------------------------------------------------------ [2003-07-19 00:18:04] phpdeveloper at chinese dot university dot hk i am using IIS+windows xp+php4.3.2.2 facing the same problem and can not connect to the ldap except using ldaps://host:636/ but success using ldap://host/ ------------------------------------------------------------------------ [2002-09-11 11:19:30] [EMAIL PROTECTED] No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. ------------------------------------------------------------------------ [2002-06-21 15:17:11] [EMAIL PROTECTED] If you use the OpenLDAP 2.x.x lib, the script below should work. At least I don't see anything wrong. Only error I can think of is that the lib isn't compiled with SSL, but if this was the lib used when building ldapsearch, then this should be okay too. PHP doesn't really do anything clever with LDAP and SSL here, it only passes the URL to the lib in ldap_connect() and the lib will/should use SSL since the URL starts with ldaps. This is exactly what ldapsearch does too. So I don't really see what's wrong here. I would try to see what LDAP library is used and check whether it's compiled with SSL. strace/tcpdump/gdb might be of use to see what's going on. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/17738 -- Edit this bug report at http://bugs.php.net/?id=17738&edit=1