summaryrefslogtreecommitdiff
path: root/caddytest
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2021-06-25 11:28:32 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2021-06-25 11:28:32 -0600
commitb3d35a4995c98cfadeb0c3a356025dbd3984caef (patch)
tree5bffe5ab50efa2f3a18f912b102ace7bced34989 /caddytest
parent2de7e14e1c5fcc8c846b341583597ab65eaf7156 (diff)
httpcaddyfile: Don't put localhost in public APs (fix #4220)
If an email is specified in global options, a site called 'localhost' shouldn't be bunched together with public DNS names in the automation policies, which get the default, public-CA issuers. Fix old test that did this. I also noticed that these two: localhost { } example.com { } and localhost, example.com { } produce slightly different TLS automation policies. The former is what the new test case covers, and we have logic that removes the empty automation policy for localhost so that auto-HTTPS can implicitly create one. (We prefer that whenever possible.) But the latter case produces two automation policies, with the second one being for localhost, with an explicit internal issuer. It's not wrong, just more explicit than it needs to be. I'd really like to completely rewrite the code from scratch that generates automation policies, hopefully there is a simpler, more correct algorithm.
Diffstat (limited to 'caddytest')
-rw-r--r--caddytest/integration/caddyfile_adapt/global_options_preferred_chains.txt6
-rw-r--r--caddytest/integration/caddyfile_adapt/tls_automation_policies_global_email_localhost.txt66
2 files changed, 69 insertions, 3 deletions
diff --git a/caddytest/integration/caddyfile_adapt/global_options_preferred_chains.txt b/caddytest/integration/caddyfile_adapt/global_options_preferred_chains.txt
index 893b34b..9173b26 100644
--- a/caddytest/integration/caddyfile_adapt/global_options_preferred_chains.txt
+++ b/caddytest/integration/caddyfile_adapt/global_options_preferred_chains.txt
@@ -2,7 +2,7 @@
preferred_chains smallest
}
-localhost
+example.com
----------
{
"apps": {
@@ -17,7 +17,7 @@ localhost
"match": [
{
"host": [
- "localhost"
+ "example.com"
]
}
],
@@ -32,7 +32,7 @@ localhost
"policies": [
{
"subjects": [
- "localhost"
+ "example.com"
],
"issuers": [
{
diff --git a/caddytest/integration/caddyfile_adapt/tls_automation_policies_global_email_localhost.txt b/caddytest/integration/caddyfile_adapt/tls_automation_policies_global_email_localhost.txt
new file mode 100644
index 0000000..e8ef3a7
--- /dev/null
+++ b/caddytest/integration/caddyfile_adapt/tls_automation_policies_global_email_localhost.txt
@@ -0,0 +1,66 @@
+{
+ email foo@bar
+}
+
+localhost {
+}
+
+example.com {
+}
+----------
+{
+ "apps": {
+ "http": {
+ "servers": {
+ "srv0": {
+ "listen": [
+ ":443"
+ ],
+ "routes": [
+ {
+ "match": [
+ {
+ "host": [
+ "example.com"
+ ]
+ }
+ ],
+ "terminal": true
+ },
+ {
+ "match": [
+ {
+ "host": [
+ "localhost"
+ ]
+ }
+ ],
+ "terminal": true
+ }
+ ]
+ }
+ }
+ },
+ "tls": {
+ "automation": {
+ "policies": [
+ {
+ "subjects": [
+ "example.com"
+ ],
+ "issuers": [
+ {
+ "email": "foo@bar",
+ "module": "acme"
+ },
+ {
+ "email": "foo@bar",
+ "module": "zerossl"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+} \ No newline at end of file