-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(AutoTLS): opt-in WSS certs from p2p-forge at libp2p.direct #10521
Changes from 20 commits
ce6d09d
ecfc8d9
fe307da
bfc73d0
7c9842e
bef0a21
06708d8
af543af
946298b
d5994c1
7ae58bc
4889612
a038637
538c9bb
b306f56
9bd8ebb
21b5c88
7eeda1b
99b7757
e6e0b7a
ed7e201
e51d907
73c3fd3
e68493a
bcabbb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package config | ||
|
||
import p2pforge "github.com/ipshipyard/p2p-forge/client" | ||
|
||
// AutoTLS includes optional configuration of p2p-forge client of service | ||
// for obtaining a domain and TLS certificate to improve connectivity for web | ||
// browser clients. More: https://github.com/ipshipyard/p2p-forge#readme | ||
type AutoTLS struct { | ||
// Enables the p2p-forge feature | ||
Enabled Flag `json:",omitempty"` | ||
|
||
// Optional override of the parent domain that will be used | ||
DomainSuffix *OptionalString `json:",omitempty"` | ||
|
||
// Optional override of HTTP API that acts as ACME DNS-01 Challenge broker | ||
RegistrationEndpoint *OptionalString `json:",omitempty"` | ||
|
||
// Optional Authorization token, used with private/test instances of p2p-forge | ||
RegistrationToken *OptionalString `json:",omitempty"` | ||
|
||
// Optional override of CA ACME API used by p2p-forge system | ||
CAEndpoint *OptionalString `json:",omitempty"` | ||
} | ||
|
||
const ( | ||
DefaultAutoTLSEnabled = false // experimental, opt-in for now (https://github.com/ipfs/kubo/pull/10521) | ||
DefaultDomainSuffix = p2pforge.DefaultForgeDomain | ||
DefaultRegistrationEndpoint = p2pforge.DefaultForgeEndpoint | ||
DefaultCAEndpoint = p2pforge.DefaultCAEndpoint | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,12 @@ config file at runtime. | |
- [`Swarm.DisableBandwidthMetrics`](#swarmdisablebandwidthmetrics) | ||
- [`Swarm.DisableNatPortMap`](#swarmdisablenatportmap) | ||
- [`Swarm.EnableHolePunching`](#swarmenableholepunching) | ||
- [`Swarm.AutoTLS`](#swarmautotls) | ||
- [`Swarm.AutoTLS.Enabled`](#swarmautotlsenabled) | ||
- [`Swarm.AutoTLS.DomainSuffix`](#swarmautotlsdomainsuffix) | ||
- [`Swarm.AutoTLS.RegistrationEndpoint`](#swarmautotlsregistrationendpoint) | ||
- [`Swarm.AutoTLS.RegistrationToken`](#swarmautotlsregistrationtoken) | ||
- [`Swarm.AutoTLS.CAEndpoint`](#swarmautotlscaendpoint) | ||
- [`Swarm.EnableAutoRelay`](#swarmenableautorelay) | ||
- [`Swarm.RelayClient`](#swarmrelayclient) | ||
- [`Swarm.RelayClient.Enabled`](#swarmrelayclientenabled) | ||
|
@@ -1716,6 +1722,86 @@ Default: `true` | |
|
||
Type: `flag` | ||
|
||
### `Swarm.AutoTLS` | ||
|
||
AutoTLS enables publicly reachable Kubo nodes (those dialable from the public | ||
internet) to automatically obtain a wildcard TLS certificate for a DNS name | ||
unique to their PeerID at `*.[PeerID].libp2p.direct`. This enables direct | ||
libp2p connections and retrieval of IPFS content from browsers using Secure | ||
WebSockets, without requiring manual domain registration and configuration. | ||
|
||
Under the hood, `libp2p.direct` acts as an [ACME DNS-01 Challenge](https://letsencrypt.org/docs/challenge-types/#dns-01-challenge) | ||
broker for obtaining these wildcard TLS certificates. | ||
|
||
By default, the certificates are requested from Let's Encrypt. | ||
Origin and rationale for this project can be found in [community.letsencrypt.org discussion]. | ||
lidel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
> [!NOTE] | ||
> Public good infrastructure at `libp2p.direct` is run by the team at [Interplanetary Shipyard](https://ipshipyard.com). | ||
> | ||
> <a href="http://ipshipyard.com/"><img src="https://github.com/user-attachments/assets/39ed3504-bb71-47f6-9bf8-cb9a1698f272" /></a> | ||
|
||
[p2p-forge]: https://github.com/ipshipyard/p2p-forge | ||
[community.letsencrypt.org discussion]: https://community.letsencrypt.org/t/feedback-on-raising-certificates-per-registered-domain-to-enable-peer-to-peer-networking/223003 | ||
|
||
Default: `{}` | ||
|
||
Type: `object` | ||
|
||
#### `Swarm.AutoTLS.Enabled` | ||
|
||
> [!CAUTION] | ||
> This is an EXPERIMENTAL feature and should not be used in production yet. | ||
2color marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> Feel free to enable it and [report issues](https://github.com/ipfs/kubo/issues/new/choose) if you want to help with testing. | ||
|
||
Enables **EXPERIMENTAL** [p2p-forge] client. This feature works only if your Kubo node is publicly diallable. | ||
|
||
If enabled, it will detect when `.../tls/sni/.../ws` is present in [`Addresses.Swarm`](#addressesswarm) | ||
and SNI is matching `Swarm.AutoTLS.DomainSuffix`, and set up a trusted TLS certificate matching the domain name used in Secure WebSockets (WSS) listener. | ||
|
||
If you want to test this, add `/ip4/0.0.0.0/tcp/4082/tls/sni/*.libp2p.direct/ws` to [`Addresses.Swarm`](#addressesswarm). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is port Can you use the same port as the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not yet, we need libp2p/go-libp2p#2984 for that. The idea is that TCP port sharing will land in go-libp2p before we enable AutoTLS by default. |
||
|
||
Debugging can be enabled by setting environment variable `GOLOG_LOG_LEVEL="error,p2p-forge/client=debug"` | ||
|
||
Default: `false` | ||
|
||
Type: `flag` | ||
|
||
#### `Swarm.AutoTLS.DomainSuffix` | ||
|
||
Optional override of the parent domain suffix that will be used in DNS+TLS+WebSockets multiaddrs generated by [p2p-forge] client. | ||
Do not change this unless you self-host [p2p-forge]. | ||
|
||
Default: `libp2p.direct` (public good run by [Interplanetary Shipyard](https://ipshipyard.com)) | ||
|
||
Type: `optionalString` | ||
|
||
#### `Swarm.AutoTLS.RegistrationEndpoint` | ||
|
||
Optional override of [p2p-forge] HTTP registration API. | ||
Do not change this unless you self-host [p2p-forge]. | ||
|
||
Default: `https://registration.libp2p.direct` (public good run by [Interplanetary Shipyard](https://ipshipyard.com)) | ||
|
||
Type: `optionalString` | ||
|
||
#### `Swarm.AutoTLS.RegistrationToken` | ||
|
||
Optional value for `Forge-Authorization` token sent with request to `RegistrationEndpoint` | ||
(useful for private/self-hosted/test instances of [p2p-forge]). | ||
|
||
Default: `""` | ||
|
||
Type: `optionalString` | ||
|
||
#### `Swarm.AutoTLS.CAEndpoint` | ||
|
||
Optional override of CA ACME API used by [p2p-forge] system. | ||
|
||
Default: [certmagic.LetsEncryptProductionCA](https://pkg.go.dev/github.com/caddyserver/certmagic#pkg-constants) (see [community.letsencrypt.org discussion]) | ||
|
||
Type: `optionalString` | ||
|
||
### `Swarm.EnableAutoRelay` | ||
|
||
**REMOVED** | ||
|
@@ -1835,7 +1921,7 @@ Type: `optionalInteger` | |
|
||
#### `Swarm.RelayService.MaxReservationsPerPeer` | ||
|
||
**REMOVED in kubo 0.32 due to removal from go-libp2p v0.37** | ||
**REMOVED in kubo 0.32 due to [go-libp2p#2974](https://github.com/libp2p/go-libp2p/pull/2974)** | ||
|
||
#### `Swarm.RelayService.MaxReservationsPerIP` | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a bug in cluster logs ("error while checking storage for updated ARI; updating ARI now"):
I suspect this is another race condition where certmanager things (like location
.local/share/certmagic/
) are initialized with default config before our config is applied (same problem as the logger).Will look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential fix in e51d907 and ipshipyard/p2p-forge@f599f48.
TLDR is that
certmagic.NewDefault
should be used only for prototyping, or if one is ok with default storage location and logger. Using dedicated cache and avoiding callingcertmagic.NewDefault
should remove surface for race condition in setting storage paths AFTER maintenance job is started.I'm going to deploy to collab cluster, let it run over night and see if ARI error is gone.
Update: so far the fix looks good, renewal check does not produce error anymore:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the error seems to be gone. Considering this resolved, but keeping this open for visibility.