1. The problem I’m having:
I’m trying to use a frontend instance of Caddy as an acme server and issue certificates to services on other machines in my LAN. The frontend Caddy successfully received a certificate and can serve HTTPS connections correctly to the WAN, but when the backend Caddy requests to the front end (acme server), it received an X509 certificate signed by unknown authority. A similar error pops up when curl -vL ing
2. Error messages and/or full log output:
Backend log:
gloin@gloin:~$ sudo caddy run
2023/05/14 17:46:39.114 INFO using adjacent Caddyfile
2023/05/14 17:46:39.116 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//[::1]:2019", "//127.0.0.1:2019", "//localhost:2019"]}
2023/05/14 17:46:39.117 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc00049c230"}
2023/05/14 17:46:39.117 INFO http server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "srv0", "https_port": 443}
2023/05/14 17:46:39.117 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2023/05/14 17:46:39.117 INFO http enabling HTTP/3 listener {"addr": ":443"}
2023/05/14 17:46:39.118 INFO tls cleaning storage unit {"description": "FileStorage:/root/.local/share/caddy"}
2023/05/14 17:46:39.118 INFO tls finished cleaning storage units
2023/05/14 17:46:39.118 INFO failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Receive-Buffer-Size for details.
2023/05/14 17:46:39.118 DEBUG http starting server loop {"address": "[::]:443", "tls": true, "http3": true}
2023/05/14 17:46:39.118 INFO http.log server running {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2023/05/14 17:46:39.118 DEBUG http starting server loop {"address": "[::]:80", "tls": false, "http3": false}
2023/05/14 17:46:39.118 INFO http.log server running {"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2023/05/14 17:46:39.118 INFO http enabling automatic TLS certificate management {"domains": ["gloin.dwarf"]}
2023/05/14 17:46:39.119 INFO autosaved config (load with --resume flag) {"file": "/root/.config/caddy/autosave.json"}
2023/05/14 17:46:39.119 INFO serving initial configuration
2023/05/14 17:46:39.119 INFO tls.obtain acquiring lock {"identifier": "gloin.dwarf"}
2023/05/14 17:46:39.121 INFO tls.obtain lock acquired {"identifier": "gloin.dwarf"}
2023/05/14 17:46:39.121 INFO tls.obtain obtaining certificate {"identifier": "gloin.dwarf"}
2023/05/14 17:46:39.122 DEBUG events event {"name": "cert_obtaining", "id": "9e54e296-bd86-4e99-a247-c14e81df60a7", "origin": "tls", "data": {"identifier":"gloin.dwarf"}}
2023/05/14 17:46:39.122 DEBUG tls.obtain trying issuer 1/1 {"issuer": "oin.dwarf-home-oin-.local"}
2023/05/14 17:46:39.126 WARN http.acme_client HTTP request failed; retrying {"url": "https://oin.dwarf/home/oin/.local", "error": "performing request: Get \"https://oin.dwarf/home/oin/.local\": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of \"x509: ECDSA verification failure\" while trying to verify candidate authority certificate \"Caddy Local Authority - 2023 ECC Root\")"}
2023/05/14 17:46:39.380 WARN http.acme_client HTTP request failed; retrying {"url": "https://oin.dwarf/home/oin/.local", "error": "performing request: Get \"https://oin.dwarf/home/oin/.local\": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of \"x509: ECDSA verification failure\" while trying to verify candidate authority certificate \"Caddy Local Authority - 2023 ECC Root\")"}
2023/05/14 17:46:39.635 WARN http.acme_client HTTP request failed; retrying {"url": "https://oin.dwarf/home/oin/.local", "error": "performing request: Get \"https://oin.dwarf/home/oin/.local\": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of \"x509: ECDSA verification failure\" while trying to verify candidate authority certificate \"Caddy Local Authority - 2023 ECC Root\")"}
2023/05/14 17:46:39.635 ERROR tls.obtain could not get certificate from issuer {"identifier": "gloin.dwarf", "issuer": "oin.dwarf-home-oin-.local", "error": "registering account [] with server: provisioning client: performing request: Get \"https://oin.dwarf/home/oin/.local\": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of \"x509: ECDSA verification failure\" while trying to verify candidate authority certificate \"Caddy Local Authority - 2023 ECC Root\")"}
2023/05/14 17:46:39.635 DEBUG events event {"name": "cert_failed", "id": "92c6b05b-868e-42dd-8ee7-4fad48ad9b50", "origin": "tls", "data": {"error":{},"identifier":"gloin.dwarf","issuers":["oin.dwarf-home-oin-.local"],"renewal":false}}
2023/05/14 17:46:39.635 ERROR tls.obtain will retry {"error": "[gloin.dwarf] Obtain: registering account [] with server: provisioning client: performing request: Get \"https://oin.dwarf/home/oin/.local\": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of \"x509: ECDSA verification failure\" while trying to verify candidate authority certificate \"Caddy Local Authority - 2023 ECC Root\")", "attempt": 1, "retrying_in": 60, "elapsed": 0.513861091, "max_duration": 2592000}
Frontend log
oin@oin:~$ sudo caddy run
2023/05/14 17:47:32.757 INFO using adjacent Caddyfile
2023/05/14 17:47:32.759 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2023/05/14 17:47:32.760 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc000338230"}
2023/05/14 17:47:32.760 INFO http server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "srv0", "https_port": 443}
2023/05/14 17:47:32.760 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2023/05/14 17:47:32.875 INFO tls cleaning storage unit {"description": "FileStorage:/root/.local/share/caddy"}
2023/05/14 17:47:32.875 DEBUG http starting server loop {"address": "[::]:80", "tls": false, "http3": false}
2023/05/14 17:47:32.875 INFO http.log server running {"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2023/05/14 17:47:32.875 INFO http enabling HTTP/3 listener {"addr": ":443"}
2023/05/14 17:47:32.875 INFO failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Receive-Buffer-Size for details.
2023/05/14 17:47:32.875 DEBUG http starting server loop {"address": "[::]:443", "tls": true, "http3": true}
2023/05/14 17:47:32.875 INFO http.log server running {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2023/05/14 17:47:32.875 INFO http enabling automatic TLS certificate management {"domains": ["sage.bluepine.xyz", "oin.dwarf"]}
2023/05/14 17:47:32.876 DEBUG tls loading managed certificate {"domain": "sage.bluepine.xyz", "expiration": "2023/08/12 12:19:14.000", "issuer_key": "acme-v02.api.letsencrypt.org-directory", "storage": "FileStorage:/root/.local/share/caddy"}
2023/05/14 17:47:32.876 DEBUG tls.cache added certificate to cache {"subjects": ["sage.bluepine.xyz"], "expiration": "2023/08/12 12:19:14.000", "managed": true, "issuer_key": "acme-v02.api.letsencrypt.org-directory", "hash": "71ce31498cd8c90716020c086cc7abcdd37e7fef1052aa820b0e467b25fb0204", "cache_size": 1, "cache_capacity": 10000}
2023/05/14 17:47:32.876 DEBUG events event {"name": "cached_managed_cert", "id": "647d2b9b-f76f-46b0-918a-7a62937a84d0", "origin": "tls", "data": {"sans":["sage.bluepine.xyz"]}}
2023/05/14 17:47:32.876 INFO tls finished cleaning storage units
2023/05/14 17:47:32.876 WARN tls stapling OCSP {"error": "no OCSP stapling for [oin.dwarf]: no OCSP server specified in certificate", "identifiers": ["oin.dwarf"]}
2023/05/14 17:47:32.876 DEBUG tls.cache added certificate to cache {"subjects": ["oin.dwarf"], "expiration": "2023/05/15 04:39:41.000", "managed": true, "issuer_key": "local", "hash": "46c290aad75dea3008a6ea0156574f224d70aa9f9500569b16e7ad423923bcd8", "cache_size": 2, "cache_capacity": 10000}
2023/05/14 17:47:32.876 DEBUG events event {"name": "cached_managed_cert", "id": "5ee72041-4d99-498f-af30-50b96bc8dbd4", "origin": "tls", "data": {"sans":["oin.dwarf"]}}
2023/05/14 17:47:32.888 INFO pki.ca.local root certificate is already trusted by system {"path": "storage:pki/authorities/local/root.crt"}
2023/05/14 17:47:32.888 INFO autosaved config (load with --resume flag) {"file": "/root/.config/caddy/autosave.json"}
2023/05/14 17:47:32.888 INFO serving initial configuration
2023/05/14 17:47:38.301 DEBUG events event {"name": "tls_get_certificate", "id": "4fb9c3e1-c975-4ce8-a8e1-2f1566c277cf", "origin": "tls", "data": {"client_hello":{"CipherSuites":[52393,52392,49195,49199,49196,49200,49161,49171,49162,49172,156,157,47,53,49170,10,4867,4865,4866],"ServerName":"oin.dwarf","SupportedCurves":[29,23,24,25],"SupportedPoints":"AA==","SignatureSchemes":[2052,1027,2055,2053,2054,1025,1281,1537,1283,1539,513,515],"SupportedProtos":["h2","http/1.1"],"SupportedVersions":[772,771],"Conn":{}}}}
2023/05/14 17:47:38.301 DEBUG tls.handshake choosing certificate {"identifier": "oin.dwarf", "num_choices": 1}
2023/05/14 17:47:38.301 DEBUG tls.handshake default certificate selection results {"identifier": "oin.dwarf", "subjects": ["oin.dwarf"], "managed": true, "issuer_key": "local", "hash": "46c290aad75dea3008a6ea0156574f224d70aa9f9500569b16e7ad423923bcd8"}
2023/05/14 17:47:38.301 DEBUG tls.handshake matched certificate in cache {"remote_ip": "192.168.1.119", "remote_port": "39268", "subjects": ["oin.dwarf"], "managed": true, "expiration": "2023/05/15 04:39:41.000", "hash": "46c290aad75dea3008a6ea0156574f224d70aa9f9500569b16e7ad423923bcd8"}
2023/05/14 17:47:38.303 DEBUG http.stdlib http: TLS handshake error from 192.168.1.119:39268: remote error: tls: bad certificate
2023/05/14 17:47:38.556 DEBUG events event {"name": "tls_get_certificate", "id": "31b8a1c7-8b39-4590-9455-91a2c4971412", "origin": "tls", "data": {"client_hello":{"CipherSuites":[52393,52392,49195,49199,49196,49200,49161,49171,49162,49172,156,157,47,53,49170,10,4867,4865,4866],"ServerName":"oin.dwarf","SupportedCurves":[29,23,24,25],"SupportedPoints":"AA==","SignatureSchemes":[2052,1027,2055,2053,2054,1025,1281,1537,1283,1539,513,515],"SupportedProtos":["h2","http/1.1"],"SupportedVersions":[772,771],"Conn":{}}}}
2023/05/14 17:47:38.556 DEBUG tls.handshake choosing certificate {"identifier": "oin.dwarf", "num_choices": 1}
2023/05/14 17:47:38.556 DEBUG tls.handshake default certificate selection results {"identifier": "oin.dwarf", "subjects": ["oin.dwarf"], "managed": true, "issuer_key": "local", "hash": "46c290aad75dea3008a6ea0156574f224d70aa9f9500569b16e7ad423923bcd8"}
2023/05/14 17:47:38.556 DEBUG tls.handshake matched certificate in cache {"remote_ip": "192.168.1.119", "remote_port": "39284", "subjects": ["oin.dwarf"], "managed": true, "expiration": "2023/05/15 04:39:41.000", "hash": "46c290aad75dea3008a6ea0156574f224d70aa9f9500569b16e7ad423923bcd8"}
2023/05/14 17:47:38.558 DEBUG http.stdlib http: TLS handshake error from 192.168.1.119:39284: remote error: tls: bad certificate
2023/05/14 17:47:38.811 DEBUG events event {"name": "tls_get_certificate", "id": "ff815b11-1670-4988-b265-b644cd4ad360", "origin": "tls", "data": {"client_hello":{"CipherSuites":[52393,52392,49195,49199,49196,49200,49161,49171,49162,49172,156,157,47,53,49170,10,4867,4865,4866],"ServerName":"oin.dwarf","SupportedCurves":[29,23,24,25],"SupportedPoints":"AA==","SignatureSchemes":[2052,1027,2055,2053,2054,1025,1281,1537,1283,1539,513,515],"SupportedProtos":["h2","http/1.1"],"SupportedVersions":[772,771],"Conn":{}}}}
2023/05/14 17:47:38.811 DEBUG tls.handshake choosing certificate {"identifier": "oin.dwarf", "num_choices": 1}
2023/05/14 17:47:38.811 DEBUG tls.handshake default certificate selection results {"identifier": "oin.dwarf", "subjects": ["oin.dwarf"], "managed": true, "issuer_key": "local", "hash": "46c290aad75dea3008a6ea0156574f224d70aa9f9500569b16e7ad423923bcd8"}
2023/05/14 17:47:38.811 DEBUG tls.handshake matched certificate in cache {"remote_ip": "192.168.1.119", "remote_port": "39298", "subjects": ["oin.dwarf"], "managed": true, "expiration": "2023/05/15 04:39:41.000", "hash": "46c290aad75dea3008a6ea0156574f224d70aa9f9500569b16e7ad423923bcd8"}
2023/05/14 17:47:38.812 DEBUG http.stdlib http: TLS handshake error from 192.168.1.119:39298: remote error: tls: bad certificate
3. Caddy version:
Front and backend running v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
4. How I installed and ran Caddy:
a. System environment:
Front- and back-end both installed on (separate) Ubuntu 21.04 VMs
b. Command:
sudo caddy run
c. Service/unit/compose file:
NAT and rules set up so WAN port 443 directs to 192.168.1.118
DNS resolving provided by PfSense:
oin.dwarf directs to 192.168.1.118
gloin.dwarf directs to 192.168.1.119
d. My complete Caddy config:
Frontend Caddyfile:
{
debug
}
oin.dwarf {
acme_server
tls internal
}
sage.bluepine.xyz {
reverse_proxy /test
respond "this page is served correctly over HTTPS"
reverse_proxy /media https://gloin.dwarf {
header_up Host {upstream_hostport}
}
}
Backend Caddyfile
{
debug
acme_ca https://oin.dwarf/home/oin/.local
acme_ca_root /etc/ssl/certs/root.crt
}
gloin.dwarf {
encode gzip
uri replace /media /web/
reverse_proxy /web/* :32400
}
5. Links to relevant resources:
Followed this guide as close as I could: Use Caddy for local HTTPS (TLS) between front-end reverse proxy and LAN hosts
I’ve been searching duckduckgo and these forums for most of two days trying to figure this out but still can’t figure it out.
Is my problem related to the acme_ca_root directory being incorrect? Or that the certificate was generated for sage.bluepine.xyz, but now oin.dwarf is trying to serve as the acme server?
It seems like gloin is trying to grab the new certificate but can’t because it has to be transferred with TLS, but TLS fails because there’s no certificate…I know I’m not understanding some part. Thank in advance