MCPcopy Index your code
hub / github.com/foxcpp/maddy / TLSDirective

Function TLSDirective

framework/config/tls/server.go:54–69  ·  view source on GitHub ↗

TLSDirective reads the TLS configuration and adds the reload handler to reread certificates on SIGUSR2. The returned value is *tls.Config with GetConfigForClient set. If the 'tls off' is used, returned value is nil.

(m *config.Map, node config.Node)

Source from the content-addressed store, hash-verified

52// The returned value is *tls.Config with GetConfigForClient set.
53// If the 'tls off' is used, returned value is nil.
54func TLSDirective(m *config.Map, node config.Node) (interface{}, error) {
55 cfg, err := readTLSBlock(m.Globals, node)
56 if err != nil {
57 return nil, err
58 }
59
60 if cfg == nil {
61 return nil, nil
62 }
63
64 return &tls.Config{
65 GetConfigForClient: func(hello *tls.ClientHelloInfo) (*tls.Config, error) {
66 return cfg.Get()
67 },
68 }, nil
69}
70
71func readTLSBlock(globals map[string]interface{}, blockNode config.Node) (*TLSConfig, error) {
72 baseCfg := tls.Config{

Callers

nothing calls this directly

Calls 2

readTLSBlockFunction · 0.85
GetMethod · 0.45

Tested by

no test coverage detected