Skip to content

Commit

Permalink
Add --insecure flag to skip TLS verification in s3-md5-check tool (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveenrajmani committed May 26, 2022
1 parent c0bf02b commit 62cd643
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions docs/debugging/s3-check-md5/main.go
Expand Up @@ -38,6 +38,7 @@ var (
bucket, prefix string
debug bool
versions bool
insecure bool
)

// getMD5Sum returns MD5 sum of given data.
Expand All @@ -55,6 +56,7 @@ func main() {
flag.StringVar(&prefix, "prefix", "", "Select a prefix")
flag.BoolVar(&debug, "debug", false, "Prints HTTP network calls to S3 endpoint")
flag.BoolVar(&versions, "versions", false, "Verify all versions")
flag.BoolVar(&insecure, "insecure", false, "Disable TLS verification")
flag.Parse()

if endpoint == "" {
Expand All @@ -78,12 +80,23 @@ func main() {
log.Fatalln(err)
}

secure := strings.EqualFold(u.Scheme, "https")
transport, err := minio.DefaultTransport(secure)
if err != nil {
log.Fatalln(err)
}
if insecure {
// skip TLS verification
transport.TLSClientConfig.InsecureSkipVerify = true
}

s3Client, err := minio.New(u.Host, &minio.Options{
Creds: credentials.NewStaticV4(accessKey, secretKey, ""),
Secure: strings.EqualFold(u.Scheme, "https"),
Creds: credentials.NewStaticV4(accessKey, secretKey, ""),
Secure: secure,
Transport: transport,
})
if err != nil {
log.Fatalln()
log.Fatalln(err)
}

if debug {
Expand Down

0 comments on commit 62cd643

Please sign in to comment.