
|
Server : Apache System : Linux 182.49.167.72.host.secureserver.net 4.18.0-553.92.1.el8_10.x86_64 #1 SMP Wed Jan 14 06:31:58 EST 2026 x86_64 User : kikai ( 1014) PHP Version : 8.3.30 Disable Function : NONE Directory : /var/opt/nydus/ops/oscrypto/ |
Upload File : |
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
import sys
import socket
__all__ = [
'AsymmetricKeyError',
'CACertsError',
'LibraryNotFoundError',
'SignatureError',
'TLSError',
'TLSConnectionError',
'TLSDisconnectError',
'TLSGracefulDisconnectError',
'TLSVerificationError',
]
class LibraryNotFoundError(Exception):
"""
An exception when trying to find a shared library
"""
pass
class SignatureError(Exception):
"""
An exception when validating a signature
"""
pass
class AsymmetricKeyError(Exception):
"""
An exception when a key is invalid or unsupported
"""
pass
class IncompleteAsymmetricKeyError(AsymmetricKeyError):
"""
An exception when a key is missing necessary information
"""
pass
class CACertsError(Exception):
"""
An exception when exporting CA certs from the OS trust store
"""
pass
class TLSError(socket.error):
"""
An exception related to TLS functionality
"""
message = None
def __init__(self, message):
self.args = (message,)
self.message = message
def __str__(self):
output = self.__unicode__()
if sys.version_info < (3,):
output = output.encode('utf-8')
return output
def __unicode__(self):
return self.message
class TLSConnectionError(TLSError):
pass
class TLSDisconnectError(TLSConnectionError):
pass
class TLSGracefulDisconnectError(TLSDisconnectError):
pass
class TLSVerificationError(TLSError):
"""
A server certificate verification error happened during a TLS handshake
"""
certificate = None
def __init__(self, message, certificate):
TLSError.__init__(self, message)
self.certificate = certificate
self.args = (message, certificate)