@@ -3740,7 +3740,8 @@ PHP_FUNCTION(ldap_rename_ext)
3740
3740
*/
3741
3741
static int _php_ldap_tls_newctx (LDAP * ld )
3742
3742
{
3743
- int val = 0 , i , opts [] = {
3743
+ int val = 0 , i ;
3744
+ int str_opts [] = {
3744
3745
#if (LDAP_API_VERSION > 2000 )
3745
3746
LDAP_OPT_X_TLS_CACERTDIR ,
3746
3747
LDAP_OPT_X_TLS_CACERTFILE ,
@@ -3760,21 +3761,42 @@ static int _php_ldap_tls_newctx(LDAP *ld)
3760
3761
#endif
3761
3762
0 };
3762
3763
3763
- for (i = 0 ; opts [i ] ; i ++ ) {
3764
+ for (i = 0 ; str_opts [i ] ; i ++ ) {
3764
3765
char * path = NULL ;
3765
3766
3766
- ldap_get_option (ld , opts [i ], & path );
3767
+ ldap_get_option (ld , str_opts [i ], & path );
3767
3768
if (path ) { /* already set locally */
3768
3769
ldap_memfree (path );
3769
3770
} else {
3770
- ldap_get_option (NULL , opts [i ], & path );
3771
+ ldap_get_option (NULL , str_opts [i ], & path );
3771
3772
if (path ) { /* set globally, inherit */
3772
- ldap_set_option (ld , opts [i ], path );
3773
+ ldap_set_option (ld , str_opts [i ], path );
3773
3774
ldap_memfree (path );
3774
3775
}
3775
3776
}
3776
3777
}
3777
3778
3779
+ #ifdef LDAP_OPT_X_TLS_PROTOCOL_MIN
3780
+ int int_opts [] = {
3781
+ LDAP_OPT_X_TLS_PROTOCOL_MIN ,
3782
+ #ifdef LDAP_OPT_X_TLS_PROTOCOL_MAX
3783
+ LDAP_OPT_X_TLS_PROTOCOL_MAX ,
3784
+ #endif
3785
+ 0
3786
+ };
3787
+ for (i = 0 ; int_opts [i ] ; i ++ ) {
3788
+ int value = 0 ;
3789
+
3790
+ ldap_get_option (ld , int_opts [i ], & value );
3791
+ if (value <= 0 ) { /* if value is not set already */
3792
+ ldap_get_option (NULL , int_opts [i ], & value );
3793
+ if (value > 0 ) { /* set globally, inherit */
3794
+ ldap_set_option (ld , int_opts [i ], & value );
3795
+ }
3796
+ }
3797
+ }
3798
+ #endif
3799
+
3778
3800
return ldap_set_option (ld , LDAP_OPT_X_TLS_NEWCTX , & val );
3779
3801
}
3780
3802
0 commit comments