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