[python-ldap] ValueError: option error on trying to set OPT_X_TLS_CACERTFILE

Michael Ströder michael at stroeder.com
Sun Feb 7 10:31:42 EST 2016

Peter Bengtsson wrote:
>> "/Users/peterbe/virtualenvs/medlem/lib/python2.7/site-packages/python_ldap-2.4.25-py2.7-macosx-10.11-x86_64.egg/ldap/functions.py",
>>> line 64, in _ldap_function_call
>>>     result = func(*args,**kwargs)
>>> ValueError: option error
>> Most times this happens if the cert file does not exist.
> Wouldn't/Shouldn't that yield a IOError then if it tries to read a file
> that doesn't exist?

The option values are all directly passed to OpenLDAP's libldap which does not
know about Python's IOError exception. Also actual use of the options within
libldap is lazy. Which means the error occurs when you send the first real LDAP
operation through a LDAPObject instance.

>>>> import os
>>>> assert os.path.isfile('ldapproxy-medlem.crt')
>>>> import ldap
>>>> ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, 'ldapproxy-medlem.crt')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File
> "/Users/peterbe/virtualenvs/medlem/lib/python2.7/site-packages/python_ldap-2.4.25-py2.7-macosx-10.11-x86_64.egg/ldap/functions.py",
> line 133, in set_option
>     return _ldap_function_call(None,_ldap.set_option,option,invalue)
>   File
> "/Users/peterbe/virtualenvs/medlem/lib/python2.7/site-packages/python_ldap-2.4.25-py2.7-macosx-10.11-x86_64.egg/ldap/functions.py",
> line 64, in _ldap_function_call
>     result = func(*args,**kwargs)
> ValueError: option error
> The file clearly exists.

Hmm, did you also try the same with the full path name?

Anyway I'm on Linux and therefore cannot comment on any specific things
regarding the Mac OS X installations.

Ciao, Michael.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20160207/86274eb8/attachment.bin>

More information about the python-ldap mailing list