Conversation
Add support for manual TLS certificate/key files for WSS listeners on custom domains, complementing the existing AutoTLS feature which only covers *.libp2p.direct domains. Operators place $IPFS_PATH/<domain>.crt and $IPFS_PATH/<domain>.key in the IPFS repo, and Kubo serves those certificates for the matching SNI hostname on /wss connections. This follows the same file-convention approach as the private network swarm.key. Manual certs coexist with AutoTLS: manual certs take precedence for matching SNI hostnames, and p2p-forge's certmagic is used as fallback for *.libp2p.direct domains. Loaded certificates are cached in memory and automatically reloaded when files change on disk. Closes ipfs#11460. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Summary
Draft / RFC PR to drive design discussion for #11460.
Adds support for manual TLS certificate/key files for WSS (
/wss) listeners on custom domains, complementing the existingAutoTLSfeature which only covers*.libp2p.directdomains.Motivation
This addresses the remaining review concern from @lidel on #8740 (now superseded by #10521):
Currently, operators who want WSS on their own domain (e.g.
example.net) must run a reverse proxy (nginx, Caddy, etc.) in front of Kubo. This PR lets them serve WSS directly from Kubo using their own certificates.Design
Follows the file convention approach (same as
swarm.keyfor private networks):$IPFS_PATH/<domain>.crtand$IPFS_PATH/<domain>.keyin the IPFS repo/dns/example.net/.../wssaddress toAddresses.Swarmexample.net, Kubo loads the matching cert/key filesCoexistence with AutoTLS:
*.libp2p.direct)Implementation
core/node/libp2p/manualtls.go— cert cache +GetCertificatecallback that checks manual files first, falls back to p2p-forgecore/node/libp2p/transport.go— wires the manual cert getter into the websocket transport's TLS configcore/node/groups.go— passes repo path toTransports()docs/config.md— documents the file conventiondocs/changelogs/v0.44.md— changelog entrycore/node/libp2p/manualtls_test.go— unit tests for cache, loading, fallback, and edge casesOpen questions for reviewers
$IPFS_PATH/<domain>.crt) vs. a subdirectory ($IPFS_PATH/wss-certs/<domain>.crt)? The repo root follows theswarm.keyprecedent but could get cluttered with many domains.Swarm.Transports.Network.Websocket.ManualTLS), or is the file convention sufficient as an implicit opt-in?*.example.net.crtmatchingfoo.example.net)?Closes #11460.
Test plan
go build ./core/... ./cmd/...passesgo vet ./core/node/...passesgofmtcleango test ./core/node/libp2p/ -run TestManualCert -vGenerated with Devin