title: Python LDAP ValueError: option error when using set_option(ldap. OPT_X_TLS_CACERTDIR)
body: <p>I'm using the django authentication backend <a href="https://pythonhosted.org/django-auth-ldap/" rel="nofollow noreferrer">django-auth-ldap</a> to authenticate against an LDAP service. When attempting to set the path to the directory containing the ssl certificate;</p>
  
  <pre><code>ldap.set_option(ldap.OPT_X_TLS_CACERTDIR, '/etc/ssl/certs')
  </code></pre>
  
  <p>I get a ValueError exception:</p>
  
  <pre><code>File "/Users/liz/web_application/work/ldap_settings.py", line 5, in &lt;module&gt;
  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
  </code></pre>
  
  <p>I've tried the accepted answer from this <a href="https://stackoverflow.com/questions/43328378/python-ldap-macos-valueerror-option-error">previous SO post</a> that suggests uninstalling python-ldap (though I'm using <a href="https://github.com/pyldap/pyldap" rel="nofollow noreferrer">pyldap</a>, a fork of python-ldap) and re-installing using a brew-installed openldap by running:</p>
  
  <pre><code>LDFLAGS="-L/usr/local/brew/opt/openldap/lib" CPPFLAGS="-I/usr/local/brew/opt/openldap/include" pip install python-ldap
  </code></pre>
  
  <p>This seemed to have no effect. I also followed <a href="https://keathmilligan.net/python-ldap-and-macos/" rel="nofollow noreferrer">this guide</a>, 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!</p>
  
  <p><strong>Other existing questions on SO</strong></p>
  
  <p>The answer to <a href="https://stackoverflow.com/questions/11617147/valueerror-option-error-in-django-python">this question</a> has no effect for me; setting AUTH_LDAP_GLOBAL_OPTIONS instead of set_option results in the same ValueError</p>
  
  <pre><code>AUTH_LDAP_GLOBAL_OPTIONS = {ldap.OPT_X_TLS_CACERTDIR: '/etc/ssl/certs'}
  </code></pre>