Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
add MINIO_CA_CERT and extra logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tnix100 committed Aug 16, 2024
1 parent 94bfe9f commit 4d6dc8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/hex"
"fmt"
"io"
"log"
"time"

"github.com/discord/lilliput"
Expand Down Expand Up @@ -138,6 +139,7 @@ func CreateFile(bucket string, fileBytes []byte, filename string, mime string, u
ContentType: mime,
},
); err != nil {
log.Println(err)
return f, err
}
}
Expand Down
18 changes: 12 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"crypto/tls"
"crypto/x509"

"github.com/getsentry/sentry-go"
_ "github.com/glebarez/go-sqlite"
Expand Down Expand Up @@ -79,14 +80,19 @@ func main() {
endpoint := region[1]
opts := &minio.Options{
Creds: credentials.NewStaticV4(os.Getenv("MINIO_ACCESS_KEY"), os.Getenv("MINIO_SECRET_KEY"), ""),
Secure: true,
Secure: os.Getenv("MINIO_SECURE") == "1",
}
if os.Getenv("MINIO_SECURE") != "1" {
opts.Secure = false
}
if os.Getenv("MINIO_NO_TLS_VERIFY") == "1" {
if os.Getenv("MINIO_CA_CERT") != "" {
caCert, err := os.ReadFile(os.Getenv("MINIO_CA_CERT"))
if err != nil {
log.Fatalln(err)
}
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
opts.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
TLSClientConfig: &tls.Config{
RootCAs: caCertPool,
},
}
}
s3Clients[name], err = minio.New(endpoint, opts)
Expand Down

0 comments on commit 4d6dc8f

Please sign in to comment.