mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-09-22 14:04:53 -04:00
Use context for http request
This commit is contained in:
parent
114a51b29c
commit
c45c2332bc
1 changed files with 8 additions and 3 deletions
|
@ -8,6 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
@ -42,7 +43,7 @@ func getIDKeyDigest(rawToken string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get JSON Web Key set.
|
// Get JSON Web Key set.
|
||||||
keySetBytes, err := httpGet("https://sharedeus.eus.attest.azure.net/certs")
|
keySetBytes, err := httpGet(context.Background(), "https://sharedeus.eus.attest.azure.net/certs")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -95,8 +96,12 @@ func parseKeySet(keySetBytes []byte) (jose.JSONWebKeySet, error) {
|
||||||
return keySet, nil
|
return keySet, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func httpGet(url string) ([]byte, error) {
|
func httpGet(ctx context.Context, url string) ([]byte, error) {
|
||||||
resp, err := http.Get(url)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, http.NoBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue