-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
acme_server: Configurable default lifetime for issued certificates (#…
…5232) * acme_server: add certificate lifetime configuration option Signed-off-by: Kyle McCullough <kylemcc@gmail.com> * pki: allow intermediate cert lifetime to be configured Signed-off-by: Kyle McCullough <kylemcc@gmail.com> Signed-off-by: Kyle McCullough <kylemcc@gmail.com>
- Loading branch information
Showing
8 changed files
with
268 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
caddytest/integration/caddyfile_adapt/acme_server_lifetime.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
pki { | ||
ca internal { | ||
name "Internal" | ||
root_cn "Internal Root Cert" | ||
intermediate_cn "Internal Intermediate Cert" | ||
} | ||
ca internal-long-lived { | ||
name "Long-lived" | ||
root_cn "Internal Root Cert 2" | ||
intermediate_cn "Internal Intermediate Cert 2" | ||
} | ||
} | ||
} | ||
|
||
acme-internal.example.com { | ||
acme_server { | ||
ca internal | ||
} | ||
} | ||
|
||
acme-long-lived.example.com { | ||
acme_server { | ||
ca internal-long-lived | ||
lifetime 7d | ||
} | ||
} | ||
---------- | ||
{ | ||
"apps": { | ||
"http": { | ||
"servers": { | ||
"srv0": { | ||
"listen": [ | ||
":443" | ||
], | ||
"routes": [ | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"acme-long-lived.example.com" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"ca": "internal-long-lived", | ||
"handler": "acme_server", | ||
"lifetime": 604800000000000 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
}, | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"acme-internal.example.com" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"ca": "internal", | ||
"handler": "acme_server" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"pki": { | ||
"certificate_authorities": { | ||
"internal": { | ||
"name": "Internal", | ||
"root_common_name": "Internal Root Cert", | ||
"intermediate_common_name": "Internal Intermediate Cert" | ||
}, | ||
"internal-long-lived": { | ||
"name": "Long-lived", | ||
"root_common_name": "Internal Root Cert 2", | ||
"intermediate_common_name": "Internal Intermediate Cert 2" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,4 +165,4 @@ acme-bar.example.com { | |
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package integration | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/caddyserver/caddy/v2/caddytest" | ||
) | ||
|
||
func TestLeafCertLifetimeLessThanIntermediate(t *testing.T) { | ||
caddytest.AssertLoadError(t, ` | ||
{ | ||
"apps": { | ||
"http": { | ||
"servers": { | ||
"srv0": { | ||
"listen": [ | ||
":443" | ||
], | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"ca": "internal", | ||
"handler": "acme_server", | ||
"lifetime": 604800000000000 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"pki": { | ||
"certificate_authorities": { | ||
"internal": { | ||
"install_trust": false, | ||
"intermediate_lifetime": 604800000000000, | ||
"name": "Internal CA" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, "json", "certificate lifetime (168h0m0s) should be less than intermediate certificate lifetime (168h0m0s)") | ||
} | ||
|
||
func TestIntermediateLifetimeLessThanRoot(t *testing.T) { | ||
caddytest.AssertLoadError(t, ` | ||
{ | ||
"apps": { | ||
"http": { | ||
"servers": { | ||
"srv0": { | ||
"listen": [ | ||
":443" | ||
], | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"ca": "internal", | ||
"handler": "acme_server", | ||
"lifetime": 2592000000000000 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"pki": { | ||
"certificate_authorities": { | ||
"internal": { | ||
"install_trust": false, | ||
"intermediate_lifetime": 311040000000000000, | ||
"name": "Internal CA" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, "json", "intermediate certificate lifetime must be less than root certificate lifetime (86400h0m0s)") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters