Parcourir la source

Merge branch 'master' into master

Mariano Cano il y a 11 mois
Parent
commit
f1a8a1076d
5 fichiers modifiés avec 22 ajouts et 6 suppressions
  1. 5 3
      .version.sh
  2. 11 0
      ca/client.go
  3. 3 0
      ca/tls.go
  4. 1 1
      go.mod
  5. 2 2
      go.sum

+ 5 - 3
.version.sh

@@ -1,7 +1,9 @@
 #!/usr/bin/env sh
 read -r firstline < .VERSION
 last_half="${firstline##*tag: }"
-if [[ ${last_half::1} == "v" ]]; then
-    version_string="${last_half%%[,)]*}"
-fi
+case "$last_half" in
+    v*)
+        version_string="${last_half%%[,)]*}"
+        ;;
+esac
 echo "${version_string:-v0.0.0}"

+ 11 - 0
ca/client.go

@@ -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)
 }
@@ -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) {

+ 3 - 0
ca/tls.go

@@ -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

+ 1 - 1
go.mod

@@ -15,7 +15,7 @@ require (
 	github.com/go-chi/chi/v5 v5.2.3
 	github.com/go-jose/go-jose/v3 v3.0.4
 	github.com/google/go-cmp v0.7.0
-	github.com/google/go-tpm v0.9.7
+	github.com/google/go-tpm v0.9.8
 	github.com/google/uuid v1.6.0
 	github.com/googleapis/gax-go/v2 v2.16.0
 	github.com/hashicorp/vault/api v1.22.0

+ 2 - 2
go.sum

@@ -192,8 +192,8 @@ github.com/google/go-sev-guest v0.14.0 h1:dCb4F3YrHTtrDX3cYIPTifEDz7XagZmXQioxRB
 github.com/google/go-sev-guest v0.14.0/go.mod h1:SK9vW+uyfuzYdVN0m8BShL3OQCtXZe/JPF7ZkpD3760=
 github.com/google/go-tdx-guest v0.3.2-0.20241009005452-097ee70d0843 h1:+MoPobRN9HrDhGyn6HnF5NYo4uMBKaiFqAtf/D/OB4A=
 github.com/google/go-tdx-guest v0.3.2-0.20241009005452-097ee70d0843/go.mod h1:g/n8sKITIT9xRivBUbizo34DTsUm2nN2uU3A662h09g=
-github.com/google/go-tpm v0.9.7 h1:u89J4tUUeDTlH8xxC3CTW7OHZjbjKoHdQ9W7gCUhtxA=
-github.com/google/go-tpm v0.9.7/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
+github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo=
+github.com/google/go-tpm v0.9.8/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
 github.com/google/go-tpm-tools v0.4.7 h1:J3ycC8umYxM9A4eF73EofRZu4BxY0jjQnUnkhIBbvws=
 github.com/google/go-tpm-tools v0.4.7/go.mod h1:gSyXTZHe3fgbzb6WEGd90QucmsnT1SRdlye82gH8QjQ=
 github.com/google/go-tspi v0.3.0 h1:ADtq8RKfP+jrTyIWIZDIYcKOMecRqNJFOew2IT0Inus=