1. Caddy version (caddy version
):
v2.4.3 h1:Y1FaV2N4WO3rBqxSYA8UZsZTQdN+PwcoOcAiZTM8C0I=
(linux version)
and
v2.4.5 h1:P1mRs6V2cMcagSPn+NWpD+OEYUYLIf6ecOa48cFGeUg=
(macos version)
2. How I run Caddy:
systemd
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
a. System environment:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
b. Command:
sudo systemctl start caddy.service
c. Service/unit/compose file:
see above
d. My complete Caddyfile or JSON config:
{
debug
on_demand_tls {
ask http://127.0.0.1:5000/_domain_check
}
acme_ca https://acme.zerossl.com/v2/DV90
acme_eab {
key_id nope
mac_key nope-nope
}
}
:443 {
# API RELATED CONFIGS
# allow password reset
@api_password_reset {
header_regexp apihost Host api\.(.*)
path /password_reset*
}
handle @api_password_reset {
redir https://www.{re.apihost.1}{uri} permanent
}
# allow activate
@api_activate {
header_regexp apihost Host api\.(.*)
path /activate*
}
handle @api_activate {
redir https://www.{re.apihost.1}{uri} permanent
}
# allow admin
@api_admin {
header Host api.*
path /admin*
}
handle @api_admin {
reverse_proxy 127.0.0.1:5001
}
# allow crossbar-api-clients
@api_client {
header Host api.*
header User-Agent crossbar-api-client
}
handle @api_client {
reverse_proxy 127.0.0.1:5001 {
fail_duration 0s
max_fails 100000
unhealthy_status 5xx
}
}
# api static assets
@api_static {
header Host api.*
path /static*
}
handle @api_static {
file_server /static/* {
root /var/www/cb/api/api/
}
}
# api media assets
@api_media {
header Host api.*
path /media*
}
handle @api_static {
file_server /media/* {
root /var/www/cb/api/api/
}
}
# send non crossbar-api-clients to 403 - must go last!
@api_the_rest {
header Host api.*
}
handle @api_the_rest {
header {
Content-Type "text/html; charset=UTF-8"
}
respond "Forbidden ē¦ę¢ć®" 403
}
@marketing_app header Host a.crossbar.org
handle @marketing_app {
reverse_proxy 127.0.0.1:5003
}
@www_app header Host crossbar.org
handle @www_app {
file_server /static/* {
root /var/www/cb/www/
}
}
handle @www_app {
reverse_proxy 127.0.0.1:5002
}
# APP RELATED CONFIGS
@app header Host www.*
# serve static files
handle @app {
file_server /static/* {
root /var/www/cb/app/
}
}
# proxy to uwsgi server and/or redirec to www
handle @app {
reverse_proxy 127.0.0.1:5000
}
# send non-www to www
@needs_www {
not header Host api.*
}
handle @needs_www {
redir https://www.{host}{uri}
}
# old domain redirects
@crossbarhq_root header Host crossbarhq.com
handle @crossbarhq_root {
redir https://crossbar.org{uri} permanent
}
@crossbarhq_www header Host www.crossbarhq.com
handle @crossbarhq_www {
redir https://crossbar.org{uri} permanent
}
tls josh.anyan@nope.org {
on_demand
dns route53 {
max_retries 10
aws_profile "default"
}
ciphers TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
}
log {
output file /tmp/caddy.log {
roll_size 100MiB
roll_keep 10
roll_keep_for 336h
}
}
}
3. The problem Iām having:
When using ZeroSSL + DNS challenge it often fails to generate a cert.
4. Error messages and/or full log output:
2021/10/04 00:18:32.803 DEBUG tls.handshake no matching certificates and no custom selection logic {"identifier": "claytonhockey.com"}
2021/10/04 00:18:32.803 DEBUG tls.handshake no matching certificates and no custom selection logic {"identifier": "*.com"}
2021/10/04 00:18:32.803 DEBUG tls.handshake no matching certificates and no custom selection logic {"identifier": "*.*"}
2021/10/04 00:18:32.862 INFO tls.on_demand obtaining new certificate {"server_name": "claytonhockey.com"}
2021/10/04 00:18:32.863 INFO tls.obtain acquiring lock {"identifier": "claytonhockey.com"}
2021/10/04 00:18:32.888 INFO tls.obtain lock acquired {"identifier": "claytonhockey.com"}
2021/10/04 00:18:33.252 DEBUG tls.obtain trying issuer 1/2 {"issuer": "acme.zerossl.com-v2-DV90"}
2021/10/04 00:18:33.252 INFO tls.issuance.acme waiting on internal rate limiter {"identifiers": ["claytonhockey.com"], "ca": "https://acme.zerossl.com/v2/DV90", "account": "josh.anyan@crossbar.org"}
2021/10/04 00:18:33.252 INFO tls.issuance.acme done waiting on internal rate limiter {"identifiers": ["claytonhockey.com"], "ca": "https://acme.zerossl.com/v2/DV90", "account": "josh.anyan@crossbar.org"}
2021/10/04 00:18:33.516 DEBUG tls.issuance.acme.acme_client http request {"method": "HEAD", "url": "https://acme.zerossl.com/v2/DV90/newNonce", "headers": {"User-Agent":["Caddy/2.4.5 CertMagic acmez (darwin; amd64)"]}, "response_headers": {"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=-1"],"Content-Type":["application/octet-stream"],"Date":["Mon, 04 Oct 2021 00:18:33 GMT"],"Link":["<https://acme.zerossl.com/v2/DV90>;rel=\"index\""],"Replay-Nonce":["ubEBj5DN-kpRAL6whc-cak7LBSpVuPggnYf3y11ifqI"],"Server":["nginx"],"Strict-Transport-Security":["max-age=15552000"]}, "status_code": 200}
2021/10/04 00:18:33.734 DEBUG tls.issuance.acme.acme_client http request {"method": "POST", "url": "https://acme.zerossl.com/v2/DV90/newOrder", "headers": {"Content-Type":["application/jose+json"],"User-Agent":["Caddy/2.4.5 CertMagic acmez (darwin; amd64)"]}, "response_headers": {"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=0, no-cache, no-store","max-age=-1"],"Content-Length":["279"],"Content-Type":["application/json"],"Date":["Mon, 04 Oct 2021 00:18:33 GMT"],"Location":["https://acme.zerossl.com/v2/DV90/order/2xsKEI-V4fsgqVS7uCBshw"],"Replay-Nonce":["4GxHoc_bjLW-D-2Rm7rQ6JJHUnSv1asOwwb_DsVFKNA"],"Server":["nginx"],"Status":[""],"Strict-Transport-Security":["max-age=15552000"]}, "status_code": 201}
2021/10/04 00:18:33.840 DEBUG tls.issuance.acme.acme_client http request {"method": "POST", "url": "https://acme.zerossl.com/v2/DV90/authz/Yh7h7t9bNfGFKSsAU797xg", "headers": {"Content-Type":["application/jose+json"],"User-Agent":["Caddy/2.4.5 CertMagic acmez (darwin; amd64)"]}, "response_headers": {"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=-1"],"Content-Length":["447"],"Content-Type":["application/json"],"Date":["Mon, 04 Oct 2021 00:18:33 GMT"],"Link":["<https://acme.zerossl.com/v2/DV90>;rel=\"index\""],"Replay-Nonce":["3Y4WgomJf6n009oZIdj0Xrw1hRcEAK_z_7JPHkgGT3A"],"Retry-After":["5"],"Server":["nginx"],"Strict-Transport-Security":["max-age=15552000"]}, "status_code": 200}
2021/10/04 00:18:33.840 DEBUG tls.issuance.acme.acme_client no solver configured {"challenge_type": "http-01"}
2021/10/04 00:18:33.840 INFO tls.issuance.acme.acme_client trying to solve challenge {"identifier": "claytonhockey.com", "challenge_type": "dns-01", "ca": "https://acme.zerossl.com/v2/DV90"}
2021/10/04 00:19:13.165 DEBUG tls.issuance.acme.acme_client http request {"method": "POST", "url": "https://acme.zerossl.com/v2/DV90/chall/gCI5gZaVLmEpOIhVGm_UsA", "headers": {"Content-Type":["application/jose+json"],"User-Agent":["Caddy/2.4.5 CertMagic acmez (darwin; amd64)"]}, "response_headers": {"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=-1"],"Content-Length":["163"],"Content-Type":["application/json"],"Date":["Mon, 04 Oct 2021 00:19:13 GMT"],"Link":["<https://acme.zerossl.com/v2/DV90>;rel=\"index\"","<https://acme.zerossl.com/v2/DV90/authz/Yh7h7t9bNfGFKSsAU797xg>;rel=\"up\""],"Replay-Nonce":["30O3m42KlBPurhyjzzFj0AvCod-01OAwC-5oDFG5VvI"],"Retry-After":["10"],"Server":["nginx"],"Strict-Transport-Security":["max-age=15552000"]}, "status_code": 200}
2021/10/04 00:19:13.166 DEBUG tls.issuance.acme.acme_client challenge accepted {"identifier": "claytonhockey.com", "challenge_type": "dns-01"}
2021/10/04 00:19:13.515 DEBUG tls.issuance.acme.acme_client http request {"method": "POST", "url": "https://acme.zerossl.com/v2/DV90/authz/Yh7h7t9bNfGFKSsAU797xg", "headers": {"Content-Type":["application/jose+json"],"User-Agent":["Caddy/2.4.5 CertMagic acmez (darwin; amd64)"]}, "response_headers": {"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=-1"],"Content-Length":["316"],"Content-Type":["application/json"],"Date":["Mon, 04 Oct 2021 00:19:13 GMT"],"Link":["<https://acme.zerossl.com/v2/DV90>;rel=\"index\""],"Replay-Nonce":["frQj5OfSJ7SDptFl_JJlxerwESaZ8agS1_CVrYvfSJQ"],"Retry-After":["5"],"Server":["nginx"],"Strict-Transport-Security":["max-age=15552000"]}, "status_code": 200}
2021/10/04 00:20:02.861 ERROR tls.issuance.acme.acme_client cleaning up solver {"identifier": "claytonhockey.com", "challenge_type": "dns-01"}
2021/10/04 00:20:02.861 INFO tls.issuance.acme.acme_client validations succeeded; finalizing order {"order": "https://acme.zerossl.com/v2/DV90/order/2xsKEI-V4fsgqVS7uCBshw"}
2021/10/04 00:20:02.862 WARN tls.issuance.acme.acme_client HTTP request failed; retrying {"url": "https://acme.zerossl.com/v2/DV90/order/2xsKEI-V4fsgqVS7uCBshw/finalize", "error": "performing request: Post \"https://acme.zerossl.com/v2/DV90/order/2xsKEI-V4fsgqVS7uCBshw/finalize\": context deadline exceeded"}
2021/10/04 00:20:02.862 ERROR tls.obtain could not get certificate from issuer {"identifier": "claytonhockey.com", "issuer": "acme.zerossl.com-v2-DV90", "error": "[claytonhockey.com] finalizing order https://acme.zerossl.com/v2/DV90/order/2xsKEI-V4fsgqVS7uCBshw: attempt 1: https://acme.zerossl.com/v2/DV90/order/2xsKEI-V4fsgqVS7uCBshw/finalize: context deadline exceeded (ca=https://acme.zerossl.com/v2/DV90)"}
2021/10/04 00:20:02.862 DEBUG tls.obtain trying issuer 2/2 {"issuer": "acme.zerossl.com-v2-DV90"}
2021/10/04 00:20:02.862 INFO tls.issuance.acme waiting on internal rate limiter {"identifiers": ["claytonhockey.com"], "ca": "https://acme.zerossl.com/v2/DV90", "account": "josh.anyan@crossbar.org"}
2021/10/04 00:20:02.862 ERROR tls.obtain could not get certificate from issuer {"identifier": "claytonhockey.com", "issuer": "acme.zerossl.com-v2-DV90", "error": "context canceled"}
2021/10/04 00:20:02.862 INFO tls.obtain releasing lock {"identifier": "claytonhockey.com"}
2021/10/04 00:20:02.863 DEBUG http.stdlib http: TLS handshake error from 127.0.0.1:50027: [claytonhockey.com] Obtain: context canceled
5. What I already tried:
Different ways of authenticating with ZeroSSL. Previously I tried email only. Iām currently using the EAB method.
Although I donāt think the way Iām authenticating with ZeroSSL is the issue, but it was something easy to try.
It almost seems like a timing or timeout issue with respect to DNS challenge. I had a similar problem with Letās Encrypt, but it would succeed maybe 90% of the time. With ZeroSSL it seems to succeed about 10% of the time. Even worse, with certain domains it seems to never succeed, no many how many times I try. The one above, claytonhockey.com, it is continually failing, but www.claytonhockey.com worked on the second try.
Iām currently trying this locally on my Mac, so the version above calls that out. Iām using the same config as production. Iām just running this manually right now sudo caddy run
but Iām worried this is going to fail in production as well.