[php-src] Issue #22154: [8.4.21] ldap_connect(): Could not create new security context

From: Date: Tue, 26 May 2026 18:12:37 +0000
Subject: [php-src] Issue #22154: [8.4.21] ldap_connect(): Could not create new security context
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-252132@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/22154 Author: Commifreak ### Description The following code: ```php <?php ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); if (isset($_SERVER['HOME']) && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { $ldaprcfile = $_SERVER['HOME'] . '/.ldaprc'; if (!file_exists($ldaprcfile)) { @file_put_contents($ldaprcfile, 'TLS_REQCERT allow') } putenv('LDAPCONF=' . $ldaprcfile); } putenv('LDAPTLS_REQCERT=allow'); putenv('TLS_REQCERT=allow'); $hostPrefix = 'ldaps://my.ldap.server'; $port = 636; ldap_set_option(null, LDAP_OPT_NETWORK_TIMEOUT, 5); $l = ldap_connect($hostPrefix, $port); if (!$l) { echo "Connect to $hostPrefix:$port failed!"; } ldap_set_option($l, LDAP_OPT_NETWORK_TIMEOUT, 5); ldap_set_option($l, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($l, LDAP_OPT_REFERRALS, 0); $bind_dn = 'xxxxx'; $b = ldap_bind($l, $bind_dn, 'xxxxx'); if (!$b && ldap_errno($l) === -1) { // -1 = No TCP connection echo "Connect try #$connTry failed!"; } if (!$b) { echo 'Bind failed! ' . ldap_error($l) . ' - Errno: ' . ldap_errno($l); } 3 $result = ldap_search($l, 'dc=ldap', '(mail=*me*)', ['mail'], 0, -1, -1, LDAP_DEREF_NEVER); $entries = ldap_get_entries($l, $result); ``` Resulted in this output: ``` PHP Warning: ldap_connect(): Could not create new security context in /root/ldap_test.php on line 35 ``` But I expected this output instead: ``` - ``` Maybe this is a known bug, following up from #18529 ? Only 8.4 is not working: | PHP Version | Result | |--------|--------| | 7.3.33-32+ubuntu22.04.1+deb.sury.org+1| OK| | 1:7.4.33-28+ubuntu22.04.1+deb.sury.org+1| OK| | 1:8.0.30-22+ubuntu22.04.1+deb.sury.org+1| OK| | 8.1.34-6+ubuntu22.04.1+deb.sury.org+1| OK| | 8.2.31-3+ubuntu22.04.1+deb.sury.org+1| OK| | 8.3.31-3+ubuntu22.04.1+deb.sury.org+1| OK| | 8.4.21-3+ubuntu22.04.1+deb.sury.org+1| ldap_connect(): Could not create new security context| | 8.5.6-3+ubuntu22.04.1+deb.sury.org+1| OK| ### PHP Version ```plain PHP 8.4.21 (cli) (built: May 14 2026 16:00:34) (NTS) Copyright (c) The PHP Group Built by Ubuntu Zend Engine v4.4.21, Copyright (c) Zend Technologies with Zend OPcache v8.4.21, Copyright (c), by Zend Technologies with Xdebug v3.5.0, Copyright (c) 2002-2025, by Derick Rethans ``` ### Operating System Ubuntu 22.04

« previous php.bugs (#252132) next »