@@ -3725,7 +3725,8 @@ PHP_FUNCTION(ldap_rename_ext)
3725
3725
*/
3726
3726
static int _php_ldap_tls_newctx (LDAP * ld )
3727
3727
{
3728
- int val = 0 , i , opts [] = {
3728
+ int val = 0 , i ;
3729
+ int str_opts [] = {
3729
3730
#if (LDAP_API_VERSION > 2000 )
3730
3731
LDAP_OPT_X_TLS_CACERTDIR ,
3731
3732
LDAP_OPT_X_TLS_CACERTFILE ,
@@ -3745,21 +3746,42 @@ static int _php_ldap_tls_newctx(LDAP *ld)
3745
3746
#endif
3746
3747
0 };
3747
3748
3748
- for (i = 0 ; opts [i ] ; i ++ ) {
3749
+ for (i = 0 ; str_opts [i ] ; i ++ ) {
3749
3750
char * path = NULL ;
3750
3751
3751
- ldap_get_option (ld , opts [i ], & path );
3752
+ ldap_get_option (ld , str_opts [i ], & path );
3752
3753
if (path ) { /* already set locally */
3753
3754
ldap_memfree (path );
3754
3755
} else {
3755
- ldap_get_option (NULL , opts [i ], & path );
3756
+ ldap_get_option (NULL , str_opts [i ], & path );
3756
3757
if (path ) { /* set globally, inherit */
3757
- ldap_set_option (ld , opts [i ], path );
3758
+ ldap_set_option (ld , str_opts [i ], path );
3758
3759
ldap_memfree (path );
3759
3760
}
3760
3761
}
3761
3762
}
3762
3763
3764
+ #ifdef LDAP_OPT_X_TLS_PROTOCOL_MIN
3765
+ int int_opts [] = {
3766
+ LDAP_OPT_X_TLS_PROTOCOL_MIN ,
3767
+ #ifdef LDAP_OPT_X_TLS_PROTOCOL_MAX
3768
+ LDAP_OPT_X_TLS_PROTOCOL_MAX ,
3769
+ #endif
3770
+ 0
3771
+ };
3772
+ for (i = 0 ; int_opts [i ] ; i ++ ) {
3773
+ int value = 0 ;
3774
+
3775
+ ldap_get_option (ld , int_opts [i ], & value );
3776
+ if (value <= 0 ) { /* if value is not set already */
3777
+ ldap_get_option (NULL , int_opts [i ], & value );
3778
+ if (value > 0 ) { /* set globally, inherit */
3779
+ ldap_set_option (ld , int_opts [i ], & value );
3780
+ }
3781
+ }
3782
+ }
3783
+ #endif
3784
+
3763
3785
return ldap_set_option (ld , LDAP_OPT_X_TLS_NEWCTX , & val );
3764
3786
}
3765
3787
0 commit comments