_tls_util.py 528 B

12345678910111213141516171819
  1. # Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
  2. import os
  3. from typing import Tuple
  4. def convert_verify_to_cafile_and_capath(
  5. verify: bool | str,
  6. ) -> Tuple[str | None, str | None]:
  7. cafile: str | None = None
  8. capath: str | None = None
  9. if isinstance(verify, str):
  10. if os.path.isfile(verify):
  11. cafile = verify
  12. elif os.path.isdir(verify):
  13. capath = verify
  14. else:
  15. raise ValueError("invalid verify string")
  16. return cafile, capath