mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -04:00
api: add functions to transparently handle signatures upon API interaction (#2142)
This commit is contained in:
parent
002c3a9a32
commit
dac690656e
45 changed files with 707 additions and 472 deletions
|
@ -43,7 +43,12 @@ func NewFetcher() Fetcher {
|
|||
|
||||
// NewFetcherWithClient returns a new fetcher with custom http client.
|
||||
func NewFetcherWithClient(client apifetcher.HTTPClient) Fetcher {
|
||||
return newFetcherWithClientAndVerifier(client, sigstore.CosignVerifier{})
|
||||
verifier, err := sigstore.NewCosignVerifier([]byte(cosignPublicKey))
|
||||
if err != nil {
|
||||
// This relies on an embedded public key. If this key can not be validated, there is no way to recover from this.
|
||||
panic(fmt.Errorf("creating cosign verifier: %w", err))
|
||||
}
|
||||
return newFetcherWithClientAndVerifier(client, verifier)
|
||||
}
|
||||
|
||||
func newFetcherWithClientAndVerifier(client apifetcher.HTTPClient, cosignVerifier sigstore.Verifier) Fetcher {
|
||||
|
@ -73,7 +78,7 @@ func (f *fetcher) FetchAzureSEVSNPVersion(ctx context.Context, azureVersion Azur
|
|||
return fetchedVersion, fmt.Errorf("fetch version %s signature: %w", azureVersion.Version, err)
|
||||
}
|
||||
|
||||
err = f.verifier.VerifySignature(versionBytes, signature.Signature, []byte(cosignPublicKey))
|
||||
err = f.verifier.VerifySignature(versionBytes, signature.Signature)
|
||||
if err != nil {
|
||||
return fetchedVersion, fmt.Errorf("verify version %s signature: %w", azureVersion.Version, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue