Browse Source
interface: fix connecting to new servers using self-signed certs
got broken in 6ec1578a90
regtest_lnd
SomberNight
6 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
1 changed files with
5 additions and
4 deletions
-
electrum/interface.py
|
@ -177,7 +177,8 @@ class _Connector(aiorpcx.Connector): |
|
|
try: |
|
|
try: |
|
|
return await super().create_connection() |
|
|
return await super().create_connection() |
|
|
except OSError as e: |
|
|
except OSError as e: |
|
|
raise ConnectError(e) |
|
|
# note: using "from e" here will set __cause__ of ConnectError |
|
|
|
|
|
raise ConnectError(e) from e |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def deserialize_server(server_str: str) -> Tuple[str, str, str]: |
|
|
def deserialize_server(server_str: str) -> Tuple[str, str, str]: |
|
@ -254,11 +255,11 @@ class Interface(Logger): |
|
|
""" |
|
|
""" |
|
|
try: |
|
|
try: |
|
|
await self.open_session(ca_ssl_context, exit_early=True) |
|
|
await self.open_session(ca_ssl_context, exit_early=True) |
|
|
except ssl.SSLError as e: |
|
|
except ConnectError as e: |
|
|
if e.reason == 'CERTIFICATE_VERIFY_FAILED': |
|
|
cause = e.__cause__ |
|
|
|
|
|
if isinstance(cause, ssl.SSLError) and cause.reason == 'CERTIFICATE_VERIFY_FAILED': |
|
|
# failures due to self-signed certs are normal |
|
|
# failures due to self-signed certs are normal |
|
|
return False |
|
|
return False |
|
|
# e.g. too weak crypto |
|
|
|
|
|
raise |
|
|
raise |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|