adding option to skip tls verification error (#30)

* adding option to skip tls verification error

* merge options

* removed merged option from README

Co-authored-by: Schwannden Kuo <schwannden@mobagel.com>
This commit is contained in:
schwannden 2021-10-29 01:51:35 +08:00 committed by GitHub
parent ad7ec58322
commit 7f0f173115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,11 +159,24 @@ func newScript() (*script, error) {
} else { } else {
return nil, errors.New("newScript: AWS_S3_BUCKET_NAME is defined, but no credentials were provided") return nil, errors.New("newScript: AWS_S3_BUCKET_NAME is defined, but no credentials were provided")
} }
options := minio.Options{
mc, err := minio.New(s.c.AwsEndpoint, &minio.Options{
Creds: creds, Creds: creds,
Secure: !s.c.AwsEndpointInsecure && s.c.AwsEndpointProto == "https", Secure: s.c.AwsEndpointProto == "https",
}) }
if s.c.AwsEndpointInsecure {
if options.Secure {
transport, err := minio.DefaultTransport(options.Secure)
if err != nil {
return nil, fmt.Errorf("newScript: failed to create default minio transport")
}
transport.TLSClientConfig.InsecureSkipVerify = true
options.Transport = transport
} else {
return nil, errors.New("newScript: AWS_ENDPOINT_INSECURE = true is only meaningful for https")
}
}
mc, err := minio.New(s.c.AwsEndpoint, &options)
if err != nil { if err != nil {
return nil, fmt.Errorf("newScript: error setting up minio client: %w", err) return nil, fmt.Errorf("newScript: error setting up minio client: %w", err)
} }