Skip to content

Commit 7e661dd

Browse files
Fix TLS client config error
Signed-off-by: Anisur Rahman <anisur@appscode.com>
1 parent 5082c40 commit 7e661dd

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

api/v1/generated.pb.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/blob/blob.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
api "kmodules.xyz/objectstore-api/api/v1"
3131

3232
aws2 "github.com/aws/aws-sdk-go-v2/aws"
33+
awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"
3334
"github.com/aws/aws-sdk-go-v2/config"
3435
"github.com/aws/aws-sdk-go-v2/credentials"
3536
"github.com/aws/aws-sdk-go-v2/service/s3"
@@ -503,7 +504,7 @@ func (b *Blob) getS3Config(ctx context.Context, debug bool) (aws2.Config, error)
503504
return config.LoadDefaultConfig(ctx, loadOptions...)
504505
}
505506

506-
func configureTLS(caCert []byte, insecureTLS bool) (*http.Client, error) {
507+
func configureTLS(caCert []byte, insecureTLS bool) (*awshttp.BuildableClient, error) {
507508
tlsConfig := &tls.Config{
508509
InsecureSkipVerify: insecureTLS,
509510
}
@@ -514,12 +515,12 @@ func configureTLS(caCert []byte, insecureTLS bool) (*http.Client, error) {
514515
}
515516
tlsConfig.RootCAs = caCertPool
516517
}
517-
rt := http.DefaultTransport.(*http.Transport).Clone()
518-
rt.TLSClientConfig = tlsConfig
518+
buildableClient := awshttp.NewBuildableClient().WithTransportOptions(func(tr *http.Transport) {
519+
tr.TLSClientConfig = tlsConfig
520+
})
521+
// https://docs.aws.amazon.com/sdk-for-go/v2/developer-guide/configure-http.html#transport
519522

520-
return &http.Client{
521-
Transport: rt,
522-
}, nil
523+
return buildableClient, nil
523524
}
524525

525526
func (b *Blob) SetPathAsDir(ctx context.Context, path string) error {

0 commit comments

Comments
 (0)