#NEWLINE# def _do_ssl_handshake( self ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . _handshake_reading = False #NEWLINE# self . _handshake_writing = False #NEWLINE# self . socket . do_handshake ( ) #NEWLINE# #UNINDENT# except ssl . SSLError as err : #NEWLINE# #INDENT# if ( err . args [ 0 ] == ssl . SSL_ERROR_WANT_READ ) : #NEWLINE# #INDENT# self . _handshake_reading = True #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( err . args [ 0 ] == ssl . SSL_ERROR_WANT_WRITE ) : #NEWLINE# #INDENT# self . _handshake_writing = True #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( err . args [ 0 ] in ( ssl . SSL_ERROR_EOF , ssl . SSL_ERROR_ZERO_RETURN ) ) : #NEWLINE# #INDENT# return self . close ( exc_info = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( err . args [ 0 ] == ssl . SSL_ERROR_SSL ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# peer = self . socket . getpeername ( ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# peer = '(not connected)' #NEWLINE# #UNINDENT# gen_log . warning ( 'SSL Error on %d %s: %s' , self . socket . fileno ( ) , self , err ) #NEWLINE# return self . close ( exc_info = True ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# raise #NEWLINE# #UNINDENT# except socket . error as err : #NEWLINE# #INDENT# if ( err . args [ 0 ] in ( errno . ECONNABORTED , errno . ECONNRESET ) ) : #NEWLINE# #INDENT# return self . close ( exc_info = True ) #NEWLINE# #UNINDENT# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# return self . close ( exc_info = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _ssl_accepting = False #NEWLINE# if ( not self . _verify_cert ( self . socket . getpeercert ( ) ) ) : #NEWLINE# #INDENT# self . close ( ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( self . _ssl_connect_callback is not None ) : #NEWLINE# #INDENT# callback = self . _ssl_connect_callback #NEWLINE# self . _ssl_connect_callback = None #NEWLINE# self . _run_callback ( callback )