spesmilo / electrumx

Alternative implementation of spesmilo/electrum-server
MIT License
432 stars 343 forks source link

Added code for certificate pinning for hardcoded peers. #164

Open xloem opened 2 years ago

xloem commented 2 years ago

I'm curious as to anybody's thoughts on the idea of using TLS certificate hashes to verify peer identity.

This is some code I wrote to add to the 'real_name' format so that cert hashes can be provided, and check them. So, a peer name in coins.py can now look like the below and the peer will be marked bad if its TLS certificate doesn't match the hashes:

'electrumx.bitcoinsv.io s xsha256=08aa855b19599d84871cc4ce2218dee0f585eefae8fd8fa1899cad27ebe05d7f xblake2b=36b2e8aae9547d38d18de1f2e0f90153efb60f577acfb078ed330ec414e18d24de6c4c03aba0946bd4c3118707dede3443e6e9e68ce91b5cf18d0cac84703339'

I haven't looked at how features and peers are exchanged between servers at this time. I'm pretty new to the electrum protocol, and can often struggle to write code.