connection.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:MiNode 作者: TheKysek 项目源码 文件源码
def _do_tls_handshake(self):
        logging.debug('Initializing TLS connection with {}:{}'.format(self.host, self.port))
        self.s = ssl.wrap_socket(self.s, keyfile=os.path.join(shared.source_directory, 'tls', 'key.pem'),
                                 certfile=os.path.join(shared.source_directory, 'tls', 'cert.pem'),
                                 server_side=self.server, ssl_version=ssl.PROTOCOL_TLSv1, do_handshake_on_connect=False,
                                 ciphers='AECDH-AES256-SHA', suppress_ragged_eofs=True)
        if hasattr(self.s, "context"):
            self.s.context.set_ecdh_curve("secp256k1")
        while True:
            try:
                self.s.do_handshake()
                break
            except ssl.SSLWantReadError:
                select.select([self.s], [], [])
            except ssl.SSLWantWriteError:
                select.select([], [self.s], [])
            except Exception as e:
                logging.debug('Disconnecting from {}:{}. Reason: {}'.format(self.host, self.port, e))
                self.status = 'disconnecting'
                break
        self.tls = True
        logging.debug('Established TLS connection with {}:{}'.format(self.host, self.port))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号