current source. throwing encoding error from hashlib. import electrumx import aiorpcx import asyncio import hashlib import ssl async def main(): coin_peers = { coin.NAME: coin.PEERS for coin in electrumx.lib.coins.util.subclasses(electrumx.lib.coins.Coin) if len(coin.PEERS) > 0 } nonverifying_ssl = ssl.SSLContext(ssl.PROTOCOL_TLS) for name, peers in coin_peers.items(): try: for peer in peers: peer = electrumx.lib.peer.Peer.from_real_name(peer, '') cert_msg = '' client = aiorpcx.connect_rs(peer.host, peer.ssl_port, ssl=True) try: transport, protocol = await client.create_connection() except ssl.SSLCertVerificationError as err: if err.reason != 'CERTIFICATE_VERIFY_FAILED': raise else: cert_msg = err.verify_message client = aiorpcx.connect_rs(peer.host, peer.ssl_port, ssl=nonverifying_ssl) transport, protocol = await client.create_connection() try: print('connected to', name, peer.real_name(), protocol.session) ssl_obj = protocol.session.transport._asyncio_transport.get_extra_info('ssl_object') der_cert = ssl_obj.getpeercert(True) pem_cert = ssl.DER_cert_to_PEM_cert(der_cert) for alg in 'md5 sha1 sha256 blake2b'.split(' '): cert_print = getattr(hashlib, alg)(pem_cert).hexdigest() print(peer.real_name(), alg, cert_print) finally: protocol.session.close() except KeyError: continue asyncio.run(main())