Skip to content

[bug]: TLS manager fails to create certificate if key file exists #10392

@thiagorb

Description

@thiagorb

Pre-Submission Checklist

  • I have searched the existing issues and believe this is a new bug.
  • I am not asking a question about how to use lnd, but reporting a bug (otherwise open a discussion).

LND Version

lnd version 0.20.0-beta commit=v0.20.0-beta

LND Configuration

Irrelevant

Backend Version

Neutrino

Backend Configuration


OS/Distribution

Ubuntu 22.04

Bug Details & Steps to Reproduce

  1. Start a docker container docker run --rm -it --entrypoint bash lightninglabs/lnd:v0.20.0-beta
  2. Create a dummy config file (optional): touch ~/.lnd/lnd.conf
  3. Start lnd with the command lnd --bitcoin.regtest --bitcoin.node=neutrino
  4. Terminate lnd
  5. Start lnd with the command lnd --bitcoin.regtest --bitcoin.node=neutrino --tlscertpath=/tmp/tls.cert
    Output:
2025-11-25 19:15:51.523 [INF] LTND: Version Info rev=b9ea70 version=0.20.0-beta commit=v0.20.0-beta debuglevel=production logging=info
2025-11-25 19:15:51.523 [INF] LTND: Network Info rev=b9ea70 active_chain=Bitcoin network=regtest
2025-11-25 19:15:51.523 [ERR] LTND: Shutting down due to error in main method rev=b9ea70 err="unable to generate or renew TLS certificate: open /tmp/tls.cert: no such file or directory"
2025-11-25 19:15:51.523 [INF] LTND: Shutdown complete
error setting cert before unlock: unable to generate or renew TLS certificate: open /tmp/tls.cert: no such file or directory

Expected Behavior

LND creates a new pair of tls.key and tls.cert

OR

LND crashes with a message that says "TLS key found at but certificate does not exist at "

Debug Information

The condition in https://github.com/lightningnetwork/lnd/blob/master/tls_manager.go#L212-L213 could be changed to &&, and then the certificate would be generated. I think it is a valid solution, considering that lnd regenerates the certificates if they expired, so why not if one of the files is missing.

Environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnintended code behaviourneeds triageneutrinoLightweight neutrino backend-type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions