@@ -17,6 +17,7 @@ import (
17
17
"github.com/redis/go-redis/v9/internal/pool"
18
18
"github.com/redis/go-redis/v9/internal/rand"
19
19
"github.com/redis/go-redis/v9/push"
20
+ "github.com/redis/go-redis/v9/internal/util"
20
21
)
21
22
22
23
//------------------------------------------------------------------------------
@@ -274,6 +275,7 @@ func (opt *FailoverOptions) clusterOptions() *ClusterOptions {
274
275
// URL attributes (scheme, host, userinfo, resp.), query parameters using these
275
276
// names will be treated as unknown parameters
276
277
// - unknown parameter names will result in an error
278
+ // - use "skip_verify=true" to ignore TLS certificate validation
277
279
//
278
280
// Example:
279
281
//
@@ -381,6 +383,10 @@ func setupFailoverConnParams(u *url.URL, o *FailoverOptions) (*FailoverOptions,
381
383
o .SentinelAddrs = append (o .SentinelAddrs , net .JoinHostPort (h , p ))
382
384
}
383
385
386
+ if o .TLSConfig != nil && q .has ("skip_verify" ) {
387
+ o .TLSConfig .InsecureSkipVerify = q .bool ("skip_verify" )
388
+ }
389
+
384
390
// any parameters left?
385
391
if r := q .remaining (); len (r ) > 0 {
386
392
return nil , fmt .Errorf ("redis: unexpected option: %s" , strings .Join (r , ", " ))
@@ -806,7 +812,20 @@ func (c *sentinelFailover) MasterAddr(ctx context.Context) (string, error) {
806
812
for err := range errCh {
807
813
errs = append (errs , err )
808
814
}
809
- return "" , fmt .Errorf ("redis: all sentinels specified in configuration are unreachable: %w" , errors .Join (errs ... ))
815
+ return "" , fmt .Errorf ("redis: all sentinels specified in configuration are unreachable: %s" , joinErrors (errs ))
816
+ }
817
+
818
+ func joinErrors (errs []error ) string {
819
+ if len (errs ) == 1 {
820
+ return errs [0 ].Error ()
821
+ }
822
+
823
+ b := []byte (errs [0 ].Error ())
824
+ for _ , err := range errs [1 :] {
825
+ b = append (b , '\n' )
826
+ b = append (b , err .Error ()... )
827
+ }
828
+ return util .BytesToString (b )
810
829
}
811
830
812
831
func (c * sentinelFailover ) replicaAddrs (ctx context.Context , useDisconnected bool ) ([]string , error ) {
0 commit comments