@@ -942,43 +942,6 @@ PHP_MINFO_FUNCTION(ldap)
942
942
}
943
943
/* }}} */
944
944
945
- /* Force new tls context creation with string options inherited from global */
946
- static int _php_ldap_newctx (LDAP * ld )
947
- {
948
- int val = 0 , i , opts [] = {
949
- #if (LDAP_API_VERSION > 2000 )
950
- LDAP_OPT_X_TLS_CACERTDIR ,
951
- LDAP_OPT_X_TLS_CACERTFILE ,
952
- LDAP_OPT_X_TLS_CERTFILE ,
953
- LDAP_OPT_X_TLS_CIPHER_SUITE ,
954
- LDAP_OPT_X_TLS_KEYFILE ,
955
- LDAP_OPT_X_TLS_RANDOM_FILE ,
956
- #endif
957
- #ifdef LDAP_OPT_X_TLS_CRLFILE
958
- LDAP_OPT_X_TLS_CRLFILE ,
959
- #endif
960
- #ifdef LDAP_OPT_X_TLS_DHFILE
961
- LDAP_OPT_X_TLS_DHFILE ,
962
- #endif
963
- 0 };
964
-
965
- for (i = 0 ; opts [i ] ; i ++ ) {
966
- char * path = NULL ;
967
-
968
- ldap_get_option (ld , opts [i ], & path );
969
- if (path ) { /* already set locally */
970
- ldap_memfree (path );
971
- } else {
972
- ldap_get_option (NULL , opts [i ], & path );
973
- if (path ) { /* set globally, inherit */
974
- ldap_set_option (ld , opts [i ], & path );
975
- ldap_memfree (path );
976
- }
977
- }
978
- }
979
- return ldap_set_option (NULL , LDAP_OPT_X_TLS_NEWCTX , & val );
980
- }
981
-
982
945
/* {{{ Connect to an LDAP server */
983
946
PHP_FUNCTION (ldap_connect )
984
947
{
@@ -3758,6 +3721,46 @@ PHP_FUNCTION(ldap_rename_ext)
3758
3721
/* }}} */
3759
3722
3760
3723
#ifdef HAVE_LDAP_START_TLS_S
3724
+ /*
3725
+ Force new tls context creation with string options inherited from global
3726
+ Workaround to https://bugs.openldap.org/show_bug.cgi?id=10337
3727
+ */
3728
+ static int _php_ldap_tls_newctx (LDAP * ld )
3729
+ {
3730
+ int val = 0 , i , opts [] = {
3731
+ #if (LDAP_API_VERSION > 2000 )
3732
+ LDAP_OPT_X_TLS_CACERTDIR ,
3733
+ LDAP_OPT_X_TLS_CACERTFILE ,
3734
+ LDAP_OPT_X_TLS_CERTFILE ,
3735
+ LDAP_OPT_X_TLS_CIPHER_SUITE ,
3736
+ LDAP_OPT_X_TLS_KEYFILE ,
3737
+ LDAP_OPT_X_TLS_RANDOM_FILE ,
3738
+ #endif
3739
+ #ifdef LDAP_OPT_X_TLS_CRLFILE
3740
+ LDAP_OPT_X_TLS_CRLFILE ,
3741
+ #endif
3742
+ #ifdef LDAP_OPT_X_TLS_DHFILE
3743
+ LDAP_OPT_X_TLS_DHFILE ,
3744
+ #endif
3745
+ 0 };
3746
+
3747
+ for (i = 0 ; opts [i ] ; i ++ ) {
3748
+ char * path = NULL ;
3749
+
3750
+ ldap_get_option (ld , opts [i ], & path );
3751
+ if (path ) { /* already set locally */
3752
+ ldap_memfree (path );
3753
+ } else {
3754
+ ldap_get_option (NULL , opts [i ], & path );
3755
+ if (path ) { /* set globally, inherit */
3756
+ ldap_set_option (ld , opts [i ], & path );
3757
+ ldap_memfree (path );
3758
+ }
3759
+ }
3760
+ }
3761
+ return ldap_set_option (NULL , LDAP_OPT_X_TLS_NEWCTX , & val );
3762
+ }
3763
+
3761
3764
/* {{{ Start TLS */
3762
3765
PHP_FUNCTION (ldap_start_tls )
3763
3766
{
@@ -3774,7 +3777,7 @@ PHP_FUNCTION(ldap_start_tls)
3774
3777
3775
3778
if (((rc = ldap_set_option (ld -> link , LDAP_OPT_PROTOCOL_VERSION , & protocol )) != LDAP_SUCCESS ) ||
3776
3779
#ifdef LDAP_OPT_X_TLS_NEWCTX
3777
- (LDAPG (tls_newctx ) && (rc = _php_ldap_newctx (ld -> link )) != LDAP_OPT_SUCCESS ) ||
3780
+ (LDAPG (tls_newctx ) && (rc = _php_ldap_tls_newctx (ld -> link )) != LDAP_OPT_SUCCESS ) ||
3778
3781
#endif
3779
3782
((rc = ldap_start_tls_s (ld -> link , NULL , NULL )) != LDAP_SUCCESS )
3780
3783
) {
0 commit comments