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

Method validateCACert

config/http.go:394–415  ·  view source on GitHub ↗
(certs *HTTPClientCerts)

Source from the content-addressed store, hash-verified

392}
393
394func (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//

Callers 1

ValidateWithCertsMethod · 0.95

Calls 2

loadPEMFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected