From ed7715ff5bccc94619c8f4559a46890cee9ae9db Mon Sep 17 00:00:00 2001 From: Stephen Touset Date: Fri, 20 Jun 2025 11:14:41 -0700 Subject: [PATCH 1/2] Ensure ClientConfig settings are applied to provided HTTPClients (#433) --- client.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/client.go b/client.go index 73b4fcb6..0aca0ac2 100644 --- a/client.go +++ b/client.go @@ -7,7 +7,6 @@ package gofish import ( "bytes" "context" - "crypto/tls" "encoding/base64" "encoding/json" "fmt" @@ -121,10 +120,6 @@ func setupClientWithConfig(ctx context.Context, config *ClientConfig) (c *APICli client.sem = make(chan bool, config.MaxConcurrentRequests) } - if config.TLSHandshakeTimeout == 0 { - config.TLSHandshakeTimeout = 10 - } - if config.HTTPClient == nil { defaultTransport := http.DefaultTransport.(*http.Transport) transport := &http.Transport{ @@ -133,10 +128,20 @@ func setupClientWithConfig(ctx context.Context, config *ClientConfig) (c *APICli MaxIdleConns: defaultTransport.MaxIdleConns, IdleConnTimeout: defaultTransport.IdleConnTimeout, ExpectContinueTimeout: defaultTransport.ExpectContinueTimeout, + TLSClientConfig: defaultTransport.TLSClientConfig, TLSHandshakeTimeout: time.Duration(config.TLSHandshakeTimeout) * time.Second, - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: config.Insecure, - }, + } + + config.HTTPClient = &http.Client{Transport: transport} + } + + client.HTTPClient = config.HTTPClient + + // if the provided HTTPClient uses a standard Transport, we want to + // amend its configuration to match what was provided to us + if transport, ok := client.HTTPClient.Transport.(*http.Transport); ok { + if config.Insecure { + transport.TLSClientConfig.InsecureSkipVerify = config.Insecure } if config.ReuseConnections { @@ -145,12 +150,9 @@ func setupClientWithConfig(ctx context.Context, config *ClientConfig) (c *APICli transport.IdleConnTimeout = 1 * time.Minute } - client.HTTPClient = &http.Client{Transport: transport} - } else { - if config.ReuseConnections { - client.keepAlive = true + if config.TLSHandshakeTimeout != 0 { + transport.TLSHandshakeTimeout = time.Duration(config.TLSHandshakeTimeout) * time.Second } - client.HTTPClient = config.HTTPClient } // Fetch the service root From e364e997b5e8863c5d68465f7661c8f9851cf026 Mon Sep 17 00:00:00 2001 From: Brian Brown Date: Sat, 21 Jun 2025 16:32:09 -0400 Subject: [PATCH 2/2] fix: TrustedComponent TPM is a json object (#435) Use the TPM type instead --- redfish/trustedcomponent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redfish/trustedcomponent.go b/redfish/trustedcomponent.go index b8afcaae..18b96392 100644 --- a/redfish/trustedcomponent.go +++ b/redfish/trustedcomponent.go @@ -106,7 +106,7 @@ type TrustedComponent struct { Status common.Status // TPM shall contain TPM-specific information for this trusted component. This property shall only be present for // TCG-defined TPM trusted components. - TPM string + TPM TPM // TrustedComponentType shall contain the type of trusted component. TrustedComponentType TrustedComponentType // UUID shall contain a universally unique identifier number for the trusted component.