Repository navigation
wollet: configure Electrum domain validation - #3
Closed
ethicnology-agent wants to merge 3 commits into
Closed
ethicnology-agent wants to merge 3 commits into
ethicnology-agent wants to merge 3 commits into
Conversation
Author
|
@ethicnology ready for your review. |
- ElectrumClientBuilder had no way to skip the TLS certificate validation, so a server with a self-signed certificate or reached by IP address (e.g. a personal node on a LAN) could not be used over TLS. Add ElectrumClientBuilder::validate_domain(), true by default. - The flag is applied while parsing the url: an ssl:// url with an IP host is only rejected when the domain is validated. ElectrumUrl::from_str stays strict. - Since 0.19.0, ElectrumClient::new() and with_options() rebuild the client from the url's string form, which drops the flag of an ElectrumUrl built with ElectrumUrl::new(host, true, false): the domain is validated anyway, and an IP host fails with SslWithoutDomain. They now pass the flag to the builder. - With rustls, false disables the server certificate verification entirely, so the server is not authenticated; the docs say so and that a token can then be intercepted. It does not relax the refusal to send a token over plaintext.
ethicnology-agent
force-pushed
the
fix/electrum-keep-validate-domain
branch
from
November 5, 2026 19:32
75e2864 to
0075397
Compare
ethicnology-agent
force-pushed
the
fix/electrum-keep-validate-domain
branch
from
November 5, 2026 19:33
0075397 to
5d1b262
Compare
- A TLS url on an IP host is refused by default. - With validate_domain(false) it passes url parsing and the client tries to connect, through the builder and the deprecated constructors, which lost the flag since 0.19.0. - No server is needed: nothing listens on 127.0.0.1:1, so a connection error instead of a url error proves the flag is kept.
- Foreign languages could not use an Electrum server with a self-signed certificate or reached by IP address over TLS. Add a validate_domain field to the ElectrumClientBuilder record, true by default so existing callers keep validating, and pass it to the builder. - Since 0.19.0, the ElectrumClient(url, tls, validate_domain) constructor dropped validate_domain=false: it built its builder from the url's string form. It now passes the flag, which also applies to the builder kept to recreate the client in clone_client. - from_url keeps validating the domain.
ethicnology-agent
force-pushed
the
fix/electrum-keep-validate-domain
branch
from
November 5, 2026 19:37
5d1b262 to
bd4ffc2
Compare
Member
|
Nobody (to my knowledge) self-host liquid electrum server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Users who run their own Electrum node often serve TLS with a self-signed certificate, or reach the node by IP address on a LAN or VPN.
ElectrumClientBuilder, the Electrum interface since 0.19.0, has no way to connect to such a server: the certificate is always verified, and anssl://url with an IP host is rejected withSslWithoutDomain.The older path is broken too. Since 0.19.0,
ElectrumClient::new()andElectrumClient::with_options()rebuild the client from the string form of theElectrumUrl, which cannot carry the domain validation flag. AnElectrumUrlbuilt withElectrumUrl::new(host, true, false), the documented way to use TLS without validating the domain, is validated anyway, and the same url on an IP host fails withSslWithoutDomain. The UniFFIElectrumClient(url, tls, validate_domain)constructor dropsvalidate_domain = falsethe same way, since bindings 0.19.0.The
validate_domainpart of Blockstream#60 asked for the same on the previousElectrumOptions; this does it on the builder instead.API
lwk_wollet:ElectrumClientBuilder::validate_domain(bool),trueby default. The flag is applied while the url is parsed, sossl://<ip>:<port>is accepted only when it isfalse, and it is passed to electrum-client for TLS.tcp://urls ignore it.ElectrumUrl::from_strstays strict,ElectrumUrl::new()andElectrumOptionsare unchanged, and there is no new public conversion fromElectrumUrl.lwk_wollet:ElectrumClient::new()andwith_options()pass theElectrumUrl::Tlsflag to the builder again.ElectrumUrl::build_client()already did.lwk_bindings:ElectrumClientBuildergets a last fieldvalidate_domain: bool, defaulttrue, so existing callers are unaffected. TheElectrumClient(url, tls, validate_domain)constructor passes its flag, which also applies to the builder kept forclone_client.ElectrumClient.from_url()keeps validating. Itstls=false, validate_domain=trueerror is unchanged. Nothing changes for wasm, which has no Electrum client.No breaking change: the Rust additions are a new builder method and private fields, and the bindings field is appended with a default.
Security note
With the rustls backend used by
lwk_wollet,validate_domain(false)does not only skip matching the certificate against the host name: electrum-client installsNoCertificateVerification, so the server certificate is not verified at all. The connection stays encrypted but the server is not authenticated, so anyone able to intercept the connection can impersonate the server and see or alter the requests and their answers. A token fromtoken_provideris sent to whoever answers and can then be captured.validate_domain(false)does not relax the refusal to send a token overtcp://, which still needsallow_plaintext_with_token(true). The docs of the method and of the bindings field say this.Tests
lwk_wolletunit testelectrum_tls_domain_validation_flag, no network:ssl://127.0.0.1:1is rejected withSslWithoutDomainby default; withvalidate_domain(false)the builder,ElectrumClient::new()andwith_options()accept the url and fail on the connection (nothing listens on port 1), not on the url. On the previous code the two constructors returnSslWithoutDomain.Verified on 2026-11-05 on Linux:
cargo test -p lwk_wollet --lib electrum_tls_domain_validation_flag,cargo clippy --all-targets -- -D warningsonlwk_wolletandlwk_bindings,cargo fmt --check. The source commits were also checked with rustdoc (-D warnings --cfg docsrs) and the CI wasm check oflwk_wolletbefore the test was reduced.Review guide
Base:
SatoshiPortal/lwkmaster70b3aa03(2026-11-05), which isBlockstream/lwkmaster32201840plus the signer commits of Blockstream#196; these four commits touch onlylwk_wolletandlwk_bindingsand apply unchanged on32201840.Cargo.lockis unchanged.8bc6cecdwollet: configure Electrum domain validation886a593cwollet: test Electrum domain validation flagbd4ffc2ebindings: expose Electrum domain validationRead the two source commits closely; the test commit can be skimmed.