@marcel91200 / caddy Mirror · read-only / commits / 5d3ccf1e
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

httpcaddyfile: Get rid of 'tls off' parameter; probably not useful

Matthew Holt committed Jan 22, 2020 at 09:24 UTC 5d3ccf1eb79c47c1da37836b60903f26693b8018
1 file changed +17 -12
caddyconfig/httpcaddyfile/builtins.go
+17 -12
@@ -20,6 +20,7 @@ import (
20 "html"
21 "net/http"
22 "reflect"
23 + "strings"
24
25 "github.com/caddyserver/caddy/v2"
26 "github.com/caddyserver/caddy/v2/caddyconfig"
@@ -80,6 +81,17 @@ func parseRoot(h Helper) ([]ConfigValue, error) {
81 return []ConfigValue{{Class: "route", Value: route}}, nil
82 }
83
84 +// parseTLS parses the tls directive. Syntax:
85 +//
86 +// tls [<email>]|[<cert_file> <key_file>] {
87 +// protocols <min> [<max>]
88 +// ciphers <cipher_suites...>
89 +// curves <curves...>
90 +// alpn <values...>
91 +// load <paths...>
92 +// ca <acme_ca_endpoint>
93 +// }
94 +//
95 func parseTLS(h Helper) ([]ConfigValue, error) {
96 var configVals []ConfigValue
97
@@ -87,7 +99,6 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
99 var fileLoader caddytls.FileLoader
100 var folderLoader caddytls.FolderLoader
101 var mgr caddytls.ACMEManagerMaker
90 - var off bool
102
103 // fill in global defaults, if configured
104 if email := h.Option("email"); email != nil {
@@ -103,16 +114,15 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
114 switch len(firstLine) {
115 case 0:
116 case 1:
106 - if firstLine[0] == "off" {
107 - off = true
108 - } else {
109 - mgr.Email = firstLine[0]
117 + if !strings.Contains(firstLine[0], "@") {
118 + return nil, h.Err("single argument must be an email address")
119 }
120 + mgr.Email = firstLine[0]
121 case 2:
122 fileLoader = append(fileLoader, caddytls.CertKeyFilePair{
123 Certificate: firstLine[0],
124 Key: firstLine[1],
115 - // TODO: add tags, for enterprise module's certificate selection
125 + // TODO: add tags, to ensure this certificate is always used for this server name
126 })
127 default:
128 return nil, h.ArgErr()
@@ -231,12 +241,7 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
241 }
242
243 // automation policy
234 - if off {
235 - configVals = append(configVals, ConfigValue{
236 - Class: "tls.off",
237 - Value: true,
238 - })
239 - } else if !reflect.DeepEqual(mgr, caddytls.ACMEManagerMaker{}) {
244 + if !reflect.DeepEqual(mgr, caddytls.ACMEManagerMaker{}) {
245 configVals = append(configVals, ConfigValue{
246 Class: "tls.automation_manager",
247 Value: mgr,