FiloSottile / FiloSottile/torchwood
litebastion: no error message when TLS certificate configuration fails
- Dominant language
- Go
- Stars
- 29
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Description
I was setting up litebastion on a server where port 443 was already used for something else, so I configured litebastion to use another port number using `-listen 0.0.0.0:3333`. From what I could see on the bastion server itself, litebastion was up and running and there was no error message indicating any trouble. But clients could not connect, and it turned out to be because it had no TLS certificate and it failed to get a certificate because the ALPN ACME challenge tries to use port 443 which on this server was used for something else.
The cmd/litebastion/README.md file says the following:
```
Since litebastion needs to operate at a lower level than HTTPS on the witness
side, it can't be behind a reverse proxy, and needs to configure its own TLS
certificate. Use the `-cache`, `-email`, and `-host` flags to configure the ACME
client. The ALPN ACME challenge is used, so as long as the `-listen` port
receives connections to the `-host` name at port 443, everything should just
work.
```
So, it's not strange that it did not work, arguably the user (me) should have read the documentation and understand that port 443 is needed.
But I do think that the behavior of litebastion in this case is confusing. Clients that try to connect just end up waiting until a timeout, presumably because litebastion is trying (failing) to get a certificate. On the bastion server side, there is no error message and also no log message at all related to the TLS certificate configuration. So the situation is unclear, things are not working and there is no clear indication of why.
One thing the user can do is to look in the chosen `-cache` directory (directory to cache ACME certificates at) and see that no certificate files have appeared there, and in this way figure out that there is a problem with the ALPN ACME challenge.
It would have been helpful if there was an error message saying that the ALPN ACME challenge failed.
Another thing that would have helped is if there was an informational log message before ("Trying to get cert") and after each attempt to get a certificate ("Successfully got cert"). Then the user could see the message about trying but no message about success, and understand that there was a problem.
Related to https://github.com/FiloSottile/torchwood/issues/9
Contributor guide
Research direction
Read cmd/litebastion/README.md for the TLS and ALPN ACME requirements, then reproduce the failure with -listen 0.0.0.0:3333 while port 443 is occupied. Trace the certificate setup and make each attempt report failure or success clearly; done means a failed challenge no longer leaves the server silent while clients wait for a timeout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100