( ctx context.Context, c ClientComponent, fetcher fetch.Interface, )
| 40 | } |
| 41 | |
| 42 | func (conf tlsConfig) TLSConfig( |
| 43 | ctx context.Context, c ClientComponent, fetcher fetch.Interface, |
| 44 | ) (*tls.Config, error) { |
| 45 | res := &tls.Config{ |
| 46 | MinVersion: tls.VersionTLS12, |
| 47 | } |
| 48 | clientConfig := &tlsconfig.Client{ |
| 49 | FileReader: tlsconfig.FromFetcher(fetcher), |
| 50 | RootCA: conf.RootCA, |
| 51 | } |
| 52 | if err := clientConfig.ApplyTo(res); err != nil { |
| 53 | return nil, err |
| 54 | } |
| 55 | source := conf.Source |
| 56 | // TODO: Require explicit source for client certificate |
| 57 | // (https://github.com/TheThingsNetwork/lorawan-stack/issues/1450) |
| 58 | if source == "" && (conf.Certificate != "" || conf.Key != "") { |
| 59 | source = "file" |
| 60 | } |
| 61 | tlsConfig := c.GetTLSConfig(ctx) |
| 62 | clientAuthConfig := &tlsconfig.ClientAuth{ |
| 63 | Source: source, |
| 64 | FileReader: tlsconfig.FromFetcher(fetcher), |
| 65 | Certificate: conf.Certificate, |
| 66 | Key: conf.Key, |
| 67 | ACME: &tlsConfig.ACME, |
| 68 | KeyVault: tlsconfig.ClientKeyVault{ |
| 69 | CertificateProvider: c.KeyService(), |
| 70 | }, |
| 71 | } |
| 72 | if err := clientAuthConfig.ApplyTo(res); err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | return res, nil |
| 76 | } |
| 77 | |
| 78 | const ( |
| 79 | // InteropClientConfigurationName represents the filename of interop client configuration. |
no test coverage detected