#acme #https #tls #autocert #alpn

tide-acme

Automatic HTTPS certificates for Tide, via Let's Encrypt and ACME tls-alpn-01 challenges

3 unstable releases

0.2.0 Jun 20, 2022
0.2.0-beta.1 May 24, 2022
0.1.1 Apr 19, 2021
0.1.0 Mar 21, 2021

#330 in HTTP server

Download history 22/week @ 2022-10-07 7/week @ 2022-10-14 19/week @ 2022-10-21 29/week @ 2022-10-28 24/week @ 2022-11-04 22/week @ 2022-11-11 19/week @ 2022-11-18 12/week @ 2022-11-25 11/week @ 2022-12-02 28/week @ 2022-12-09 12/week @ 2022-12-16 20/week @ 2022-12-23 11/week @ 2022-12-30 14/week @ 2023-01-06 15/week @ 2023-01-13 70/week @ 2023-01-20

115 downloads per month
Used in 3 crates

MIT/Apache

10KB
56 lines

tide-acme helps you serve HTTPS with Tide using automatic certificates, via Let's Encrypt and ACME tls-alpn-01 challenges.

Documentation

To use tide-acme, set up HTTPS with Tide normally using tide_rustls, but instead of specifying a certificate and key, call the acme method to configure automatic certificates in the TLS listener:

use tide_acme::{AcmeConfig, TideRustlsExt};
use tide_acme::rustls_acme::caches::DirCache;

let mut app = tide::new();
app.at("/").get(|_| async { Ok("Hello TLS") });
app.listen(
    tide_rustls::TlsListener::build().addrs("0.0.0.0:443").acme(
        AcmeConfig::new(vec!["domain.example"])
            .contact_push("mailto:admin@example.org")
            .cache(DirCache::new("/srv/example/tide-acme-cache-dir")),
    ),
)
.await?;

This will configure the TLS stack to obtain a certificate for the domain domain.example, which must be a domain for which your Tide server handles HTTPS traffic.

On initial startup, your server will register a certificate via Let's Encrypt. Let's Encrypt will verify your server's control of the domain via an ACME tls-alpn-01 challenge, which the TLS listener configured by tide-acme will respond to.

You must supply a cache via [AcmeConfig::cache] or one of the other cache methods. This cache will keep the ACME account key and registered certificates between runs, needed to avoid hitting rate limits. You can use [rustls_acme::caches::DirCache] for a simple filesystem cache, or implement your own caching using the rustls_acme cache traits.

By default, tide-acme will use the Let's Encrypt staging environment, which is suitable for testing purposes; it produces certificates signed by a staging root so that you can verify your stack is working, but those certificates will not be trusted in browsers or other HTTPS clients. The staging environment has more generous rate limits for use while testing.

When you're ready to deploy to production, you can call .directory_lets_encrypt(true) to switch to the production Let's Encrypt environment, which produces certificates trusted in browsers and other HTTPS clients. The production environment has stricter rate limits.

tide-acme builds upon tide-rustls and rustls-acme.

Dependencies

~17–25MB
~516K SLoC