()
| 126 | } |
| 127 | |
| 128 | func (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 | |
| 157 | func (f *FileLoader) ConfigureTLS(c *tls.Config) error { |
| 158 | // Loader function replaces only the whole slice. |
no outgoing calls
no test coverage detected