2015-05-05 01:04:17 +08:00
|
|
|
package setup
|
|
|
|
|
2015-05-06 03:30:24 +08:00
|
|
|
import (
|
|
|
|
"github.com/mholt/caddy/middleware"
|
|
|
|
"log"
|
|
|
|
)
|
2015-05-05 01:04:17 +08:00
|
|
|
|
|
|
|
func TLS(c *Controller) (middleware.Middleware, error) {
|
2015-05-06 03:30:24 +08:00
|
|
|
c.TLS.Enabled = true
|
|
|
|
if c.Port == "http" {
|
|
|
|
c.TLS.Enabled = false
|
|
|
|
log.Printf("Warning: TLS was disabled on host http://%s."+
|
|
|
|
" Make sure you are specifying https://%s in your config (if you haven't already)."+
|
|
|
|
" If you meant to serve tls on port 80,"+
|
|
|
|
" specify port 80 in your config (http://%s:80).", c.Host, c.Host, c.Host)
|
|
|
|
}
|
2015-05-05 01:04:17 +08:00
|
|
|
|
|
|
|
for c.Next() {
|
|
|
|
if !c.NextArg() {
|
|
|
|
return nil, c.ArgErr()
|
|
|
|
}
|
|
|
|
c.TLS.Certificate = c.Val()
|
|
|
|
|
|
|
|
if !c.NextArg() {
|
|
|
|
return nil, c.ArgErr()
|
|
|
|
}
|
|
|
|
c.TLS.Key = c.Val()
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|