Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 11, 01:00 UTC
| 1 | package integration |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/caddyserver/caddy/v2/caddytest" |
| 7 | ) |
| 8 | |
| 9 | func TestLeafCertLifetimeLessThanIntermediate(t *testing.T) { |
| 10 | caddytest.AssertLoadError(t, ` |
| 11 | { |
| 12 | "admin": { |
| 13 | "disabled": true |
| 14 | }, |
| 15 | "apps": { |
| 16 | "http": { |
| 17 | "servers": { |
| 18 | "srv0": { |
| 19 | "listen": [ |
| 20 | ":443" |
| 21 | ], |
| 22 | "routes": [ |
| 23 | { |
| 24 | "handle": [ |
| 25 | { |
| 26 | "handler": "subroute", |
| 27 | "routes": [ |
| 28 | { |
| 29 | "handle": [ |
| 30 | { |
| 31 | "ca": "internal", |
| 32 | "handler": "acme_server", |
| 33 | "lifetime": 604800000000000 |
| 34 | } |
| 35 | ] |
| 36 | } |
| 37 | ] |
| 38 | } |
| 39 | ] |
| 40 | } |
| 41 | ] |
| 42 | } |
| 43 | } |
| 44 | }, |
| 45 | "pki": { |
| 46 | "certificate_authorities": { |
| 47 | "internal": { |
| 48 | "install_trust": false, |
| 49 | "intermediate_lifetime": 604800000000000, |
| 50 | "name": "Internal CA" |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | `, "json", "should be less than intermediate certificate lifetime") |
| 57 | } |
| 58 | |
| 59 | func TestIntermediateLifetimeLessThanRoot(t *testing.T) { |
| 60 | caddytest.AssertLoadError(t, ` |
| 61 | { |
| 62 | "admin": { |
| 63 | "disabled": true |
| 64 | }, |
| 65 | "apps": { |
| 66 | "http": { |
| 67 | "servers": { |
| 68 | "srv0": { |
| 69 | "listen": [ |
| 70 | ":443" |
| 71 | ], |
| 72 | "routes": [ |
| 73 | { |
| 74 | "handle": [ |
| 75 | { |
| 76 | "handler": "subroute", |
| 77 | "routes": [ |
| 78 | { |
| 79 | "handle": [ |
| 80 | { |
| 81 | "ca": "internal", |
| 82 | "handler": "acme_server", |
| 83 | "lifetime": 2592000000000000 |
| 84 | } |
| 85 | ] |
| 86 | } |
| 87 | ] |
| 88 | } |
| 89 | ] |
| 90 | } |
| 91 | ] |
| 92 | } |
| 93 | } |
| 94 | }, |
| 95 | "pki": { |
| 96 | "certificate_authorities": { |
| 97 | "internal": { |
| 98 | "install_trust": false, |
| 99 | "intermediate_lifetime": 311040000000000000, |
| 100 | "name": "Internal CA" |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | `, "json", "intermediate certificate lifetime must be less than actual root certificate lifetime") |
| 107 | } |