Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ca/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (c *uaClient) SetTransport(tr http.RoundTripper) {
c.Client.Transport = tr
}

func (c *uaClient) CloseIdleConnections() {
c.Client.CloseIdleConnections()
}

func (c *uaClient) Get(u string) (*http.Response, error) {
return c.GetWithContext(context.Background(), u)
}
Expand Down Expand Up @@ -639,6 +643,13 @@ func (c *Client) SetTransport(tr http.RoundTripper) {
c.client.SetTransport(tr)
}

// CloseIdleConnections closes any connections on its Transport which were
// previously connected from previous requests but are now sitting idle in a
// "keep-alive" state. It does not interrupt any connections currently in use.
func (c *Client) CloseIdleConnections() {
c.client.CloseIdleConnections()
}

// Version performs the version request to the CA with an empty context and returns the
// api.VersionResponse struct.
func (c *Client) Version() (*api.VersionResponse, error) {
Expand Down
3 changes: 3 additions & 0 deletions ca/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ func getPEM(i interface{}) ([]byte, error) {

func getRenewFunc(ctx *TLSOptionCtx, client *Client, tr *http.Transport, pk crypto.PrivateKey) RenewFunc {
return func() (*tls.Certificate, error) {
// Close connections in keep-alive state
defer client.CloseIdleConnections()

// Get updated list of roots
if err := ctx.applyRenew(); err != nil {
return nil, err
Expand Down