certs.py 613 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. certs.py
  5. ~~~~~~~~
  6. This module returns the preferred default CA certificate bundle.
  7. If you are packaging Requests, e.g., for a Linux distribution or a managed
  8. environment, you can change the definition of where() to return a separately
  9. packaged CA bundle.
  10. """
  11. import os.path
  12. try:
  13. from certifi import where
  14. except ImportError:
  15. def where():
  16. """Return the preferred certificate bundle."""
  17. # vendored bundle inside Requests
  18. return os.path.join(os.path.dirname(__file__), 'cacert.pem')
  19. if __name__ == '__main__':
  20. print(where())