<s> """<STR_LIT>""" <EOL> import sys <EOL> from rpyc . lib import safe_import <EOL> ssl = safe_import ( "<STR_LIT>" ) <EOL> class AuthenticationError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class SSLAuthenticator ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , keyfile , certfile , ca_certs = None , cert_reqs = None , <EOL> ssl_version = None , ciphers = None ) : <EOL> self . keyfile = keyfile <EOL> self . certfile = certfile <EOL> self . ca_certs = ca_certs <EOL> self . ciphers = ciphers <EOL> if cert_reqs is None : <EOL> if ca_certs : <EOL> self . cert_reqs = ssl . CERT_REQUIRED <EOL> else : <EOL> self . cert_reqs = ssl . CERT_NONE <EOL> else : <EOL> self . cert_reqs = cert_reqs <EOL> if ssl_version is None : <EOL> self . ssl_version = ssl . PROTOCOL_TLSv1 <EOL> else : <EOL> self . ssl_version = ssl_version <EOL> def __call__ ( self , sock ) : <EOL> kwargs = dict ( keyfile = self . keyfile , certfile = self . certfile , <EOL> server_side = True , ca_certs = self . ca_certs , cert_reqs = self . cert_reqs , <EOL> ssl_version = self . ssl_version ) <EOL> if self . ciphers is not None : <EOL> kwargs [ "<STR_LIT>" ] = self . ciphers <EOL> try : <EOL> sock2 = ssl . wrap_socket ( sock , ** kwargs ) <EOL> except ssl . SSLError : <EOL> ex = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> raise AuthenticationError ( str ( ex ) ) <EOL> return sock2 , sock2 . getpeercert ( ) </s>
