Commit b2489cdf authored by Thomas Johansen's avatar Thomas Johansen Committed by Vitaliy Filippov
Browse files

Allow insecure S3 connections (fix #100)

parent 8ebd0f05
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -3,8 +3,11 @@ package s3
import (
	"bytes"
	"context"
	"crypto/tls"
	"fmt"
	"net/http"
	"net/url"
	"strconv"
	"sync/atomic"

	"github.com/golang/glog"
@@ -29,6 +32,7 @@ type Config struct {
	Region          string
	Endpoint        string
	Mounter         string
	Insecure        bool
}

type FSMeta struct {
@@ -52,7 +56,15 @@ func NewClient(cfg *Config) (*s3Client, error) {
	if u.Port() != "" {
		endpoint = u.Hostname() + ":" + u.Port()
	}

	var transport = &http.Transport{}
	if client.Config.Insecure {
		tlsConfig := &tls.Config{}
		tlsConfig.InsecureSkipVerify = true
		transport.TLSClientConfig = tlsConfig
	}
	minioClient, err := minio.New(endpoint, &minio.Options{
		Transport: transport,
		Creds:     credentials.NewStaticV4(client.Config.AccessKeyID, client.Config.SecretAccessKey, ""),
		Region:    client.Config.Region,
		Secure:    ssl,
@@ -66,6 +78,7 @@ func NewClient(cfg *Config) (*s3Client, error) {
}

func NewClientFromSecret(secret map[string]string) (*s3Client, error) {
	insecure, _ := strconv.ParseBool(secret["insecure"])
	return NewClient(&Config{
		AccessKeyID:     secret["accessKeyID"],
		SecretAccessKey: secret["secretAccessKey"],
@@ -73,6 +86,7 @@ func NewClientFromSecret(secret map[string]string) (*s3Client, error) {
		Endpoint:        secret["endpoint"],
		// Mounter is set in the volume preferences, not secrets
		Mounter:  "",
		Insecure: insecure,
	})
}