1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- //nolint:goconst
1615package client
1716
1817import (
@@ -40,6 +39,11 @@ import (
4039 "github.com/opentracing/opentracing-go"
4140)
4241
42+ const (
43+ schemeHTTP = "http"
44+ schemeHTTPS = "https"
45+ )
46+
4347// TLSClientOptions to configure client authentication with mutual TLS
4448type TLSClientOptions struct {
4549 // Certificate is the path to a PEM-encoded certificate to be used for
@@ -112,7 +116,9 @@ type TLSClientOptions struct {
112116// TLSClientAuth creates a tls.Config for mutual auth
113117func TLSClientAuth (opts TLSClientOptions ) (* tls.Config , error ) {
114118 // create client tls config
115- cfg := & tls.Config {} //nolint:gosec
119+ cfg := & tls.Config {
120+ MinVersion : tls .VersionTLS12 ,
121+ }
116122
117123 // load client cert if specified
118124 if opts .Certificate != "" {
@@ -158,11 +164,12 @@ func TLSClientAuth(opts TLSClientOptions) (*tls.Config, error) {
158164 // When no CA certificate is provided, default to the system cert pool
159165 // that way when a request is made to a server known by the system trust store,
160166 // the name is still verified
161- if opts .LoadedCA != nil { //nolint:gocritic
167+ switch {
168+ case opts .LoadedCA != nil :
162169 caCertPool := basePool (opts .LoadedCAPool )
163170 caCertPool .AddCert (opts .LoadedCA )
164171 cfg .RootCAs = caCertPool
165- } else if opts .CA != "" {
172+ case opts .CA != "" :
166173 // load ca cert
167174 caCert , err := os .ReadFile (opts .CA )
168175 if err != nil {
@@ -171,7 +178,7 @@ func TLSClientAuth(opts TLSClientOptions) (*tls.Config, error) {
171178 caCertPool := basePool (opts .LoadedCAPool )
172179 caCertPool .AppendCertsFromPEM (caCert )
173180 cfg .RootCAs = caCertPool
174- } else if opts .LoadedCAPool != nil {
181+ case opts .LoadedCAPool != nil :
175182 cfg .RootCAs = opts .LoadedCAPool
176183 }
177184
@@ -227,7 +234,7 @@ type Runtime struct {
227234 Host string
228235 BasePath string
229236 Formats strfmt.Registry
230- Context context.Context //nolint:containedctx
237+ Context context.Context //nolint:containedctx // we precisely want this type to contain the request context
231238
232239 Debug bool
233240 logger logger.Logger
@@ -316,7 +323,7 @@ func (r *Runtime) pickScheme(schemes []string) string {
316323 if v := r .selectScheme (schemes ); v != "" {
317324 return v
318325 }
319- return "http"
326+ return schemeHTTP
320327}
321328
322329func (r * Runtime ) selectScheme (schemes []string ) string {
@@ -327,9 +334,9 @@ func (r *Runtime) selectScheme(schemes []string) string {
327334
328335 scheme := schemes [0 ]
329336 // prefer https, but skip when not possible
330- if scheme != "https" && schLen > 1 {
337+ if scheme != schemeHTTPS && schLen > 1 {
331338 for _ , sch := range schemes {
332- if sch == "https" {
339+ if sch == schemeHTTPS {
333340 scheme = sch
334341 break
335342 }
0 commit comments