feat(lightning): support loading LND TLS certificate from file#3861
Conversation
Add optional LIGHTNING_API_CERTIFICATE_PATH env var. When set and the file is readable, the LND TLS certificate is read from disk (the live cert); otherwise it falls back to the existing LIGHTNING_API_CERTIFICATE env var, unchanged. Fully backward compatible.
|
Suggestion: remove the fallback entirely The silent catch-all fallback to Hidden fallbacks are also confusing when debugging: "is my app using the live cert or the stale one?" Since:
→ I'd remove the fallback and the |
|
Done — removed the fallback. One knock-on: this app code is shared with dfxprd, which wasn't in the original (dfxdev-only) scope. To avoid breaking prod once the env var is gone, I also migrated dfxprd in the infra PR (mount the live cert + set the path env on the prod dfx-api/lds-api services). See DFXServer/server#366. |
|
davidleomay
left a comment
There was a problem hiding this comment.
Approved. Deploy after server PR (DFXServer/server#366) — that adds the cert mount + LIGHTNING_API_CERTIFICATE_PATH env var.
c9ee3d6 to
49ac77e
Compare
|
Small refinement after CI: |
Address review: if LIGHTNING_API_CERTIFICATE_PATH is set, read it or throw. The LIGHTNING_API_CERTIFICATE env var was the stale copy this change fixes, so keeping it as a silent fallback only masks a broken mount. Remove it.
49ac77e to
bf4ee74
Compare
Problem
The LND TLS certificate is currently loaded only from the
LIGHTNING_API_CERTIFICATEenv var, which is hand-copied. When the live cert on the node is rotated/regenerated, the env var goes stale and the app starts throwing recurring "self-signed certificate" errors on dfxdev.Change
Adds support for an optional env var
LIGHTNING_API_CERTIFICATE_PATH. When it is set and the file is readable, the app reads the live certificate directly from disk. Otherwise it falls back to the existingLIGHTNING_API_CERTIFICATEenv var, completely unchanged.readCert()helper insrc/config/config.tsfeeds the existingcertificateconfig field.ca) is untouched..env.exampledocuments the new optional var.Backward compatibility
Fully backward compatible. With no
LIGHTNING_API_CERTIFICATE_PATHset, behavior is identical to before (and an unreadable path silently falls back to the env var). Safe to deploy first — no behavior change until the path env is set.Related
LightningDotSpace/apiPR Masternode Resign / KYC #200.Testing
npx tsc --noEmit— passesjestconfig + lightning specs — 18 passing