Page MenuHomePhabricator

[electrum] Interface: Use check_hostname instead of match_hostname
ClosedPublic

Authored by PiRK on Aug 31 2023, 14:36.

Details

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

Diff Detail

Repository
rABC Bitcoin ABC
Branch
match_hostname
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24923
Build 49434: Build Diffelectrum-tests
Build 49433: arc lint + arc unit