Can I use one certificate for sub and wildcard domain?

1. Caddy version (caddy version):

v2.4.1 h1:kAJ0JB5Xk5gPdTH/27S5cyoMGqD5lBAe9yZ8zTjVJa0=

2. How I run Caddy:

caddy run --config Caddyfile

a. System environment:

Ubuntu 20.04.2

b. Command:

caddy run --config Caddyfile

d. My complete Caddyfile or JSON config:

ip.buct.edu.cn {
	respond / "{remote_host} {tls_cipher} {tls_version}"
	encode zstd gzip
	tls {
		on_demand
	}
}

*.buct.edu.cn {
	encode zstd gzip
	reverse_proxy * <my_backend>
	handle_errors {
		respond "{http.error.status_code} {http.error.status_text}"
	}
	tls {
		issuer zerossl {
			dns duckdns <api_key> {
				override_domain buct.duckdns.org
			}
		}
	}
}

3. The problem I’m having:

Now, it will issues two certificates for my server, one is ip.buct.edu.cn and the other is *.buct.edu.cn, can I use one certificate to serve mutli-domain, just like issue a certificate with ip.buct.edu.cn and *.buct.edu.cn or a certificate only with *.buct.edu.cn.

4. What I already tried:

And I tried to specify the wildcard certificate path which managed by caddy with this Caddyfile,

ip.buct.edu.cn {
	respond / "{remote_host} {tls_cipher} {tls_version}"
	encode zstd gzip
	tls <path_to_wildcard_.buct.edu.cn>
}

*.buct.edu.cn {
	encode zstd gzip
	reverse_proxy * <my_backend>
	handle_errors {
		respond "{http.error.status_code} {http.error.status_text}"
	}
	tls {
		issuer zerossl {
			dns duckdns <api_key> {
				override_domain buct.duckdns.org
			}
		}
	}
}

It works, but lost certificate auto-renew function.

skipping automatic certificate management because one or more matching certificates are already loaded","domain":"ip.buct.edu.cn","server_name":"srv0"
skipping automatic certificate management because one or more matching certificates are already loaded","domain":"*.buct.edu.cn","server_name":"srv0"

You should instead use a pattern like this in your Caddyfile:

This topic was automatically closed after 30 days. New replies are no longer allowed.