(certs *HTTPClientCerts)
| 392 | } |
| 393 | |
| 394 | func (c *HTTPClientConfiguration) validateCACert(certs *HTTPClientCerts) (err error) { |
| 395 | if strings.TrimSpace(c.CACert) != "" { |
| 396 | caCert, err := loadPEM(c.CACert) |
| 397 | if err != nil { |
| 398 | return fmt.Errorf("failed to load CA certificate (%w)", err) |
| 399 | } |
| 400 | |
| 401 | certs.CACertPool = x509.NewCertPool() |
| 402 | if !certs.CACertPool.AppendCertsFromPEM(caCert) { |
| 403 | return fmt.Errorf("invalid CA certificate provided") |
| 404 | } |
| 405 | } else if strings.HasPrefix(c.URL, "https://") { |
| 406 | certs.CACertPool, err = x509.SystemCertPool() |
| 407 | if err != nil { |
| 408 | return fmt.Errorf( |
| 409 | "system certificate pool unusable and no explicit CA certificate was given (%w)", |
| 410 | err, |
| 411 | ) |
| 412 | } |
| 413 | } |
| 414 | return nil |
| 415 | } |
| 416 | |
| 417 | // HTTPServerConfiguration is a structure to configure the simple HTTP server by. |
| 418 | // |
no test coverage detected