Skip to content

Commit

Permalink
chore: redis tls in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrn committed Oct 30, 2024
1 parent 8187e2e commit 275775b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions sibylla_service/pkg/redisclient/redisclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package redisclient

import (
"context"
"crypto/tls"
"log"
"os"
"time"

"github.com/go-redis/redis/v8"
Expand All @@ -15,10 +17,19 @@ type RedisClient struct {
}

func NewRedisClient(addr, password string, db int) *RedisClient {
var tlsConfig *tls.Config
if os.Getenv("ENV") == "production" {
// Create a custom TLS configuration
tlsConfig = &tls.Config{
InsecureSkipVerify: true, // Set to false in production for better security
}
}

rdb := redis.NewClient(&redis.Options{
Addr: addr,
Password: password,
DB: db,
Addr: addr,
Password: password,
DB: db,
TLSConfig: tlsConfig,
})

// Test the connection
Expand Down

0 comments on commit 275775b

Please sign in to comment.