Skip to content

Commit

Permalink
feat: preheat skip certificate validation (#786)
Browse files Browse the repository at this point in the history
* feat: preheat skip certificate validation

Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Nov 9, 2021
1 parent ec8ede0 commit 1d452b7
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions manager/job/preheat.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package job

import (
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -50,6 +51,10 @@ const (
PreheatFileType PreheatType = "file"
)

const (
timeout = 1 * time.Minute
)

var accessURLPattern, _ = regexp.Compile("^(.*)://(.*)/v2/(.*)/manifests/(.*)")

type Preheat interface {
Expand Down Expand Up @@ -205,7 +210,14 @@ func (p *preheat) getManifests(ctx context.Context, url string, header http.Head
req.Header = header
req.Header.Add("Accept", schema2.MediaTypeManifest)

resp, err := http.DefaultClient.Do(req)
client := &http.Client{
Timeout: timeout,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}

resp, err := client.Do(req)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -255,7 +267,14 @@ func getAuthToken(ctx context.Context, header http.Header) (token string) {
return
}

resp, err := http.DefaultClient.Do(req)
client := &http.Client{
Timeout: timeout,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}

resp, err := client.Do(req)
if err != nil {
return
}
Expand Down

0 comments on commit 1d452b7

Please sign in to comment.