Repository navigation
lndconnect: ask clightning for clnrest's cert dir - #270
Merged
Merged
Conversation
viberaven
reviewed
Nov 16, 2026
viberaven
left a comment
Contributor
There was a problem hiding this comment.
Reviewed 4b0259ba2e9d.
No actionable findings. Checked the shared certificate-path parser, relative/absolute/default path handling, RTL integration, caller-supplied certificate override, no-certificate paths, and warning/fallback behavior. The fallback preserves the old behavior when Core Lightning is unavailable, while RTL still fails if it cannot resolve its certificate. Local module-config, test-runner, and mdBook builds pass. I inspected the relative-cert-dir and offline-command VM coverage and successful CI results; I did not rerun those VMs locally.
Review performed with Codex (GPT-6 Astra).
lnconnect-clnrest always passed `server.pem` from clightning's network dir to lndconnect. clnrest reads its cert dir from `clnrest-certs`, which can also come from an included or per-network config file. With that option set, lnconnect-clnrest failed or put the wrong cert into the URL. Ask clightning for the effective `clnrest-certs`, like RTL does since clnrest.nix that both use. lnconnect-clnrest only asks when the URL includes the cert and the caller doesn't pass `--tlscertpath`. When clightning doesn't answer, for example because it's stopped, it prints a warning and uses the network dir, as before. RTL still fails then, because it pins the cert. `netnsRegtest` now sets a relative `clnrest-certs` dir, which `lnconnect-clnrest-cert` and the RTL tests check. Follow-up to bitcoinix#258. Assisted-by: Claude Code (Claude Opus 5.5)
ostermayer
force-pushed
the
lnconnect-clnrest-cert-dir
branch
from
November 18, 2026 00:19
4b0259b to
7a4e6c8
Compare
prusnak
enabled auto-merge
November 18, 2026 10:46
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.
Follow-up to #258.
lnconnect-clnrestalways passedserver.pemfrom clightning's network dir to lndconnect. clnrest reads its cert dir fromclnrest-certs, which can also come from anincludefile or the per-network config. With that option set,lnconnect-clnrestfailed, or it put a stale cert from the network dir into the URL. #258 solved the same problem for RTL at runtime.What this does
lnconnect-clnrestnow asks clightning for the effectiveclnrest-certswithlightning-cli listconfigs clnrest-certs, like RTL. It runs the query as its caller: root or a member of theclightninggroup.services.clightning.plugins.clnrest.serverCertPathFromConfigs. It reads thelistconfigsoutput on stdin and prints the path ofserver.pem. RTL andlnconnect-clnrestboth use it, and each runslightning-cliits own way. RTL's script does the same thing as before.clnrest.lnconnect.onion,--nocertand the caller's own--tlscertpathskip it. Solnconnect-clnrest-wgdoesn't depend on clightning at all.lnconnect-clnrestprints a warning and usesserver.pemfrom the network dir, as before. That happens when clightning is stopped, or when the caller can't read a config file thatlightning-clireads, for example anincludefile that only the clightning user can read. The warning says to run the command while clightning runs, or to pass--tlscertpath, whenclnrest-certsis set. RTL doesn't fall back. It pins the cert, so it still fails andRestart=on-failuretries again.nix-bitcoin.mkLndconnectgets an optionalgetCertPathCmdargument. Existing calls work as before.There's no versioning notice. Nothing that worked before fails now: without an answer from clightning,
lnconnect-clnrestdoes what it did before, with a warning.Testing
netnsRegtestnow setsclnrest-certs=rest-certs, a relative dir. There,lnconnect-clnrest-certcompares the URL's cert with clnrest's TLS handshake, which fails without this change.rtl-credentialsandrtl-backend-certsuse the cert and CA from that dir.regteststill uses the default dir for the same tests.wireguard-lndconnectstops clightning and checks thatlnconnect-clnrest-wg --urlprints the same URL as before.lnconnect-clnrest --urlthen prints the warning and a URL with a cert. That URL is the same as the one with--tlscertpath=<network dir>/server.pem, and that call prints no warning.listconfigsoutput with no value, a relative dir, an absolute dir with a space, invalid JSON and empty input. I also ran shellcheck on the generatedlnconnect-clnrest.On the KVM host,
netnsRegtest,wireguard-lndconnect,ciTestInfo,module-configandtest-runnerpass on the final head.regtestpassed on the previous head, which only differed in thelnconnect-clnrestfallback, its test and the docs.Models
Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes plus rechecks), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it.