noirello / bonsai

Simple Python 3 module for LDAP, using libldap2 and winldap C libraries.
MIT License
117 stars 33 forks source link

How to specify custom CA file #33

Closed schlitzered closed 5 years ago

schlitzered commented 5 years ago

i am trying to connect to a ldap server that uses a certificated that is singed by a internal ca.

i tried to set the path to the CA file using "set_ca_cert_dir" like this.

client.set_ca_cert_dir('/path/to/cert/contrib/ca-bundle.pem')

or

client.set_ca_cert_dir('/path/to/cert/contrib/')

but the certificate is not picked up. any clue what needs to be done to get this working?

noirello commented 5 years ago

Hi, you should try client.set_ca_cert("/path/to/cert/contrib/ca-bundle.pem") It should work, if your TLS lib is OpenSSL or GnuTLS.

There's a section in the docs about TLS settings. It might need some more details.

schlitzered commented 5 years ago

this is exactly what i have done, but it is not working.

noirello commented 5 years ago

You mentioned set_ca_cert_dir in your previous comment and not set_ca_cert.

You should turn on the debug mode: bonsai.set_debug(True, -1) to see what's going on. If you provide a code snippet and the output of the debug log, that could help me a lot.

schlitzered commented 5 years ago

i am sorry, i did not notice that "_dir" was missing in your suggestion, now it is working, thanks!