From 5ab08d2d472ad2c8efad2a3d7f877a8625d66e09 Mon Sep 17 00:00:00 2001 From: Jeff Hodges Date: Wed, 4 Sep 2024 00:38:57 -0700 Subject: [PATCH] use default http client everywhere now since we're not modifying it --- signer/contentsignaturepki/contentsignature.go | 3 ++- signer/contentsignaturepki/contentsignature_test.go | 3 ++- signer/contentsignaturepki/upload.go | 5 ----- signer/contentsignaturepki/x509.go | 3 ++- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/signer/contentsignaturepki/contentsignature.go b/signer/contentsignaturepki/contentsignature.go index 993b3d394..f0701966b 100755 --- a/signer/contentsignaturepki/contentsignature.go +++ b/signer/contentsignaturepki/contentsignature.go @@ -11,6 +11,7 @@ import ( "hash" "io" "math/big" + "net/http" "time" "github.com/mozilla-services/autograph/database" @@ -187,7 +188,7 @@ func (s *ContentSigner) initEE(conf signer.Configuration) error { default: return fmt.Errorf("contentsignaturepki %q: failed to find suitable end-entity: %w", s.ID, err) } - _, _, err = GetX5U(buildHTTPClient(), s.X5U) + _, _, err = GetX5U(http.DefaultClient, s.X5U) if err != nil { return fmt.Errorf("contentsignaturepki %q: failed to verify x5u: %w", s.ID, err) } diff --git a/signer/contentsignaturepki/contentsignature_test.go b/signer/contentsignaturepki/contentsignature_test.go index 2bc514b61..a77206cdc 100755 --- a/signer/contentsignaturepki/contentsignature_test.go +++ b/signer/contentsignaturepki/contentsignature_test.go @@ -9,6 +9,7 @@ package contentsignaturepki import ( "crypto/ecdsa" "fmt" + "net/http" "strings" "testing" @@ -74,7 +75,7 @@ func TestSign(t *testing.T) { } // verify the signature using the public key of the end entity - _, certs, err := GetX5U(buildHTTPClient(), s.X5U) + _, certs, err := GetX5U(http.DefaultClient, s.X5U) if err != nil { t.Fatalf("testcase %d failed to get X5U %q: %v", i, s.X5U, err) } diff --git a/signer/contentsignaturepki/upload.go b/signer/contentsignaturepki/upload.go index 6ec98d00f..0617b9135 100755 --- a/signer/contentsignaturepki/upload.go +++ b/signer/contentsignaturepki/upload.go @@ -87,11 +87,6 @@ func writeLocalFile(data, name string, target *url.URL) error { return os.WriteFile(filepath.Join(target.Path, name), []byte(data), 0755) } -// buildHTTPClient returns the default HTTP.Client for fetching X5Us -func buildHTTPClient() *http.Client { - return &http.Client{} -} - // GetX5U retrieves a chain file of certs from upload location, parses // and verifies it, then returns a byte slice of the response body and // a slice of parsed certificates. diff --git a/signer/contentsignaturepki/x509.go b/signer/contentsignaturepki/x509.go index 9b47b3d36..30a32a3e6 100755 --- a/signer/contentsignaturepki/x509.go +++ b/signer/contentsignaturepki/x509.go @@ -7,6 +7,7 @@ import ( "encoding/pem" "fmt" "math/big" + "net/http" "net/url" "time" @@ -55,7 +56,7 @@ func (s *ContentSigner) makeAndUploadChain() error { if err != nil { return fmt.Errorf("failed to join x5u with chain name: %w", err) } - _, _, err = GetX5U(buildHTTPClient(), newX5U) + _, _, err = GetX5U(http.DefaultClient, newX5U) if err != nil { return fmt.Errorf("failed to download new chain: %w", err) }