MCPcopy Create free account
hub / github.com/foxcpp/maddy / loadCerts

Method loadCerts

internal/tls/file.go:128–155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126}
127
128func (f *FileLoader) loadCerts() error {
129 if len(f.certPaths) != len(f.keyPaths) {
130 return errors.New("mismatch in certs and keys count")
131 }
132
133 if len(f.certPaths) == 0 {
134 return errors.New("tls.loader.file: at least one certificate required")
135 }
136
137 certs := make([]tls.Certificate, 0, len(f.certPaths))
138
139 for i := range f.certPaths {
140 certPath := f.certPaths[i]
141 keyPath := f.keyPaths[i]
142
143 cert, err := tls.LoadX509KeyPair(certPath, keyPath)
144 if err != nil {
145 return fmt.Errorf("failed to load %s and %s: %v", certPath, keyPath, err)
146 }
147 certs = append(certs, cert)
148 }
149
150 f.certsLock.Lock()
151 defer f.certsLock.Unlock()
152 f.certs = certs
153
154 return nil
155}
156
157func (f *FileLoader) ConfigureTLS(c *tls.Config) error {
158 // Loader function replaces only the whole slice.

Callers 3

ConfigureMethod · 0.95
ReloadMethod · 0.95
reloadTickerMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected