@@ -68,6 +68,15 @@ def authenticate(self, dn, pw):
68
68
# Let's bypass connector/communicator until they are sorted out
69
69
if self ._props .ignore_cert : # pragma: no cover
70
70
ldap .set_option (ldap .OPT_X_TLS_REQUIRE_CERT , ldap .OPT_X_TLS_NEVER )
71
+ elif self ._props .tls_cacertfile : # pragma: no cover
72
+ ldap .set_option (ldap .OPT_X_TLS_CACERTFILE , self ._props .tls_cacertfile )
73
+ elif self ._props .tls_cacertdir : # pragma: no cover
74
+ ldap .set_option (ldap .OPT_X_TLS_CACERTDIR , self ._props .tls_cacertdir )
75
+ if self ._props .tls_clcertfile and self ._props .tls_clkeyfile : # pragma: no cover
76
+ ldap .set_option (ldap .OPT_X_TLS_CERTFILE , self ._props .tls_clcertfile )
77
+ ldap .set_option (ldap .OPT_X_TLS_KEYFILE , self ._props .tls_clkeyfile )
78
+ elif self ._props .tls_clcertfile or self ._props .tls_clkeyfile : # pragma: no cover
79
+ logger .exception ("Only client certificate or key have been provided." )
71
80
con = ldap .initialize (
72
81
self ._props .uri ,
73
82
bytes_mode = False ,
@@ -77,6 +86,8 @@ def authenticate(self, dn, pw):
77
86
# Directory More info: https://www.python-ldap.org/faq.html#usage
78
87
con .set_option (ldap .OPT_REFERRALS , 0 )
79
88
try :
89
+ if self ._props .start_tls :
90
+ con .start_tls_s ()
80
91
con .simple_bind_s (dn , pw )
81
92
except (ldap .INVALID_CREDENTIALS , ldap .UNWILLING_TO_PERFORM ):
82
93
# The UNWILLING_TO_PERFORM event might be thrown, if you query a
0 commit comments