Skip to content

Commit

Permalink
Expose peer certificates in round tripper response (#3110)
Browse files Browse the repository at this point in the history
  • Loading branch information
snehachhabria authored Aug 19, 2024
1 parent 4cd0ab4 commit 8f5f9d1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions conformance/utils/roundtripper/roundtripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ type RedirectRequest struct {

// CapturedResponse contains response metadata.
type CapturedResponse struct {
StatusCode int
ContentLength int64
Protocol string
Headers map[string][]string
RedirectRequest *RedirectRequest
StatusCode int
ContentLength int64
Protocol string
Headers map[string][]string
RedirectRequest *RedirectRequest
PeerCertificates []*x509.Certificate
}

// DefaultRoundTripper is the default implementation of a RoundTripper. It will
Expand Down Expand Up @@ -258,6 +259,10 @@ func (d *DefaultRoundTripper) defaultRoundTrip(request Request, transport http.R
Headers: resp.Header,
}

if resp.TLS != nil {
cRes.PeerCertificates = resp.TLS.PeerCertificates
}

if IsRedirect(resp.StatusCode) {
redirectURL, err := resp.Location()
if err != nil {
Expand Down

0 comments on commit 8f5f9d1

Please sign in to comment.