Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const (
PreserveInfoFlag = "preserve-info"
IsNFSProtocolFlag = "nfs"
HardlinksFlag = "hardlinks"

// root command flags
AllowInsecureCertificatesFlag = "allow-insecure-certs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

design question - would this be better as an environment variable over a CLI param?

)

const (
Expand Down
6 changes: 6 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package cmd

import (
"crypto/tls"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -342,6 +343,8 @@ func init() {
_ = rootCmd.PersistentFlags().MarkHidden("memory-profile")
rootCmd.PersistentFlags().BoolVar(&checkAzCopyUpdates, "check-version", false,
"Check if a newer AzCopy version is available.")
rootCmd.PersistentFlags().BoolVar(&common.AllowInsecureCerts, AllowInsecureCertificatesFlag, false, "Use in combination with a MITM proxy for debugging purposes")
_ = rootCmd.PersistentFlags().MarkHidden(AllowInsecureCertificatesFlag)
}

// always spins up a new goroutine, because sometimes the aka.ms URL can't be reached (e.g. a constrained environment where
Expand Down Expand Up @@ -397,6 +400,9 @@ func getGitHubLatestRemoteVersionWithURL(apiEndpoint string) (*Version, error) {
IdleConnTimeout: 30 * time.Second,
DisableCompression: true, // GitHub API responses are small
DisableKeepAlives: false, // Connections are reused
TLSClientConfig: &tls.Config{
InsecureSkipVerify: common.AllowInsecureCerts,
},
}

client := &http.Client{
Expand Down
6 changes: 6 additions & 0 deletions common/oauthTokenManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package common

import (
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -87,6 +88,8 @@ func NewUserOAuthTokenManagerInstance(credCacheOptions CredCacheOptions) *UserOA
}
}

var AllowInsecureCerts bool

func newAzcopyHTTPClient() *http.Client {
return &http.Client{
Transport: &http.Transport{
Expand All @@ -105,6 +108,9 @@ func newAzcopyHTTPClient() *http.Client {
DisableKeepAlives: false,
DisableCompression: true,
MaxResponseHeaderBytes: 0,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: AllowInsecureCerts,
},
// ResponseHeaderTimeout: time.Duration{},
// ExpectContinueTimeout: time.Duration{},
},
Expand Down
5 changes: 5 additions & 0 deletions ste/mgr-JobPartMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ste

import (
"context"
"crypto/tls"
"fmt"
"mime"
"net/http"
Expand Down Expand Up @@ -81,6 +82,7 @@ type IJobPartMgr interface {
// 'ulimit -Hn' is low).
func NewAzcopyHTTPClient(maxIdleConns int) *http.Client {
const concurrentDialsPerCpu = 10 // exact value doesn't matter too much, but too low will be too slow, and too high will reduce the beneficial effect on thread count

return &http.Client{
Transport: &http.Transport{
Proxy: common.GlobalProxyLookup,
Expand All @@ -93,6 +95,9 @@ func NewAzcopyHTTPClient(maxIdleConns int) *http.Client {
DisableKeepAlives: false,
DisableCompression: true, // must disable the auto-decompression of gzipped files, and just download the gzipped version. See https://github.com/Azure/azure-storage-azcopy/issues/374
MaxResponseHeaderBytes: 0,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: common.AllowInsecureCerts,
},
// ResponseHeaderTimeout: time.Duration{},
// ExpectContinueTimeout: time.Duration{},
},
Expand Down
6 changes: 6 additions & 0 deletions ste/performanceAdvisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package ste

import (
"bytes"
"crypto/tls"
"fmt"
"github.com/Azure/azure-storage-azcopy/v10/common"
"net/http"
Expand Down Expand Up @@ -346,6 +347,11 @@ func (p *PerformanceAdvisor) GetAdvice() []common.PerformanceAdvice {
func (p *PerformanceAdvisor) getAzureVmSize() string {
client := &http.Client{
Timeout: time.Second * 3, // no point in waiting too long, since when it works, it will be almost instant
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: common.AllowInsecureCerts,
},
},
Comment on lines +350 to +354
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Azure Instance Metadata Service uses HTTP (not HTTPS), so configuring TLS settings for this client is unnecessary. The TLSClientConfig will have no effect on HTTP requests. Consider removing the TLS configuration for this specific client or adding a comment explaining why it's present despite using HTTP.

Suggested change
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: common.AllowInsecureCerts,
},
},
Transport: &http.Transport{},

Copilot uses AI. Check for mistakes.
}

req, err := http.NewRequest("GET", "http://169.254.169.254/metadata/instance/compute/vmSize?api-version=2019-03-11&format=text", nil)
Expand Down
Loading