Skip to content

Commit d97af30

Browse files
committed
allow S3 client to skip SSL verification
1 parent 55b96ca commit d97af30

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Possible JSON properties:
8383
- `disable_web`: optional, disable web interface and api
8484
- `disable_metrics`: optional, disable Prometheus metrics endpoint
8585
- `unprotected_metrics`: optional, disable HTTP basic auth protection for Prometheus metrics endpoint
86+
- `s3.disable_ssl`: optional, S3 client connections will use HTTP instead of HTTPS
87+
- `s3.skip_ssl_verification`: optional, S3 client will still use HTTPS but skips certificate verification
8688
- `s3.service_label`: optional, defines which service label backman will look for to find the S3-compatible object storage
8789
- `s3.bucket_name`: optional, bucket to use on S3 storage, backman will use service-instance/binding-name if not configured
8890
- `s3.encryption_key`: optional, defines the key which will be used to encrypt and decrypt backups as they are stored on the S3 can also be passed as an environment variable with the name `BACKMAN_ENCRYPTION_KEY`

config/config.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ type Config struct {
2929
}
3030

3131
type S3Config struct {
32-
DisableSSL bool `json:"disable_ssl"`
33-
ServiceLabel string `json:"service_label"`
34-
ServiceName string `json:"service_name"`
35-
BucketName string `json:"bucket_name"`
36-
EncryptionKey string `json:"encryption_key"`
32+
DisableSSL bool `json:"disable_ssl"`
33+
SkipSSLVerification bool `json:"skip_ssl_verification"`
34+
ServiceLabel string `json:"service_label"`
35+
ServiceName string `json:"service_name"`
36+
BucketName string `json:"bucket_name"`
37+
EncryptionKey string `json:"encryption_key"`
3738
}
3839

3940
type ServiceConfig struct {
@@ -131,6 +132,9 @@ func Get() *Config {
131132
if envConfig.S3.DisableSSL {
132133
config.S3.DisableSSL = envConfig.S3.DisableSSL
133134
}
135+
if envConfig.S3.SkipSSLVerification {
136+
config.S3.SkipSSLVerification = envConfig.S3.SkipSSLVerification
137+
}
134138
if len(envConfig.S3.ServiceLabel) > 0 {
135139
config.S3.ServiceLabel = envConfig.S3.ServiceLabel
136140
}

manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ applications:
2323

2424
# ### push either as docker image
2525
docker:
26-
image: jamesclonk/backman:1.25.1 # choose version from https://hub.docker.com/r/jamesclonk/backman/tags, or 'latest'
26+
image: jamesclonk/backman:1.26.0 # choose version from https://hub.docker.com/r/jamesclonk/backman/tags, or 'latest'
2727
# ### or as buildpack/src
2828
# buildpacks:
2929
# - https://github.com/cloudfoundry/apt-buildpack

s3/client.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package s3
22

33
import (
4+
"crypto/tls"
5+
"net"
6+
"net/http"
7+
"time"
8+
49
cfenv "github.com/cloudfoundry-community/go-cfenv"
510
"github.com/minio/minio-go/v6"
611
"github.com/swisscom/backman/config"
@@ -53,6 +58,24 @@ func New(app *cfenv.App) *Client {
5358
log.Fatalf("%v", err)
5459
}
5560

61+
if config.Get().S3.SkipSSLVerification {
62+
log.Debugln("disabling S3 client SSL verification ...")
63+
minioClient.SetCustomTransport(&http.Transport{
64+
Proxy: http.ProxyFromEnvironment,
65+
TLSClientConfig: &tls.Config{
66+
InsecureSkipVerify: true,
67+
},
68+
DialContext: (&net.Dialer{
69+
Timeout: 30 * time.Second,
70+
KeepAlive: 30 * time.Second,
71+
}).DialContext,
72+
MaxIdleConns: 100,
73+
IdleConnTimeout: 90 * time.Second,
74+
TLSHandshakeTimeout: 10 * time.Second,
75+
ExpectContinueTimeout: 1 * time.Second,
76+
})
77+
}
78+
5679
// check if bucket exists and is accessible and if not create it, or fail
5780
exists, errBucketExists := minioClient.BucketExists(bucketName)
5881
if errBucketExists == nil && exists {

0 commit comments

Comments
 (0)