[BREAKGLASS] Append-only mirror of github.com/mempool/rust-electrum-client
Go to file
valued mammal 6fe96fddae
Merge bitcoindevkit/rust-electrum-client#150: fix(insecure-tls): NoCertificateVerification implementation
05771a81d7 fix: `NoCertificateVerification` implementation (Leonardo Lima)

Pull request description:

  fixes #149 https://github.com/bitcoindevkit/bdk/issues/1598
  <!-- You can erase any parts of this template not applicable to your Pull Request. -->

  ### Description

  <!-- Describe the purpose of this PR, what's being adding and/or fixed -->

  It has been noticed some issues by both users and developers, as reported in #149, https://github.com/bitcoindevkit/bdk/issues/1598 and https://github.com/wizardsardine/liana/issues/1300, when using the library with `use-rustls-{ring}` feature to connect to electrum servers that use self-signed certificates, there are even some issues when trying to connect to `ssl://electrum.blockstream.info:50002` server.

  To connect in an insecure manner either with `rustls` or `openssl` features, the user can set the `validate_domain` field in the `Config` to false, this will either set the `SslVerifyMode::NONE` when using `openssl`, or use the custom `NoCertificateVerification` for the
  `rustls::client::danger::ServerCertVerifier` trait when using `rustls`, that said it should ignore the certificate verification when used.

  At the current library state, it's failing because we didn't set up the supported `rustls::SignatureScheme` properly, returning an empty vector at the moment. This PR focuses on fixing this issue by relying on the `CryptoProvider` in usage to get the correct and supported signature schemes.

  As part of the research to understand the problem, I've noticed that ideally, we should still use both the `rustls::webpki::verify_tls12_signature` and `rustls::webpki::verify_tls12_signature` and only rely on `rustls::client::danger::ServerCertVerified::assertion()` to ignore the certificate verification, however, it would still fail in scenarios such as https://github.com/bitcoindevkit/bdk/issues/1598 which uses X.509 certificates with any version other than 3 (it uses version 1), see [here](1a0d1646d0/src/cert.rs (L202-L218)).

  I kept the current behavior to also ignore the TLS signature, but I still would like to bring this to the discussion, should we validate it properly and update the documentation to mention the `webpki` limitation instead ?

  ### Notes to the reviewers

  I kept the current behavior to also ignore the TLS signature, but I still would like to bring this to the discussion, should we validate it properly and update the documentation to mention the `webpki` limitation instead ?

  <!-- In this section you can include notes directed to the reviewers, like explaining why some parts
  of the PR were done in a specific way -->

  ### Changelog notice

  - Updates the `NoCertificateVerification` implementation for the
  `rustls::client::danger::ServerCertVerifier` to use the `rustls::SignatureScheme` from `CryptoProvider` in use.

  <!-- Notice the release manager should include in the release tag message changelog -->
  <!-- See https://keepachangelog.com/en/1.0.0/ for examples -->

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### New Features:

  * [ ] I've added tests for the new feature
  * [ ] I've added docs for the new feature

  #### Bugfixes:

  * [ ] This pull request breaks the existing API
  * [ ] I've added tests to reproduce the issue which are now passing
  * [ ] I'm linking the issue being fixed by this PR

ACKs for top commit:
  LLFourn:
    ACK 05771a81d7
  ValuedMammal:
    ACK 05771a81d7
  notmandatory:
    ACK 05771a81d7

Tree-SHA512: f74dedf458853fb19cd21dedb5b92158acd865ee0ab0fd6bbb2b3e267bac22edc7cf004d2dc0068f66d2665d87e6dd419231710a02317e3b2bfaa9f408b30759
2024-10-23 12:51:45 -04:00
.github/workflows chore(ci): add fmt and clippy checks 2024-08-06 15:06:16 -05:00
examples timeout() and socks() don't return Result 2022-09-13 09:27:03 +02:00
src fix: NoCertificateVerification implementation 2024-09-27 14:36:14 -03:00
.gitignore Release 0.1.0-beta.1 2020-02-06 18:15:22 +01:00
Cargo.toml Bump version to 0.21.0 and update CHANGELOG.md 2024-08-06 15:43:01 -05:00
CHANGELOG.md Bump version to 0.21.0 and update CHANGELOG.md 2024-08-06 15:43:01 -05:00
clippy.toml chore: fix clippy errors and set msrv to 1.63 2024-07-31 21:37:10 -05:00
LICENSE Initial commit 2020-02-06 17:54:27 +01:00
README.md ci: add test with MSRV 1.63.0 2024-05-27 12:56:17 -05:00

rust-electrum-client

Build Status Latest Version MSRV Badge

Bitcoin Electrum client library. Supports plaintext, TLS and Onion servers.