exceptions.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. """
  2. All exceptions and warnings thrown by ``service_identity``.
  3. Separated into an own package for nicer tracebacks, you should still import
  4. them from __init__.py.
  5. """
  6. from __future__ import absolute_import, division, print_function
  7. import attr
  8. class SubjectAltNameWarning(DeprecationWarning):
  9. """
  10. Server Certificate does not contain a ``SubjectAltName``.
  11. Hostname matching is performed on the ``CommonName`` which is deprecated.
  12. """
  13. @attr.s
  14. class VerificationError(Exception):
  15. """
  16. Service identity verification failed.
  17. """
  18. errors = attr.ib()
  19. def __str__(self):
  20. return self.__repr__()
  21. @attr.s
  22. class DNSMismatch(object):
  23. """
  24. Not matching DNSPattern could be found.
  25. """
  26. mismatched_id = attr.ib()
  27. @attr.s
  28. class SRVMismatch(object):
  29. """
  30. Not matching SRVPattern could be found.
  31. """
  32. mismatched_id = attr.ib()
  33. @attr.s
  34. class URIMismatch(object):
  35. """
  36. Not matching URIPattern could be found.
  37. """
  38. mismatched_id = attr.ib()
  39. class CertificateError(Exception):
  40. """
  41. Certificate contains invalid or unexpected data.
  42. """