rfq: add price oracle certificate verification#1775
rfq: add price oracle certificate verification#1775jtobin wants to merge 9 commits intolightninglabs:mainfrom
Conversation
Pull Request Test Coverage Report for Build 21747678444Details
💛 - Coveralls |
77cad42 to
9910220
Compare
|
(Changed this from draft; I think the litd tests are failing for an unrelated reason.) |
|
(As pointed out by @ZZiigguurraatt, to be more precise: TLS support already existed for price oracles, but certificate verification was skipped entirely.) |
ffranr
left a comment
There was a problem hiding this comment.
There are other cases where we need more precise control over TLS behavior. For example:
taproot-assets/proof/courier.go
Lines 309 to 320 in a17a67a
With that in mind, I wonder if we could define a more general, reusable solution in something like the new rfq/tls.go file, especially given the need for configuration and the importance of which package owns this logic.
2b3ac4f to
035a840
Compare
cdcbb04 to
86887bf
Compare
I looked into this and agree that it's probably worth centralizing our TLS handling, but I'd consider it out of scope for this change set, which does resolve a concrete issue as-is. Maybe we can open a broader "refactor TLS handling" issue for that? I get the following hits for "crypto/tls" imports, as a rough metric: |
The mock oracle uses a self-signed certificate for TLS, but we're not concerned with having tapd verify it in the itest environment. This commit adds the 'experimental.rfq.priceoracletlsinsecure' flag added in lightninglabs/taproot-assets#1775 to the litd args list, instructing tapd not to verify certificates.
|
The LiT itest failure should be resolved by lightninglabs/lightning-terminal#1190. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces TLS certificate verification for price oracle connections, a significant security enhancement. The changes are well-structured, with new configuration options for TLS control and the core logic neatly encapsulated in a new rfq/tls.go file, complete with thorough testing. The updates to the configuration and test files are consistent and correct. I have one minor suggestion to update a function comment to align with the new function signature, improving clarity for future developers.
|
@GeorgeTsagk @ffranr this one should be good for {re-}review whenever. |
ffranr
left a comment
There was a problem hiding this comment.
Some trivial comments to be removed, for example:
// Construct the oracle's TLS configuration.
Otherwise, just nits. I can quickly approve from here.
|
Note that the failing itest case passes with the changes in lightninglabs/lightning-terminal#1190. |
Introduces rfq/tls.go, which contains a basic TLSConfig type and default value of such. The default value, which for now only indicates that certificate verification should be skipped, is used in place of the 'dialInsecure' bool when setting up the price oracle RPC.
Adds both 'TrustSystemRootCAs' and 'CustomCertificates' to the rfq TLSConfig. The former indicates whether or not to trust the operating system's root CA list; the latter allows additional certificates (CA or self-signed) to be trusted. Also adds a basic unit test skeleton.
We don't skip certificate verification by default, and also default to trusting the operating system's root CA list.
Adds some basic test cases for configuring transport credentials.
Previously we would ignore this, but it's arguably better to return an error here that at least describes what happened.
Ensures that certificate verification is skipped when constructing a communication channel with the itest oracle harness.
Ensures the price oracle TLS toggle fits the existing pattern of flags defaulting to false.
Previously the TLSConfig contained an 'Enabled' field that, as a bool, defaulted to 'false'. It is cleaner to use a 'Disabled' field such that, by default, TLS is enabled. This cleans up some flipping logic in the user-facing config handling. Also addresses a few minor formatting nits in several files.
Adds certificate verification for TLS communication with price oracles, mostly following the suggestions proposed in #1278. Adds configuration options for skipping certificate verification, distrusting the operating system's root CA list, and using a custom certificate.
Resolves #1278.