Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exceptions.py 1.4KB

1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 annotations
  7. from typing import TYPE_CHECKING, Sequence
  8. if TYPE_CHECKING:
  9. from .hazmat import ServiceID
  10. import attr
  11. class SubjectAltNameWarning(DeprecationWarning):
  12. """
  13. This warning is not used anymore and will be removed in a future version.
  14. Formerly:
  15. Server Certificate does not contain a ``SubjectAltName``.
  16. Hostname matching is performed on the ``CommonName`` which is deprecated.
  17. .. deprecated:: 23.1.0
  18. """
  19. @attr.s(slots=True)
  20. class Mismatch:
  21. mismatched_id: ServiceID = attr.ib()
  22. class DNSMismatch(Mismatch):
  23. """
  24. No matching DNSPattern could be found.
  25. """
  26. class SRVMismatch(Mismatch):
  27. """
  28. No matching SRVPattern could be found.
  29. """
  30. class URIMismatch(Mismatch):
  31. """
  32. No matching URIPattern could be found.
  33. """
  34. class IPAddressMismatch(Mismatch):
  35. """
  36. No matching IPAddressPattern could be found.
  37. """
  38. @attr.s(auto_exc=True)
  39. class VerificationError(Exception):
  40. """
  41. Service identity verification failed.
  42. """
  43. errors: Sequence[Mismatch] = attr.ib()
  44. def __str__(self) -> str:
  45. return self.__repr__()
  46. class CertificateError(Exception):
  47. """
  48. Certificate contains invalid or unexpected data.
  49. """