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)
| 52 | // The returned value is *tls.Config with GetConfigForClient set. |
| 53 | // If the 'tls off' is used, returned value is nil. |
| 54 | func 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 | |
| 71 | func readTLSBlock(globals map[string]interface{}, blockNode config.Node) (*TLSConfig, error) { |
| 72 | baseCfg := tls.Config{ |
nothing calls this directly
no test coverage detected