Add skip-verify flag for using self-signed certificates
This commit adds a `skip-verify` flag to the replica configuration so that it can be used with self-signed certificates. This is useful when running a local instance of MinIO with TLS for testing.
This commit is contained in:
@@ -276,6 +276,7 @@ type ReplicaConfig struct {
|
|||||||
Bucket string `yaml:"bucket"`
|
Bucket string `yaml:"bucket"`
|
||||||
Endpoint string `yaml:"endpoint"`
|
Endpoint string `yaml:"endpoint"`
|
||||||
ForcePathStyle *bool `yaml:"force-path-style"`
|
ForcePathStyle *bool `yaml:"force-path-style"`
|
||||||
|
SkipVerify bool `yaml:"skip-verify"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewReplicaFromConfig instantiates a replica for a DB based on a config.
|
// NewReplicaFromConfig instantiates a replica for a DB based on a config.
|
||||||
@@ -347,7 +348,7 @@ func newS3ReplicaFromConfig(c *ReplicaConfig, db *litestream.DB) (_ *s3.Replica,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bucket, path := c.Bucket, c.Path
|
bucket, path := c.Bucket, c.Path
|
||||||
region, endpoint := c.Region, c.Endpoint
|
region, endpoint, skipVerify := c.Region, c.Endpoint, c.SkipVerify
|
||||||
|
|
||||||
// Use path style if an endpoint is explicitly set. This works because the
|
// Use path style if an endpoint is explicitly set. This works because the
|
||||||
// only service to not use path style is AWS which does not use an endpoint.
|
// only service to not use path style is AWS which does not use an endpoint.
|
||||||
@@ -396,6 +397,7 @@ func newS3ReplicaFromConfig(c *ReplicaConfig, db *litestream.DB) (_ *s3.Replica,
|
|||||||
r.Region = region
|
r.Region = region
|
||||||
r.Endpoint = endpoint
|
r.Endpoint = endpoint
|
||||||
r.ForcePathStyle = forcePathStyle
|
r.ForcePathStyle = forcePathStyle
|
||||||
|
r.SkipVerify = skipVerify
|
||||||
|
|
||||||
if v := c.Retention; v > 0 {
|
if v := c.Retention; v > 0 {
|
||||||
r.Retention = v
|
r.Retention = v
|
||||||
|
|||||||
9
s3/s3.go
9
s3/s3.go
@@ -3,11 +3,13 @@ package s3
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -79,6 +81,7 @@ type Replica struct {
|
|||||||
Path string
|
Path string
|
||||||
Endpoint string
|
Endpoint string
|
||||||
ForcePathStyle bool
|
ForcePathStyle bool
|
||||||
|
SkipVerify bool
|
||||||
|
|
||||||
// Time between syncs with the shadow WAL.
|
// Time between syncs with the shadow WAL.
|
||||||
SyncInterval time.Duration
|
SyncInterval time.Duration
|
||||||
@@ -769,6 +772,12 @@ func (r *Replica) config() *aws.Config {
|
|||||||
if r.ForcePathStyle {
|
if r.ForcePathStyle {
|
||||||
config.S3ForcePathStyle = aws.Bool(r.ForcePathStyle)
|
config.S3ForcePathStyle = aws.Bool(r.ForcePathStyle)
|
||||||
}
|
}
|
||||||
|
if r.SkipVerify {
|
||||||
|
config.HTTPClient = &http.Client{Transport: &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user