LoadTLSData loads TLS data from the store
(s store.Reader, contextName, endpointName string)
| 43 | |
| 44 | // LoadTLSData loads TLS data from the store |
| 45 | func LoadTLSData(s store.Reader, contextName, endpointName string) (*TLSData, error) { |
| 46 | tlsFiles, err := s.ListTLSFiles(contextName) |
| 47 | if err != nil { |
| 48 | return nil, fmt.Errorf("failed to retrieve TLS files for context %q: %w", contextName, err) |
| 49 | } |
| 50 | if epTLSFiles, ok := tlsFiles[endpointName]; ok { |
| 51 | var tlsData TLSData |
| 52 | for _, f := range epTLSFiles { |
| 53 | data, err := s.GetTLSData(contextName, endpointName, f) |
| 54 | if err != nil { |
| 55 | return nil, fmt.Errorf("failed to retrieve TLS data (%s) for context %q: %w", f, contextName, err) |
| 56 | } |
| 57 | switch f { |
| 58 | case caKey: |
| 59 | tlsData.CA = data |
| 60 | case certKey: |
| 61 | tlsData.Cert = data |
| 62 | case keyKey: |
| 63 | tlsData.Key = data |
| 64 | default: |
| 65 | logrus.Warnf("unknown file in context %s TLS bundle: %s", contextName, f) |
| 66 | } |
| 67 | } |
| 68 | return &tlsData, nil |
| 69 | } |
| 70 | return nil, nil |
| 71 | } |
| 72 | |
| 73 | // TLSDataFromFiles reads files into a TLSData struct (or returns nil if all paths are empty) |
| 74 | func TLSDataFromFiles(caPath, certPath, keyPath string) (*TLSData, error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…