11package auth
22
33import (
4+ "crypto/tls"
45 "errors"
56 "fmt"
67 "math/rand"
@@ -75,13 +76,13 @@ func (a *State) IsExpired() bool {
7576}
7677
7778func QueryAnyAuthd (authd []string , remoteIP string , tlsEnabled bool , commonName string , authSecret string ,
78- connectTimeout time.Duration , requestTimeout time.Duration ) (* State , error ) {
79+ clientTLSConfig * tls. Config , connectTimeout time.Duration , requestTimeout time.Duration ) (* State , error ) {
7980 var retErr error
8081 start := rand .Int ()
8182 n := len (authd )
8283 for i := 0 ; i < n ; i ++ {
8384 a := authd [(i + start )% n ]
84- authState , err := QueryAuthd (a , remoteIP , tlsEnabled , commonName , authSecret , connectTimeout , requestTimeout )
85+ authState , err := QueryAuthd (a , remoteIP , tlsEnabled , commonName , authSecret , clientTLSConfig , connectTimeout , requestTimeout )
8586 if err != nil {
8687 es := fmt .Sprintf ("failed to auth against %s - %s" , a , err )
8788 if retErr != nil {
@@ -96,7 +97,7 @@ func QueryAnyAuthd(authd []string, remoteIP string, tlsEnabled bool, commonName
9697}
9798
9899func QueryAuthd (authd string , remoteIP string , tlsEnabled bool , commonName string , authSecret string ,
99- connectTimeout time.Duration , requestTimeout time.Duration ) (* State , error ) {
100+ clientTLSConfig * tls. Config , connectTimeout time.Duration , requestTimeout time.Duration ) (* State , error ) {
100101 v := url.Values {}
101102 v .Set ("remote_ip" , remoteIP )
102103 if tlsEnabled {
@@ -115,7 +116,7 @@ func QueryAuthd(authd string, remoteIP string, tlsEnabled bool, commonName strin
115116 }
116117
117118 var authState State
118- client := http_api .NewClient (nil , connectTimeout , requestTimeout )
119+ client := http_api .NewClient (clientTLSConfig , connectTimeout , requestTimeout )
119120 if err := client .GETV1 (endpoint , & authState ); err != nil {
120121 return nil , err
121122 }
0 commit comments