ValidateWithCerts validates the client configuration and returns the loaded certificates if any.
()
| 332 | |
| 333 | // ValidateWithCerts validates the client configuration and returns the loaded certificates if any. |
| 334 | func (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 | |
| 369 | func (c *HTTPClientConfiguration) validateClientCert(certs *HTTPClientCerts) error { |
| 370 | if c.ClientCert != "" && c.ClientKey == "" { |
no test coverage detected