HomePhabricator

[electrum] Interface: Use check_hostname instead of match_hostname

Description

[electrum] Interface: Use check_hostname instead of match_hostname

Summary:

Since Python 3.7 the hostname verification is done in
SSLSocket.do_handshake if SSLContext.check_hostname is set, so we
don't need our own code to verify the certificate.

This also removes the unused _match_hostname function and its tests.

This is a backport of https://github.com/Electron-Cash/Electron-Cash/pull/2662/commits/12c0c2fe7f8a49eaed93dd2782e3c0c9a65905a9

It fixes a deprecation warning visible when running the tests with python <= 3.11, and is need to make the application run with python 3.12.

The test is adjusted to avoid failure when run disconnected from the internet.

Depends on D14439

Test Plan:
Without internet:

$ python -m electrumabc.tests.test_interface -v
test_verify_bad_ca_cert (__main__.TestInterface) ... skipped 'This test requires an internet connection.'
test_verify_good_ca_cert (__main__.TestInterface) ... skipped 'This test requires an internet connection.'

----------------------------------------------------------------------
Ran 2 tests in 0.131s

OK (skipped=2)

With internet:

$ python -m electrumabc.tests.test_interface -v
test_verify_bad_ca_cert (__main__.TestInterface) ... ok
test_verify_good_ca_cert (__main__.TestInterface) ... ok

----------------------------------------------------------------------
Ran 2 tests in 2.743s

OK

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14440

Details

Provenance
EchterAgoAuthored on Jul 18 2023, 21:06
PiRKCommitted on Sep 1 2023, 07:11
PiRKPushed on Sep 1 2023, 07:11
Reviewer
Restricted Project
Differential Revision
D14440: [electrum] Interface: Use check_hostname instead of match_hostname
Parents
rABC0ce2ec6244c9: [electrum] don't hack sys.path in setup.py
Branches
Unknown
Tags
Unknown