binary.py 606 B

12345678910111213141516171819202122232425
  1. import ssl
  2. def builtin_ca():
  3. return None, None, ssl.builtin_cadata()
  4. # Normally certifi.where() returns a path to a certificate file;
  5. # here it returns a callable.
  6. def where():
  7. return builtin_ca
  8. # Patch ssl module to accept a callable cafile.
  9. load_verify_locations = ssl.SSLContext.load_verify_locations
  10. def load_verify_locations__callable(self, cafile=None, capath=None, cadata=None):
  11. if callable(cafile):
  12. cafile, capath, cadata = cafile()
  13. return load_verify_locations(self, cafile, capath, cadata)
  14. ssl.SSLContext.load_verify_locations = load_verify_locations__callable