(self)
| 131 | return |
| 132 | |
| 133 | def tls_handshake(self): |
| 134 | # wait for flush |
| 135 | if self.write_buf: |
| 136 | return False |
| 137 | # Perform the handshake. |
| 138 | try: |
| 139 | #print "handshaking (internal)" |
| 140 | self.sslSocket.do_handshake() |
| 141 | except ssl.SSLError as err: |
| 142 | #print "%s:%i: handshake fail" % (self.destination.host, self.destination.port) |
| 143 | self.want_read = self.want_write = False |
| 144 | if err.args[0] == ssl.SSL_ERROR_WANT_READ: |
| 145 | #print "want read" |
| 146 | self.want_read = True |
| 147 | if err.args[0] == ssl.SSL_ERROR_WANT_WRITE: |
| 148 | #print "want write" |
| 149 | self.want_write = True |
| 150 | if not (self.want_write or self.want_read): |
| 151 | raise |
| 152 | except socket.error as err: |
| 153 | if err.errno in asyncore._DISCONNECTED: |
| 154 | self.handle_close() |
| 155 | else: |
| 156 | raise |
| 157 | else: |
| 158 | if sys.version_info >= (2, 7, 9): |
| 159 | self.tlsVersion = self.sslSocket.version() |
| 160 | logger.debug("%s:%i: TLS handshake success, TLS protocol version: %s", |
| 161 | self.destination.host, self.destination.port, self.sslSocket.version()) |
| 162 | else: |
| 163 | self.tlsVersion = "TLSv1" |
| 164 | logger.debug("%s:%i: TLS handshake success", self.destination.host, self.destination.port) |
| 165 | # The handshake has completed, so remove this channel and... |
| 166 | self.del_channel() |
| 167 | self.set_socket(self.sslSocket) |
| 168 | self.tlsDone = True |
| 169 | |
| 170 | self.bm_proto_reset() |
| 171 | self.set_state("connection_fully_established") |
| 172 | receiveDataQueue.put(self.destination) |
| 173 | return False |
no test coverage detected