Kami / python-yubico-client

Python library for validating Yubico Yubikey One Time Passwords (OTPs) based on the validation protocol version 2.0.
https://yubico-client.readthedocs.org/en/latest/
Other
83 stars 19 forks source link

Setting custom CA_CERTS_BUNDLE_PATH doesn't work #20

Closed sferket closed 10 years ago

sferket commented 10 years ago

We want to define a custom CA_CERTS_BUNDLE_PATH location. We have this code: yubico = Yubico('123', '1234567890',use_https=True) yubico.CA_CERTS_BUNDLE_PATH = '/tmp/cert/api.yubico.com.pem' print yubico._get_ca_bundle_path() print yubico.CA_CERTS_BUNDLE_PATH

Note that yubico._get_ca_bundle_path() doesn't return the path that we set.

It does work if we change _get_ca_bundle_path: if self.CA_CERTS_BUNDLE_PATH:

User provided a custom path

        return self.CA_CERTS_BUNDLE_PATH

We would like it better if we can set the custom path when initializing the object.

Kami commented 10 years ago

@sferket You need to set CA_CERTS_BUNDLE_PATH attribute on the yubico module object and not on the class instance.

For example:

from yubico_client import yubico

yubico.CA_CERTS_BUNDLE_PATH = '/tmp/cert/api.yubico.com.pem'

cls = yubico.Yubico('123', '1234567890', use_https=True)
print cls._get_ca_bundle_path()
print yubico.CA_CERTS_BUNDLE_PATH

I do agree that passing this to the constructor is more reasonable. Once I find some time, I will make this change and update the documentation with an example of how to use it.

Kami commented 10 years ago

@sferket I've pushed some changes to trunk.

To make it easier and more obvious, you can now use a custom CA bundle by passing ca_certs_bundle_path argument to the constructor. You can find an example of how to use it on the following link - https://yubico-client.readthedocs.org/en/latest/#using-a-custom-ca-certificate-bundle

To discourage bad practices, I also removed use_https argument from the constructor.

Full change log can be found at https://github.com/Kami/python-yubico-client/blob/master/CHANGES.rst#190---in-development.

I plan to do some other minor changes in the near future so I plan to publish 1.9.0 to PyPi some time later this week.

Kami commented 10 years ago

Alright, I've published 1.9.0 to PyPi - https://pypi.python.org/pypi/yubico-client/1.9.0