Add --insecure flag to skip TLS verification in s3-md5-check tool (#14980)

This commit is contained in:
Praveen raj Mani 2022-05-26 18:32:05 +05:30 committed by GitHub
parent c0bf02b8b2
commit 62cd643868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,6 +38,7 @@ var (
bucket, prefix string bucket, prefix string
debug bool debug bool
versions bool versions bool
insecure bool
) )
// getMD5Sum returns MD5 sum of given data. // getMD5Sum returns MD5 sum of given data.
@ -55,6 +56,7 @@ func main() {
flag.StringVar(&prefix, "prefix", "", "Select a prefix") flag.StringVar(&prefix, "prefix", "", "Select a prefix")
flag.BoolVar(&debug, "debug", false, "Prints HTTP network calls to S3 endpoint") flag.BoolVar(&debug, "debug", false, "Prints HTTP network calls to S3 endpoint")
flag.BoolVar(&versions, "versions", false, "Verify all versions") flag.BoolVar(&versions, "versions", false, "Verify all versions")
flag.BoolVar(&insecure, "insecure", false, "Disable TLS verification")
flag.Parse() flag.Parse()
if endpoint == "" { if endpoint == "" {
@ -78,12 +80,23 @@ func main() {
log.Fatalln(err) 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{ s3Client, err := minio.New(u.Host, &minio.Options{
Creds: credentials.NewStaticV4(accessKey, secretKey, ""), Creds: credentials.NewStaticV4(accessKey, secretKey, ""),
Secure: strings.EqualFold(u.Scheme, "https"), Secure: secure,
Transport: transport,
}) })
if err != nil { if err != nil {
log.Fatalln() log.Fatalln(err)
} }
if debug { if debug {