Description
By default, people will point DNSLink website at their own go-ipfs and set up proper TLS cert for the domain.
This is how https://en.wikipedia-on-ipfs.org works.
Problems when loading DNSLink website from a public gateway
There are known problems when someone tries to load DNSLink website from an alternative, public gateway:
- path-based gateway at https://ipfs.io/ipns/en.wikipedia-on-ipfs.org works fine, but does not provide Origin isolation and can't be used for dapps and advanced websites
- subdomain gateway at https://dweb.link/ipns/en.wikipedia-on-ipfs.org returns redirect to http://en.wikipedia-on-ipfs.org.ipns.dweb.link which provides Origin isolation, but also returns TLS error due to the way certs work.
- TLS certificates support only a single level of wildcards (
*.ipns.dweb.link
and*.ipfs.dweb.link
). This works fine for CIDs, which are a single DNS label, but DNSLink names have.
in them, which introduces more than one level.
- TLS certificates support only a single level of wildcards (
Constraints
I think the main criteria for DNSLink representation are:
- DNS label representing FQDN with DNSLink should remain human-readable
- When loaded in web browser DNSLink website should get proper Origin isolation between content roots
- Subdomain URLs should work with any HTTP client
Solving the TLS problem
👉 Below is a summary of options I see, would love to hear what others think / do sanity check on this / propose your own.
(A) Mining wildcard certificates on the fly
My understanding is that to support DNSLink in subdomains at our public gateway without this TLS error we would have to create some magical orchestration which "mines certificate" on first load.
While it should be technically possible via some nginx+lua hackery (needs sanity check), it may violate ToS of services like Let's Encrypt. This means we would have to work with CA, make our case and ensure they won't ban us when we do it. If we have green light, we could either document the setup for other gateways to use, or consider implementing the magic it in go-ipfs' gateway itself.
💔 I don't like this because it brings complexity/centralization of PKI deep into go-ipfs/gateway logic, ale we should avoid that if we can.
(B) Do nothing, live with TLS errors
We could just live with the TLS error, and when someone points it out say "to be independent of centralized PKI you need to Install IPFS Desktop and IPFS Companion".
💔 Avoiding the problem is bad, but also I worry people won't understand nuance why, and just take a note that "IPFS breaks/ignores web security", which is a pretty bad meme.
(C) Encode FQDN to a string that fits in a single DNS label
This may be the least painful fix so far: if we come up with a way of encoding domain names to something that fits in a single DNS label (max 63 characters), then https://dweb.link/ipns/foo.tld
would redirect to https://{encoded-foo-tld}.ipfs.dweb.link
and there would be no TLS error (at last for domains shorter than 63 characters).
💚 The encoding step could be added to go-ipfs (just like we convert to base36 if base32 is too long) and that way every gateway would support this with pre-existing TLS certs (no additional setup, seamless upgrade).
Challenges:
- FQDN encoding needs to be both human-readable and non-spoofable (how to tell
foo-bar.tld
vsfoo.bar.tld
apart if both are represented asfoo-bar-tld
etc) - Encoding means one no longer can just add/remove
.ipns.example.com
suffix to get the original domain name,
but its still a lesser evil for public gateways. And when native IPFS is used on localhost subdomains, we can keep original domain names because there is no TLS.