I'm using the django authentication backend django-auth-ldap to authenticate against an LDAP service. When attempting to set the path to the directory containing the ssl certificate;
ldap.set_option(ldap.OPT_X_TLS_CACERTDIR, '/etc/ssl/certs')
I get a ValueError exception:
File "/Users/liz/web_application/work/ldap_settings.py", line 5, in <module>
ldap.set_option(ldap.OPT_X_TLS_CACERTDIR, '/etc/ssl/certs')
File "/Users/liz/.envs/dev/lib/python3.6/site-packages/ldap/functions.py", line 139, in set_option
return _ldap_function_call(None,_ldap.set_option,option,invalue)
File "/Users/liz/.envs/dev/lib/python3.6/site-packages/ldap/functions.py", line 66, in _ldap_function_call
result = func(*args,**kwargs)
ValueError: option error
I've tried the accepted answer from this previous SO post that suggests uninstalling python-ldap (though I'm using pyldap, a fork of python-ldap) and re-installing using a brew-installed openldap by running:
LDFLAGS="-L/usr/local/brew/opt/openldap/lib" CPPFLAGS="-I/usr/local/brew/opt/openldap/include" pip install python-ldap
This seemed to have no effect. I also followed this guide, to locally build a version of pyldap with the newer version of openldap (via brew), but I still see the same error. I'm not sure if there's some way I can verify my local build does use the newer openldap library, or if there's something I'm missing here? Any suggestions are much appreciated!
Other existing questions on SO
The answer to this question has no effect for me; setting AUTH_LDAP_GLOBAL_OPTIONS instead of set_option results in the same ValueError
AUTH_LDAP_GLOBAL_OPTIONS = {ldap.OPT_X_TLS_CACERTDIR: '/etc/ssl/certs'}