Skip to content

Commit 5492bf8

Browse files
authored
Merge pull request #14 from mholt/master
Update NewConfig to return error value Thanks for this @mholt
2 parents fa07d81 + b93a974 commit 5492bf8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

caddynet/netserver/plugin.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package netserver
22

33
import (
44
"fmt"
5+
"log"
56
"strings"
67

78
"github.com/mholt/caddy"
@@ -113,7 +114,10 @@ func (n *netContext) InspectServerBlocks(sourceFile string, serverBlocks []caddy
113114

114115
// Make our caddytls.Config, which has a pointer to the
115116
// instance's certificate cache
116-
caddytlsConfig := caddytls.NewConfig(n.instance)
117+
caddytlsConfig, err := caddytls.NewConfig(n.instance)
118+
if err != nil {
119+
return serverBlocks, fmt.Errorf("creating new TLS configuration: %v", err)
120+
}
117121

118122
// Save the config to our master list, and key it for lookups
119123
c := &Config{
@@ -174,7 +178,11 @@ func GetConfig(c *caddy.Controller) *Config {
174178
// is not echo or proxy i.e port number :12017
175179
// we can't return a nil because caddytls.RegisterConfigGetter will panic
176180
// so we return a default (blank) config value
177-
caddytlsConfig := caddytls.NewConfig(ctx.instance)
181+
caddytlsConfig, err := caddytls.NewConfig(ctx.instance)
182+
if err != nil {
183+
log.Printf("[ERROR] Making new TLS configuration: %v", err)
184+
return new(Config)
185+
}
178186

179187
return &Config{TLS: caddytlsConfig}
180188
}

0 commit comments

Comments
 (0)