You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: check it out and use "TOFU" (trust on first use) for self-signed certificates #176
Instead of just ignoring and not validating the self-signed certificates, we probably should use the "TOFU" (trust on first use) for the self-signed certificates.
I didn't put much thought into it yet, need to review thoroughly the frostnsnap PR. At first I thought to have it as an option that you pass the map with trusted certificates when you're creating the client, but you'd need to store it somewhere else.
It would make previously-seen certificates usage easier if we add persistance such as frostsnap did, but still not sure if the overhead of yet another dependency is worth it.
I didn't put much thought into it yet, need to review thoroughly the frostnsnap PR. At first I thought to have it as an option that you pass the map with trusted certificates when you're creating the client, but you'd need to store it somewhere else.
It would make previously-seen certificates usage easier if we add persistance such as frostsnap did, but still not sure if the overhead of yet another dependency is worth it.
I’m working on this issue in a fork. The part about persisting already-seen certificates in a SQLite database (as done in Frostsnap) would still be simple to set up, but it would introduce more dependencies. I’ve been thinking about saving a JSON file that I read from and write to, storing the corresponding certificate for each host that has been seen. However, even though this avoids adding more dependencies, I don’t consider it the best option.
Do you think it would be better to keep using SQLite, or should I switch to this approach of saving a JSON file?
Do you think it would be better to keep using SQLite, or should I switch to this approach of saving a JSON file?
IMO neither is really acceptable for a utility crate such as rust-electrum-client, which shouldn't assume any particular kind of IO/persistence. If we want to support TOFU, it would probably need to happen behind a feature that exposes a trait or callback letting the user know they need to persist a certain certificate. The persisted certificates could then also be given as an argument to an alternative constructor.
Do you think it would be better to keep using SQLite, or should I switch to this approach of saving a JSON file?
IMO neither is really acceptable for a utility crate such as rust-electrum-client, which shouldn't assume any particular kind of IO/persistence. If we want to support TOFU, it would probably need to happen behind a feature that exposes a trait or callback letting the user know they need to persist a certain certificate. The persisted certificates could then also be given as an argument to an alternative constructor.
I have a few updates regarding my progress on this issue.
Indeed, I was heading in a not-so-correct direction by adding a database dependency for our own implementation. Instead, the solution now consists of exposing a trait responsible for certificate persistence.
It is up to the user to provide their own implementation and pass it through the ConfigBuilder. During client initialization, we check whether an implementation was provided; if so, the client establishes an SSL connection using TOFU logic. This implementation was adapted to handle the specifics of both rustls and open-ssl, ensuring correct behavior regardless of which one is chosen.
I have a few updates regarding my progress on this issue.
Indeed, I was heading in a not-so-correct direction by adding a database dependency for our own implementation. Instead, the solution now consists of exposing a trait responsible for certificate persistence.
It is up to the user to provide their own implementation and pass it through the ConfigBuilder. During client initialization, we check whether an implementation was provided; if so, the client establishes an SSL connection using TOFU logic. This implementation was adapted to handle the specifics of both rustls and open-ssl, ensuring correct behavior regardless of which one is chosen.
Could you give me some feedback on this approach?
Generally sounds good, a point of discussion could be whether to pass it as part of ConfigBuilder or via a separate constructor. For further feedback it would help if you open a draft PR, which would allow us to see how the concrete code changes look like.
I have a few updates regarding my progress on this issue.
Indeed, I was heading in a not-so-correct direction by adding a database dependency for our own implementation. Instead, the solution now consists of exposing a trait responsible for certificate persistence.
It is up to the user to provide their own implementation and pass it through the ConfigBuilder. During client initialization, we check whether an implementation was provided; if so, the client establishes an SSL connection using TOFU logic. This implementation was adapted to handle the specifics of both rustls and open-ssl, ensuring correct behavior regardless of which one is chosen.
Could you give me some feedback on this approach?
Generally sounds good, a point of discussion could be whether to pass it as part of ConfigBuilder or via a separate constructor. For further feedback it would help if you open a draft PR, which would allow us to see how the concrete code changes look like.
Activity
oleonardolima commentedon Sep 18, 2025
see: frostsnap/frostsnap#278
tnull commentedon Nov 4, 2025
How will this work without adding persistence to
electrum-clientthat would allow to store previously-seen certificates?oleonardolima commentedon Nov 18, 2025
I didn't put much thought into it yet, need to review thoroughly the frostnsnap PR. At first I thought to have it as an option that you pass the map with trusted certificates when you're creating the client, but you'd need to store it somewhere else.
It would make previously-seen certificates usage easier if we add persistance such as frostsnap did, but still not sure if the overhead of yet another dependency is worth it.
lucasdbr05 commentedon Dec 30, 2025
I’m working on this issue in a fork. The part about persisting already-seen certificates in a SQLite database (as done in Frostsnap) would still be simple to set up, but it would introduce more dependencies. I’ve been thinking about saving a JSON file that I read from and write to, storing the corresponding certificate for each host that has been seen. However, even though this avoids adding more dependencies, I don’t consider it the best option.
Do you think it would be better to keep using SQLite, or should I switch to this approach of saving a JSON file?
tnull commentedon Jan 1, 2026
IMO neither is really acceptable for a utility crate such as
rust-electrum-client, which shouldn't assume any particular kind of IO/persistence. If we want to support TOFU, it would probably need to happen behind a feature that exposes a trait or callback letting the user know they need to persist a certain certificate. The persisted certificates could then also be given as an argument to an alternative constructor.lucasdbr05 commentedon Jan 13, 2026
I have a few updates regarding my progress on this issue.
Indeed, I was heading in a not-so-correct direction by adding a database dependency for our own implementation. Instead, the solution now consists of exposing a trait responsible for certificate persistence.
It is up to the user to provide their own implementation and pass it through the
ConfigBuilder. During client initialization, we check whether an implementation was provided; if so, the client establishes an SSL connection using TOFU logic. This implementation was adapted to handle the specifics of bothrustlsandopen-ssl, ensuring correct behavior regardless of which one is chosen.Could you give me some feedback on this approach?
tnull commentedon Jan 13, 2026
Generally sounds good, a point of discussion could be whether to pass it as part of
ConfigBuilderor via a separate constructor. For further feedback it would help if you open a draft PR, which would allow us to see how the concrete code changes look like.lucasdbr05 commentedon Jan 14, 2026
Draft PR opened (see #193).
@tnull @oleonardolima