@@ -3732,7 +3732,8 @@ PHP_FUNCTION(ldap_rename_ext)
3732
3732
*/
3733
3733
static int _php_ldap_tls_newctx (LDAP * ld )
3734
3734
{
3735
- int val = 0 , i , opts [] = {
3735
+ int val = 0 , i ;
3736
+ int str_opts [] = {
3736
3737
#if (LDAP_API_VERSION > 2000 )
3737
3738
LDAP_OPT_X_TLS_CACERTDIR ,
3738
3739
LDAP_OPT_X_TLS_CACERTFILE ,
@@ -3752,21 +3753,42 @@ static int _php_ldap_tls_newctx(LDAP *ld)
3752
3753
#endif
3753
3754
0 };
3754
3755
3755
- for (i = 0 ; opts [i ] ; i ++ ) {
3756
+ for (i = 0 ; str_opts [i ] ; i ++ ) {
3756
3757
char * path = NULL ;
3757
3758
3758
- ldap_get_option (ld , opts [i ], & path );
3759
+ ldap_get_option (ld , str_opts [i ], & path );
3759
3760
if (path ) { /* already set locally */
3760
3761
ldap_memfree (path );
3761
3762
} else {
3762
- ldap_get_option (NULL , opts [i ], & path );
3763
+ ldap_get_option (NULL , str_opts [i ], & path );
3763
3764
if (path ) { /* set globally, inherit */
3764
- ldap_set_option (ld , opts [i ], path );
3765
+ ldap_set_option (ld , str_opts [i ], path );
3765
3766
ldap_memfree (path );
3766
3767
}
3767
3768
}
3768
3769
}
3769
3770
3771
+ #ifdef LDAP_OPT_X_TLS_PROTOCOL_MIN
3772
+ int int_opts [] = {
3773
+ LDAP_OPT_X_TLS_PROTOCOL_MIN ,
3774
+ #ifdef LDAP_OPT_X_TLS_PROTOCOL_MAX
3775
+ LDAP_OPT_X_TLS_PROTOCOL_MAX ,
3776
+ #endif
3777
+ 0
3778
+ };
3779
+ for (i = 0 ; int_opts [i ] ; i ++ ) {
3780
+ int value = 0 ;
3781
+
3782
+ ldap_get_option (ld , int_opts [i ], & value );
3783
+ if (value <= 0 ) { /* if value is not set already */
3784
+ ldap_get_option (NULL , int_opts [i ], & value );
3785
+ if (value > 0 ) { /* set globally, inherit */
3786
+ ldap_set_option (ld , int_opts [i ], & value );
3787
+ }
3788
+ }
3789
+ }
3790
+ #endif
3791
+
3770
3792
return ldap_set_option (ld , LDAP_OPT_X_TLS_NEWCTX , & val );
3771
3793
}
3772
3794
0 commit comments