Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions datamodels/2.x/authent-ldap/datamodel.authent-ldap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@
$this->LogInfo($bDebug, "ldap_set_option('LDAP_OPT_DEBUG_LEVEL', '{$aOptions[LDAP_OPT_DEBUG_LEVEL]}') returned ".($bRet ? 'true' : 'false'));
}

// Set TLS options globally BEFORE ldap_connect() - required for ldaps:// with client certificates
// (e.g. Google Workspace Secure LDAP). OpenLDAP requires TLS context options (LDAP_OPT_X_TLS_CACERTFILE,
// LDAP_OPT_X_TLS_CERTFILE, LDAP_OPT_X_TLS_KEYFILE) to be set on the global context (null) before
// ldap_connect() is called, otherwise the TLS handshake fails on the first attempt per PHP-FPM worker.
foreach ($aOptions as $name => $value)
{
ldap_set_option(null, $name, $value);
$this->LogInfo($bDebug, "ldap_set_option(null, '$name', '$value')");
}
// Reinitialize TLS context so the new options take effect before connecting
ldap_set_option(null, LDAP_OPT_X_TLS_NEWCTX, 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give a link to PHP documentation about LDAP_OPT_X_TLS_NEWCTX? It doesn't seem to exist.


$hDS = @ldap_connect($sURI);
if ($hDS === false)
{
Expand Down