MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / validateClientCert

Method validateClientCert

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

Source from the content-addressed store, hash-verified

367}
368
369func (c *HTTPClientConfiguration) validateClientCert(certs *HTTPClientCerts) error {
370 if c.ClientCert != "" && c.ClientKey == "" {
371 return newError("clientCert", "client certificate provided without client key")
372 } else if c.ClientCert == "" && c.ClientKey != "" {
373 return newError("clientKey", "client key provided without client certificate")
374 }
375
376 if c.ClientCert != "" && c.ClientKey != "" {
377 clientCert, err := loadPEM(c.ClientCert)
378 if err != nil {
379 return wrapWithMessage(err, "clientCert", "failed to load client certificate")
380 }
381 clientKey, err := loadPEM(c.ClientKey)
382 if err != nil {
383 return wrapWithMessage(err, "clientKey", "failed to load client certificate")
384 }
385 cert, err := tls.X509KeyPair(clientCert, clientKey)
386 if err != nil {
387 return wrapWithMessage(err, "clientCert", "failed to load certificate or key")
388 }
389 certs.Cert = &cert
390 }
391 return nil
392}
393
394func (c *HTTPClientConfiguration) validateCACert(certs *HTTPClientCerts) (err error) {
395 if strings.TrimSpace(c.CACert) != "" {

Callers 1

ValidateWithCertsMethod · 0.95

Calls 3

newErrorFunction · 0.85
loadPEMFunction · 0.85
wrapWithMessageFunction · 0.85

Tested by

no test coverage detected