problem with set_option and tls

Mike Lovell mike at mozy.com
Thu May 28 21:23:26 CEST 2009


First off, hello everyone.
I am working on some software that uses python-ldap that is trying to 
connect to an ldaps server. If I do this sequence

import ldap
ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, '/path/to/cert')
conn = ldap.initialize('ldaps://server')
conn.simple_bind_s('uid', 'pass')

things work fine. But if I do it like this

import ldap
conn = ldap.initialize('ldaps://server')
conn.set_option(ldap.OPT_X_TLS_CACERTFILE, '/path/to/cert')
conn.simple_bind_s('uid', 'pass')

then I get an error saying that it can't contact the server. I am 
guessing it just can't verify the server's ssl certificate and just 
saying it can't contact the server. But it appears that if I set the 
option on the ldap module it works but setting the option on the 
individual connection doesn't.

Is this expected behavior? Is this a restriction of the underlying 
openldap client libraries? Or a bug that could use some attention? I am 
wanting to get it so that the options are on the connections so that I 
could do multiple connections with different options. Thanks for any 
help in advance.

mike




More information about the python-ldap mailing list