Skip to content

Commit 53a74f7

Browse files
committed
Fix php#17776 LDAP_OPT_X_TLS_REQUIRE_CERT can't be overridden
1 parent 8cbc0c5 commit 53a74f7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ext/ldap/ldap.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,17 @@ PHP_FUNCTION(ldap_connect)
987987
snprintf( url, urllen, "ldap://%s:" ZEND_LONG_FMT, host, port );
988988
}
989989

990+
#ifdef LDAP_OPT_X_TLS_NEWCTX
991+
if (!memcmp(url, "ldaps:", 6)) {
992+
int val = 0;
993+
994+
/* ensure all pending TLS options are applied in a new context */
995+
if (ldap_set_option(NULL, LDAP_OPT_X_TLS_NEWCTX, &val) != LDAP_OPT_SUCCESS) {
996+
php_error_docref(NULL, E_WARNING, "Could not create new security context");
997+
}
998+
}
999+
#endif
1000+
9901001
#ifdef LDAP_API_FEATURE_X_OPENLDAP
9911002
/* ldap_init() is deprecated, use ldap_initialize() instead.
9921003
*/

0 commit comments

Comments
 (0)