Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/oscrypto/errors.py: 72%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# coding: utf-8
2from __future__ import unicode_literals, division, absolute_import, print_function
4import sys
5import socket
8__all__ = [
9 'AsymmetricKeyError',
10 'CACertsError',
11 'LibraryNotFoundError',
12 'SignatureError',
13 'TLSError',
14 'TLSConnectionError',
15 'TLSDisconnectError',
16 'TLSGracefulDisconnectError',
17 'TLSVerificationError',
18]
21class LibraryNotFoundError(Exception):
23 """
24 An exception when trying to find a shared library
25 """
27 pass
30class SignatureError(Exception):
32 """
33 An exception when validating a signature
34 """
36 pass
39class AsymmetricKeyError(Exception):
41 """
42 An exception when a key is invalid or unsupported
43 """
45 pass
48class IncompleteAsymmetricKeyError(AsymmetricKeyError):
50 """
51 An exception when a key is missing necessary information
52 """
54 pass
57class CACertsError(Exception):
59 """
60 An exception when exporting CA certs from the OS trust store
61 """
63 pass
66class TLSError(socket.error):
68 """
69 An exception related to TLS functionality
70 """
72 message = None
74 def __init__(self, message):
75 self.args = (message,)
76 self.message = message
78 def __str__(self):
79 output = self.__unicode__()
80 if sys.version_info < (3,):
81 output = output.encode('utf-8')
82 return output
84 def __unicode__(self):
85 return self.message
88class TLSConnectionError(TLSError):
89 pass
92class TLSDisconnectError(TLSConnectionError):
93 pass
96class TLSGracefulDisconnectError(TLSDisconnectError):
97 pass
100class TLSVerificationError(TLSError):
102 """
103 A server certificate verification error happened during a TLS handshake
104 """
106 certificate = None
108 def __init__(self, message, certificate):
109 TLSError.__init__(self, message)
110 self.certificate = certificate
111 self.args = (message, certificate)