(ctx context.Context)
| 1530 | } |
| 1531 | |
| 1532 | func (t *tlsRoundTripper) getTLSDataWithHash(ctx context.Context) ([]byte, []byte, []byte, []byte, error) { |
| 1533 | var caBytes, certBytes, keyBytes []byte |
| 1534 | |
| 1535 | if t.settings.CA != nil { |
| 1536 | ca, err := t.settings.CA.Fetch(ctx) |
| 1537 | if err != nil { |
| 1538 | return nil, nil, nil, nil, fmt.Errorf("unable to read CA cert: %w", err) |
| 1539 | } |
| 1540 | caBytes = []byte(ca) |
| 1541 | } |
| 1542 | |
| 1543 | if t.settings.Cert != nil { |
| 1544 | cert, err := t.settings.Cert.Fetch(ctx) |
| 1545 | if err != nil { |
| 1546 | return nil, nil, nil, nil, fmt.Errorf("unable to read client cert: %w", err) |
| 1547 | } |
| 1548 | certBytes = []byte(cert) |
| 1549 | } |
| 1550 | |
| 1551 | if t.settings.Key != nil { |
| 1552 | key, err := t.settings.Key.Fetch(ctx) |
| 1553 | if err != nil { |
| 1554 | return nil, nil, nil, nil, fmt.Errorf("unable to read client key: %w", err) |
| 1555 | } |
| 1556 | keyBytes = []byte(key) |
| 1557 | } |
| 1558 | |
| 1559 | var caHash, certHash, keyHash [32]byte |
| 1560 | |
| 1561 | if len(caBytes) > 0 { |
| 1562 | caHash = sha256.Sum256(caBytes) |
| 1563 | } |
| 1564 | if len(certBytes) > 0 { |
| 1565 | certHash = sha256.Sum256(certBytes) |
| 1566 | } |
| 1567 | if len(keyBytes) > 0 { |
| 1568 | keyHash = sha256.Sum256(keyBytes) |
| 1569 | } |
| 1570 | |
| 1571 | return caBytes, caHash[:], certHash[:], keyHash[:], nil |
| 1572 | } |
| 1573 | |
| 1574 | // RoundTrip implements the http.RoundTrip interface. |
| 1575 | func (t *tlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { |
no test coverage detected