@@ -16,6 +16,7 @@ import (
16
16
"github.com/redis/go-redis/v9/internal"
17
17
"github.com/redis/go-redis/v9/internal/pool"
18
18
"github.com/redis/go-redis/v9/internal/rand"
19
+ "github.com/redis/go-redis/v9/internal/util"
19
20
)
20
21
21
22
//------------------------------------------------------------------------------
@@ -271,6 +272,7 @@ func (opt *FailoverOptions) clusterOptions() *ClusterOptions {
271
272
// URL attributes (scheme, host, userinfo, resp.), query parameters using these
272
273
// names will be treated as unknown parameters
273
274
// - unknown parameter names will result in an error
275
+ // - use "skip_verify=true" to ignore TLS certificate validation
274
276
//
275
277
// Example:
276
278
//
@@ -378,6 +380,10 @@ func setupFailoverConnParams(u *url.URL, o *FailoverOptions) (*FailoverOptions,
378
380
o .SentinelAddrs = append (o .SentinelAddrs , net .JoinHostPort (h , p ))
379
381
}
380
382
383
+ if o .TLSConfig != nil && q .has ("skip_verify" ) {
384
+ o .TLSConfig .InsecureSkipVerify = q .bool ("skip_verify" )
385
+ }
386
+
381
387
// any parameters left?
382
388
if r := q .remaining (); len (r ) > 0 {
383
389
return nil , fmt .Errorf ("redis: unexpected option: %s" , strings .Join (r , ", " ))
@@ -782,7 +788,20 @@ func (c *sentinelFailover) MasterAddr(ctx context.Context) (string, error) {
782
788
for err := range errCh {
783
789
errs = append (errs , err )
784
790
}
785
- return "" , fmt .Errorf ("redis: all sentinels specified in configuration are unreachable: %w" , errors .Join (errs ... ))
791
+ return "" , fmt .Errorf ("redis: all sentinels specified in configuration are unreachable: %s" , joinErrors (errs ))
792
+ }
793
+
794
+ func joinErrors (errs []error ) string {
795
+ if len (errs ) == 1 {
796
+ return errs [0 ].Error ()
797
+ }
798
+
799
+ b := []byte (errs [0 ].Error ())
800
+ for _ , err := range errs [1 :] {
801
+ b = append (b , '\n' )
802
+ b = append (b , err .Error ()... )
803
+ }
804
+ return util .BytesToString (b )
786
805
}
787
806
788
807
func (c * sentinelFailover ) replicaAddrs (ctx context.Context , useDisconnected bool ) ([]string , error ) {
0 commit comments