Skip to content

Commit

Permalink
bundle: use inmemory.Download to fetch signed hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
anjannath committed Jun 2, 2023
1 parent c627d21 commit bbbe32c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions pkg/crc/machine/bundle/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"io"
"net/http"
"os"
"path"
"path/filepath"
Expand All @@ -20,7 +19,9 @@ import (
"github.com/crc-org/crc/pkg/crc/logging"
"github.com/crc-org/crc/pkg/crc/network"
crcPreset "github.com/crc-org/crc/pkg/crc/preset"
"github.com/crc-org/crc/pkg/crc/version"
"github.com/crc-org/crc/pkg/download"
"github.com/crc-org/crc/pkg/download/inmemory"
)

// Metadata structure to unmarshal the crc-bundle-info.json file
Expand Down Expand Up @@ -299,21 +300,18 @@ func getBundleDownloadInfo(preset crcPreset.Preset) (*download.RemoteFile, error
// then verifies it is signed by redhat release key, if signature is valid it returns the hash
// for the default bundle of preset from the file
func getDefaultBundleVerifiedHash(preset crcPreset.Preset) (string, error) {
client := &http.Client{
Timeout: 5 * time.Second,
Transport: network.HTTPTransport(),
}
res, err := client.Get(constants.GetDefaultBundleSignedHashURL(preset))
res, err := inmemory.Download(constants.GetDefaultBundleSignedHashURL(preset),
version.UserAgent(),
network.HTTPTransport(),
)
if err != nil {
return "", err
}
signedHashes, err := io.ReadAll(res.Body)
defer res.Close()
signedHashes, err := io.ReadAll(res)
if err != nil {
return "", err
}
if err := res.Body.Close(); err != nil {
logging.Debug(err)
}

verifiedHashes, err := gpg.GetVerifiedClearsignedMsgV3(constants.RedHatReleaseKey, string(signedHashes))
if err != nil {
Expand Down

0 comments on commit bbbe32c

Please sign in to comment.