diff --git a/docs/manual/nodes.md b/docs/manual/nodes.md index 63fd5ed40..b987e5f34 100644 --- a/docs/manual/nodes.md +++ b/docs/manual/nodes.md @@ -166,6 +166,7 @@ The remote file will be downloaded to the containerlab's temp directory at `$TMP * Upon deletion of a lab, the downloaded startup-config files will not be removed. A manual cleanup should be performed if required. * If a lab is redeployed with the lab name and startup-config paths unchanged, the local file will be overwritten. + * For https locations the certificates won't be verified to allow fetching artifacts from servers with self-signed certificates. ### enforce-startup-config diff --git a/utils/file.go b/utils/file.go index eefa4ad00..d06fe7540 100644 --- a/utils/file.go +++ b/utils/file.go @@ -6,6 +6,7 @@ package utils import ( "bufio" + "crypto/tls" "errors" "fmt" "io" @@ -87,7 +88,19 @@ func CopyFileContents(src, dst string, mode os.FileMode) (err error) { var in io.ReadCloser if IsHttpUri(src) { - resp, err := http.Get(src) + // set InsecureSkipVerify to true to allow fetching + // files form servers with self-signed certificates + tr := &http.Transport{ + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: true, // skipcq: GSC-G402 + MinVersion: tls.VersionTLS12, + }, + } + + client := &http.Client{Transport: tr} + + // download using client + resp, err := client.Get(src) if err != nil || resp.StatusCode != 200 { return fmt.Errorf("%w: %s", errHTTPFetch, src) }