createTLSConfig creates a TLS config. Should only be called after config.Validate().
(config config.HTTPClientConfiguration, certs *config.HTTPClientCerts)
| 44 | |
| 45 | // createTLSConfig creates a TLS config. Should only be called after config.Validate(). |
| 46 | func createTLSConfig(config config.HTTPClientConfiguration, certs *config.HTTPClientCerts) *tls.Config { |
| 47 | if !strings.HasPrefix(config.URL, "https://") { |
| 48 | return nil |
| 49 | } |
| 50 | |
| 51 | // We let users configure the minimum TLS version, so we don't need gosec here. |
| 52 | tlsConfig := &tls.Config{ //nolint:gosec |
| 53 | MinVersion: config.TLSVersion.GetTLSVersion(), |
| 54 | CurvePreferences: config.ECDHCurves.GetList(), |
| 55 | CipherSuites: config.CipherSuites.GetList(), |
| 56 | } |
| 57 | if certs.CACertPool != nil { |
| 58 | tlsConfig.RootCAs = certs.CACertPool |
| 59 | } |
| 60 | if certs.Cert != nil { |
| 61 | tlsConfig.Certificates = []tls.Certificate{*certs.Cert} |
| 62 | } |
| 63 | return tlsConfig |
| 64 | } |
no test coverage detected