Browse Source
interface.get_certificate: use public asyncio APIs
ssl-fingerprint-check
SomberNight
5 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
1 changed files with
6 additions and
7 deletions
-
electrum/interface.py
|
@ -463,13 +463,12 @@ class Interface(Logger): |
|
|
|
|
|
|
|
|
async def get_certificate(self): |
|
|
async def get_certificate(self): |
|
|
sslc = ssl.SSLContext() |
|
|
sslc = ssl.SSLContext() |
|
|
try: |
|
|
async with _RSClient(session_factory=RPCSession, |
|
|
async with _RSClient(session_factory=RPCSession, |
|
|
host=self.host, port=self.port, |
|
|
host=self.host, port=self.port, |
|
|
ssl=sslc, proxy=self.proxy) as session: |
|
|
ssl=sslc, proxy=self.proxy) as session: |
|
|
asyncio_transport = session.transport._asyncio_transport # type: asyncio.BaseTransport |
|
|
return session.transport._asyncio_transport._ssl_protocol._sslpipe._sslobj.getpeercert(True) |
|
|
ssl_object = asyncio_transport.get_extra_info("ssl_object") # type: ssl.SSLObject |
|
|
except ValueError: |
|
|
return ssl_object.getpeercert(binary_form=True) |
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
async def get_block_header(self, height, assert_mode): |
|
|
async def get_block_header(self, height, assert_mode): |
|
|
self.logger.info(f'requesting block header {height} in mode {assert_mode}') |
|
|
self.logger.info(f'requesting block header {height} in mode {assert_mode}') |
|
|