Skip to content

Commit

Permalink
new-post: Stateless DANE websites with Caddy
Browse files Browse the repository at this point in the history
  • Loading branch information
rithvikvibhu committed Mar 2, 2024
1 parent 5febfff commit f90f89c
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 2 deletions.
2 changes: 1 addition & 1 deletion content/posts/hns-pdns-nginx-part-3/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ or to fix incorrect details, or for anything related to Handshake.

You may also want to join Handshake groups on
[Telegram](https://t.me/handshake_hns) and
[Discord](https://discord.gg/AtqtxGckqX) to show off your shiny new website :D
[Discord](https://handshake.org/discord) to show off your shiny new website :D
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
131 changes: 131 additions & 0 deletions content/posts/stateless-dane-caddy/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
title: 'Stateless DANE websites with Caddy'
date: 2024-03-02T00:00:00+05:30
draft: false
description: Set up a Stateless DANE website in ~15 minutes with Caddy!
---

In this guide, we set up a new website on a Handshake domain and secure it with
Stateless DANE. Caddy is the recommended way to set up such websites.

Learn more about [Handshake](https://handshake.org/),
[DANE](https://en.wikipedia.org/wiki/DNS-based_Authentication_of_Named_Entities),
and [Stateless DANE](TODO).

## Install Caddy

This post assumes Ubuntu; for other OS/distros, see Caddy’s [official install
docs](https://caddyserver.com/docs/install).

Install caddy with:

```sh
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install -y caddy
```

> **Temporary note:** until caddy v2.8.0 is released in ~March 2024, it needs to
> be built from source. So if the above installed a newer version of caddy (>
> 2.7.6), skip the rest of this section.
```sh
# Only follow this until caddy 2.8.0+ is released

# Install go
sudo snap install go --classic

# Build caddy from source
git clone https://github.com/caddyserver/caddy.git
cd caddy/cmd/caddy/
go build

# Set up the newly build caddy as an alt to the standard caddy
sudo dpkg-divert --divert /usr/bin/caddy.default --rename /usr/bin/caddy
sudo mv ./caddy /usr/bin/caddy.custom
sudo update-alternatives --install /usr/bin/caddy caddy /usr/bin/caddy.default 10
sudo update-alternatives --install /usr/bin/caddy caddy /usr/bin/caddy.custom 50
sudo systemctl restart caddy

# the above is adapted from https://caddyserver.com/docs/build#package-support-files-for-custom-builds-for-debianubunturaspbian
```

We’ll make sure caddy is running with `sudo systemctl status caddy` before
moving to the next section. The `Active:` line should say **active (running)**.

## Website setup

I won’t go into detail on all the features Caddy offers — they have excellent
[documentation](https://caddyserver.com/docs/caddyfile-tutorial). Instead, we’ll
use the simplest config with the `respond` directive.

Edit the default Caddyfile with your favorite editor:

```sh
sudo vim /etc/caddy/Caddyfile
```

and update the file to look like this:

```caddy
demo.lazydane {
respond "This is a Handshake website!"
tls [email protected] {
reuse_private_keys
ca https://acme.htools.work/directory
}
}
```

- Replace `demo.lazydane` with your domain name (can be a bare TLD or SLD)
- Set your email address (does not have to be valid, anything will do)

Then notify caddy to read the new config with:

```sh
sudo systemctl reload caddy
```

## Set TLSA record

The final step is to set the TLSA record, just like a regular DANE website.

To find the record to be set, visit https://acme.htools.work/tlsa and enter your
domain name:

![Screenshot of HTools ACME TLSA page](images/acme-htools-tlsa.png)

> Another way to find this record is with `openssl`:
> [link](https://gist.github.com/buffrr/609285c952e9cb28f76da168ef8c2ca6?permalink_comment_id=4958955#gistcomment-4958955)
Set this record at your DNS host (PowerDNS, Varo, Namebase, etc.)

Visiting https://demo.lazydane/ should load without warnings (if you are
browsing securely with [Fingertip](https://impervious.com/fingertip)).

As of this point, the website is just secured with regular DANE.

## Where’s Stateless?

Since the certificate needs to include DNSSEC proofs of the TLSA record, they
will only be added after the TLSA record is set.

Now that we’ve set the TLSA record, the next time caddy renews the certificate,
it will get a Stateless DANE certificate.

We could simply wait for ~1.5 days and it would automatically take effect, but
let’s force caddy to renew the certificate now to skip the wait (replace your
domain name):

```sh
sudo rm /var/lib/caddy/.local/share/caddy/certificates/acme.htools.work-directory/demo.lazydane/demo.lazydane.crt
sudo systemctl restart caddy
```

And that’s it! Your website will trustlessly load anywhere Stateleess DANE is
supported.

Now show off your shiny new website in the Handshake groups on
[Telegram](https://t.me/handshake_hns) and
[Discord](https://handshake.org/discord)!
2 changes: 1 addition & 1 deletion themes/PaperMod
Submodule PaperMod updated 88 files
+0 −12 .github/FUNDING.yml
+4 −1 .github/ISSUE_TEMPLATE/bug_report.md
+0 −32 .github/workflows/build.yml
+57 −22 .github/workflows/gh-pages.yml
+1 −1 LICENSE
+28 −13 README.md
+1 −5 assets/css/common/header.css
+3 −5 assets/css/common/main.css
+7 −3 assets/css/common/post-entry.css
+36 −59 assets/css/common/post-single.css
+5 −5 assets/css/common/profile-mode.css
+6 −0 assets/css/core/license.css
+2 −22 assets/css/core/reset.css
+2 −2 assets/css/core/theme-vars.css
+6 −9 assets/css/core/zmedia.css
+0 −63 assets/css/hljs/an-old-hope.min.css
+24 −0 assets/css/includes/chroma-mod.css
+86 −0 assets/css/includes/chroma-styles.css
+63 −0 assets/css/includes/scroll-bar.css
+27 −22 assets/js/fastsearch.js
+9 −0 assets/js/fuse.basic.min.js
+0 −9 assets/js/fuse.js
+0 −44 assets/js/highlight.min.js
+6 −0 assets/js/license.js
+8 −2 i18n/ar.yaml
+39 −0 i18n/be.yaml
+7 −2 i18n/bn.yaml
+33 −0 i18n/cs.yaml
+18 −4 i18n/de.yaml
+33 −0 i18n/el.yaml
+10 −2 i18n/en.yaml
+19 −2 i18n/es.yaml
+10 −5 i18n/fr.yaml
+19 −5 i18n/he.yaml
+5 −2 i18n/hi.yaml
+33 −0 i18n/hr.yaml
+20 −3 i18n/id.yaml
+14 −3 i18n/it.yaml
+19 −2 i18n/ja.yaml
+28 −0 i18n/ko.yaml
+5 −5 i18n/ku.yaml
+28 −0 i18n/ms.yaml
+5 −0 i18n/nl.yaml
+33 −0 i18n/no.yaml
+7 −2 i18n/pl.yaml
+17 −0 i18n/pt.yaml
+33 −0 i18n/ro.yaml
+17 −1 i18n/ru.yaml
+33 −0 i18n/sk.yaml
+28 −0 i18n/sv.yaml
+33 −0 i18n/sw.yaml
+33 −0 i18n/th.yaml
+10 −2 i18n/tr.yaml
+9 −1 i18n/vi.yaml
+10 −2 i18n/zh-tw.yaml
+8 −0 i18n/zh.yaml
+29 −4 layouts/_default/archives.html
+6 −2 layouts/_default/baseof.html
+1 −1 layouts/_default/index.json
+44 −12 layouts/_default/list.html
+60 −27 layouts/_default/rss.xml
+1 −1 layouts/_default/search.html
+14 −8 layouts/_default/single.html
+1 −1 layouts/_default/terms.html
+2 −2 layouts/partials/author.html
+2 −2 layouts/partials/breadcrumbs.html
+11 −8 layouts/partials/cover.html
+4 −4 layouts/partials/edit_post.html
+10 −10 layouts/partials/footer.html
+53 −63 layouts/partials/head.html
+47 −19 layouts/partials/header.html
+5 −5 layouts/partials/home_info.html
+41 −6 layouts/partials/index_profile.html
+2 −2 layouts/partials/post_canonical.html
+8 −2 layouts/partials/post_meta.html
+69 −45 layouts/partials/share_icons.html
+4 −3 layouts/partials/social_icons.html
+362 −29 layouts/partials/svg.html
+22 −7 layouts/partials/templates/opengraph.html
+14 −14 layouts/partials/templates/schema_json.html
+22 −5 layouts/partials/templates/twitter_cards.html
+6 −2 layouts/partials/toc.html
+3 −3 layouts/partials/translation_list.html
+1 −1 layouts/robots.txt
+0 −72 layouts/shortcodes/blockquote.html
+5 −0 layouts/shortcodes/inTextImg.html
+1 −1 layouts/shortcodes/rawhtml.html
+1 −1 theme.toml

0 comments on commit f90f89c

Please sign in to comment.