mirror of
https://code.hexops.org/hexops/autocert.git
synced 2026-11-17 02:30:28 +00:00
ACME/LetsEncrypt client for Zig
- Zig 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| example | ||
| src | ||
| .gitattributes | ||
| .gitignore | ||
| build.zig | ||
| build.zig.zon | ||
| LICENSE | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| README.md | ||
autocert - ACME/LetsEncrypt client for Zig
autocert is a small Zig library for ACME HTTP-01 certificate issuance and
renewal, intended to allow Zig services to manage Let's Encrypt certificates
in-process.
Reverse proxy
autocert provides an in-process TLS reverse proxy, which can acquire/renew
certificates via e.g. Let's Encrypt, and terminate TLS traffic (via tls.zig) before proxying it to your in-process HTTP server. The proxy
supports HTTP/1.1, chunked encodings, and WebSockets.
Limitations:
- TLS 1.3 only, older TLS handshake versions are not supported.
- HTTP/1.1 and WebSockets only, no HTTP/2 support, no HTTP/3/QUIC support.
- WebSocket support is not yet high-throughput full-duplex: TLS connection access must be serialized
because
tls.Connectiondoes not guarantee concurrent read/write safety (tls.zig#34). Server-to-client WebSocket messages may be delayed by up toTLSReverseProxy.Options.websocket_poll_timeout_mswhile the proxy polls client reads, so it is not yet suitable as a high-throughput full-duplex WebSocket tunnel as a result.
Usage
See example/main.zig for a complete example of usage.
Build the example:
zig build -Dtarget=x86_64-linux -Dcpu=x86_64_v3 -Doptimize=ReleaseFast
It can be run on a Linux host with e.g. example.com DNS pointed at it:
export HTTP_PORT='80'
export HTTP_BIND_HOST='0.0.0.0'
export ENABLE_HTTPS='true'
export HTTPS_PORT='443'
export HTTPS_BIND_HOST='0.0.0.0'
export HTTP_REDIRECT_HTTPS='true'
export ACME_DOMAIN='example.com'
export ACME_CONTACT_EMAIL='admin@example.com'
export ACME_TERMS_OF_SERVICE_AGREED='true'
export ACME_DIRECTORY_URL='https://acme-v02.api.letsencrypt.org/directory'
export DATA_DIR='/var/lib/autocert'
export BASE_URL='https://example.com'
./zig-out/bin/autocert-example