1. My Caddy version (caddy version
):
v2.0.0-beta.14 h1:QX1hRMfTA5sel53o5SuON1ys50at6yuSAnPr56sLeK8=
Built with a tls.dns.cloudflare
module (see this post):
$ caddy list-modules | grep "tls"
tls
tls.certificate_selection.custom
tls.certificates.automate
tls.certificates.load_files
tls.certificates.load_folders
tls.certificates.load_pem
tls.dns.cloudflare
tls.handshake_match.sni
tls.management.acme
tls.stek.distributed
tls.stek.standard
2. How I run Caddy:
a. System environment:
- Ubuntu 18.04.4 (kernel:
4.15.0-1060-aws
) - systemd 237
b. Command:
After copying all config files and creating caddy user/group:
sudo systemctl daemon-reload
sudo systemctl enable caddy
sudo systemctl start caddy
c. Service/unit/compose file:
Vanilla systemd config for Caddy:
[Unit]
Description=Caddy Web Server
Documentation=https://caddyserver.com/docs/
After=network.target
[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --config /etc/caddy/caddy.json --resume --environ
ExecReload=/usr/bin/caddy reload --config /etc/caddy/caddy.json
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddyfile or JSON config:
{
"apps": {
"tls": {
"automation": {
"policies": [{
"management": {
"module": "acme",
"email": "MY CLOUDFLARE EMAIL",
"challenges": {
"dns": {
"provider": "cloudflare",
"api_token": "MY API TOKEN"
}
}
}
}]
}
},
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"*.jmstfv.com",
"status.tryhexadecimal.com"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"encodings": {
"gzip": {},
"zstd": {}
},
"handler": "encode"
},
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.request.host}"
],
"X-Forwarded-For": [
"{http.request.remote.host}"
],
"X-Forwarded-Port": [
"{server_port}"
],
"X-Forwarded-Proto": [
"{http.request.scheme}"
],
"X-Real-Ip": [
"{http.request.remote.host}"
]
}
}
},
"upstreams": [
{
"dial": "0.0.0.0:3000"
}
]
}
]
}
]
}
],
"terminal": true
}
]
}
}
}
}
}
3. The problem I’m having:
I can’t obtain a certificate for status.tryhexadecimal.com
. My guess:
- incorrect permissions on the Cloudflare API token (see below)
- misconfiguration of DNS records (see below)
Wildcard certificate for *.jmstfv.com
works fine.
4. Error messages and/or full log output:
2020/02/25 08:29:21 [INFO][status.tryhexadecimal.com] Obtain certificate
2020/02/25 08:29:21 [INFO][status.tryhexadecimal.com] Obtain: Waiting on rate limiter...
2020/02/25 08:29:21 [INFO][status.tryhexadecimal.com] Obtain: Done waiting
2020/02/25 08:29:21 [INFO] [status.tryhexadecimal.com] acme: Obtaining bundled SAN certificate
2020/02/25 08:29:21 [INFO] nonce error retry: acme: error: 400 :: POST :: https://acme-v02.api.letsencrypt.org/acme/new-order :: urn:ietf:params:acme:error:badNonce :: JWS has an invalid anti-replay nonce: "00021MzqJMAx36hZQ5FTBnaK1IVkSodW-GqWcMiOxF-8rLI", url:
2020/02/25 08:29:22 [INFO] [status.tryhexadecimal.com] AuthURL: https://acme-v02.api.letsencrypt.org/acme/authz-v3/3001949923
2020/02/25 08:29:22 [INFO] [status.tryhexadecimal.com] acme: Could not find solver for: tls-alpn-01
2020/02/25 08:29:22 [INFO] [status.tryhexadecimal.com] acme: Could not find solver for: http-01
2020/02/25 08:29:22 [INFO] [status.tryhexadecimal.com] acme: use dns-01 solver
2020/02/25 08:29:22 [INFO] [status.tryhexadecimal.com] acme: Preparing to solve DNS-01
2020/02/25 08:29:22 [INFO] [status.tryhexadecimal.com] acme: Cleaning DNS-01 challenge
2020/02/25 08:29:22 [WARN] [status.tryhexadecimal.com] acme: error cleaning up: cloudflare: failed to find zone tryhexadecimal.com.: ListZonesContext command failed: error from makeRequest: HTTP status 403: insufficient permissions
2020/02/25 08:29:22 [INFO] Deactivating auth: https://acme-v02.api.letsencrypt.org/acme/authz-v3/3001949923
2020/02/25 08:29:22 [ERROR][status.tryhexadecimal.com] failed to obtain certificate: acme: Error -> One or more domains had a problem:
[status.tryhexadecimal.com] [status.tryhexadecimal.com] acme: error presenting token: cloudflare: failed to find zone tryhexadecimal.com.: ListZonesContext command failed: error from makeRequest: HTTP status 403: insufficient permissions (attempt 1/2; challenge=dns-01)
2020/02/25 08:29:23 [INFO] [status.tryhexadecimal.com] acme: Obtaining bundled SAN certificate
2020/02/25 08:29:24 [INFO] [status.tryhexadecimal.com] AuthURL: https://acme-v02.api.letsencrypt.org/acme/authz-v3/3001950343
2020/02/25 08:29:24 [INFO] [status.tryhexadecimal.com] acme: Could not find solver for: tls-alpn-01
2020/02/25 08:29:24 [INFO] [status.tryhexadecimal.com] acme: Could not find solver for: http-01
2020/02/25 08:29:24 [INFO] [status.tryhexadecimal.com] acme: use dns-01 solver
2020/02/25 08:29:24 [INFO] [status.tryhexadecimal.com] acme: Preparing to solve DNS-01
2020/02/25 08:29:24 [INFO] [status.tryhexadecimal.com] acme: Cleaning DNS-01 challenge
2020/02/25 08:29:24 [WARN] [status.tryhexadecimal.com] acme: error cleaning up: cloudflare: failed to find zone tryhexadecimal.com.: ListZonesContext command failed: error from makeRequest: HTTP status 403: insufficient permissions
2020/02/25 08:29:24 [INFO] Deactivating auth: https://acme-v02.api.letsencrypt.org/acme/authz-v3/3001950343
2020/02/25 08:29:24 [ERROR][status.tryhexadecimal.com] failed to obtain certificate: acme: Error -> One or more domains had a problem:
[status.tryhexadecimal.com] [status.tryhexadecimal.com] acme: error presenting token: cloudflare: failed to find zone tryhexadecimal.com.: ListZonesContext command failed: error from makeRequest: HTTP status 403: insufficient permissions (attempt 2/2; challenge=dns-01)
2020/02/25 08:29:25 [ERROR] status.tryhexadecimal.com: obtaining certificate: failed to obtain certificate: acme: Error -> One or more domains had a problem:
[status.tryhexadecimal.com] [status.tryhexadecimal.com] acme: error presenting token: cloudflare: failed to find zone tryhexadecimal.com.: ListZonesContext command failed: error from makeRequest: HTTP status 403: insufficient permissions - backing off and retrying (attempt 9/46)...
Sending a request to status.tryhexadecimal.com
using curl:
$ curl -v https://status.tryhexadecimal.com
[...]
curl: (35) error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error
Caddy logs:
http: TLS handshake error from [IP:Port]: no certificate available for 'status.tryhexadecimal.com'
5. What I already tried:
DNS A record for jmstfv.com
(wildcard DNS record):
$ nslookup *.jmstfv.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: *.jmstfv.com
Address: 34.229.26.68
DNS CNAME record for status.tryhexadecimal.com
(note: there isn’t a separate DNS record for domains.jmstfv.com
, it resolves to *.jmstfv.com
):
$ nslookup status.tryhexadecimal.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
status.tryhexadecimal.com canonical name = domains.jmstfv.com.
Name: domains.jmstfv.com
Address: 34.229.26.68
DNS CAA record for tryhexadecimal.com
:
$ dig tryhexadecimal.com type257 +short
0 issuewild "comodoca.com"
0 issuewild "digicert.com"
0 issuewild "letsencrypt.org"
0 issue "comodoca.com"
0 issue "digicert.com"
0 issue "letsencrypt.org"
DNS CAA record for status.tryhexadecimal.com
:
$ dig status.tryhexadecimal.com type257 +short
domains.jmstfv.com.
Permissions on the Cloudflare token (API token belongs to the jmstfv.com
account):
Zone / Zone / Read
Zone / DNS / Edit
Tried adding Zone / Zone Settings / Edit
to no avail. Also tried setting above permissions to Edit
but that didn’t work either.
6. Links to relevant resources:
Similar error messages (for traefik):