MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TLSConfig

Method TLSConfig

pkg/interop/config.go:42–76  ·  view source on GitHub ↗
(
	ctx context.Context, c ClientComponent, fetcher fetch.Interface,
)

Source from the content-addressed store, hash-verified

40}
41
42func (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
78const (
79 // InteropClientConfigurationName represents the filename of interop client configuration.

Callers 1

NewClientFunction · 0.45

Calls 5

ApplyToMethod · 0.95
ApplyToMethod · 0.95
FromFetcherFunction · 0.92
GetTLSConfigMethod · 0.65
KeyServiceMethod · 0.65

Tested by

no test coverage detected