option to skip TLS verification for object storage
package s3
import (
+ "crypto/tls"
"fmt"
"io"
"net/http"
@@ -47,6 +48,10 @@ type Conf struct {
UploadPartSize int `bson:"uploadPartSize,omitempty" json:"uploadPartSize,omitempty" yaml:"uploadPartSize,omitempty"`
MaxUploadParts int `bson:"maxUploadParts,omitempty" json:"maxUploadParts,omitempty" yaml:"maxUploadParts,omitempty"`
StorageClass string `bson:"storageClass,omitempty" json:"storageClass,omitempty" yaml:"storageClass,omitempty"`
+
+ // InsecureSkipTLSVerify disables client verification of the server's
+ // certificate chain and host name
+ InsecureSkipTLSVerify bool `bson:"insecureSkipTLSVerify" json:"insecureSkipTLSVerify" yaml:"insecureSkipTLSVerify"`
}
type AWSsse struct {
@@ -236,7 +241,6 @@ func (s *S3) List(prefix, suffix string) ([]storage.FileInfo, error) {
}
return true
})
-
if err != nil {
return nil, errors.Wrap(err, "get backup list")
}
@@ -334,7 +338,6 @@ func (pr *partReader) writeNext(w io.Writer) (n int64, err error) {
Key: aws.String(path.Join(pr.opts.Prefix, pr.fname)),
Range: aws.String(fmt.Sprintf("bytes=%d-%d", pr.n, pr.n+downloadChuckSize-1)),
})
-
if err != nil {
// if object size is undefined, we would read
// until HTTP code 416 (Requested Range Not Satisfiable)
@@ -465,7 +468,6 @@ func (s *S3) Delete(name string) error {
Bucket: aws.String(s.opts.Bucket),
Key: aws.String(path.Join(s.opts.Prefix, name)),
})
-
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
@@ -506,10 +508,20 @@ func (s *S3) session() (*session.Session, error) {
Client: ec2metadata.New(session.New()),
})
+ httpClient := http.DefaultClient
+ if s.opts.InsecureSkipTLSVerify {
+ httpClient = &http.Client{
+ Transport: &http.Transport{
+ TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
+ },
+ }
+ }
+
return session.NewSession(&aws.Config{
Region: aws.String(s.opts.Region),
Endpoint: aws.String(s.opts.EndpointURL),
Credentials: credentials.NewChainCredentials(providers),
S3ForcePathStyle: aws.Bool(true),
+ HTTPClient: httpClient,
})
}
