MCPcopy Index your code
hub / github.com/ContainerSSH/ContainerSSH / ValidateWithCerts

Method ValidateWithCerts

config/http.go:334–367  ·  view source on GitHub ↗

ValidateWithCerts validates the client configuration and returns the loaded certificates if any.

()

Source from the content-addressed store, hash-verified

332
333// ValidateWithCerts validates the client configuration and returns the loaded certificates if any.
334func (c *HTTPClientConfiguration) ValidateWithCerts() (*HTTPClientCerts, error) {
335 result := &HTTPClientCerts{}
336
337 _, err := url.ParseRequestURI(c.URL)
338 if err != nil {
339 return nil, newError("url", "invalid URL: %s", c.URL)
340 }
341 if c.Timeout < 100*time.Millisecond {
342 return nil, newError("timeout", "timeout value %s is too low, must be at least 100ms", c.Timeout.String())
343 }
344
345 if err := c.validateCACert(result); err != nil {
346 return nil, wrap(err, "cacert")
347 }
348
349 if err := c.RequestEncoding.Validate(); err != nil {
350 return nil, err
351 }
352
353 if strings.HasPrefix(c.URL, "https://") {
354 if err := c.TLSVersion.Validate(); err != nil {
355 return nil, wrap(err, "tlsVersion")
356 }
357 if err := c.ECDHCurves.Validate(); err != nil {
358 return nil, wrap(err, "curves")
359 }
360 if err := c.CipherSuites.Validate(); err != nil {
361 return nil, wrap(err, "cipher")
362 }
363 }
364
365 err = c.validateClientCert(result)
366 return result, err
367}
368
369func (c *HTTPClientConfiguration) validateClientCert(certs *HTTPClientCerts) error {
370 if c.ClientCert != "" && c.ClientKey == "" {

Callers 3

ValidateMethod · 0.95
NewClientWithHeadersFunction · 0.45
NewServerFunction · 0.45

Calls 6

validateCACertMethod · 0.95
validateClientCertMethod · 0.95
newErrorFunction · 0.85
wrapFunction · 0.85
StringMethod · 0.65
ValidateMethod · 0.65

Tested by

no test coverage detected