(certs *HTTPClientCerts)
| 367 | } |
| 368 | |
| 369 | func (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 | |
| 394 | func (c *HTTPClientConfiguration) validateCACert(certs *HTTPClientCerts) (err error) { |
| 395 | if strings.TrimSpace(c.CACert) != "" { |
no test coverage detected