File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -35,24 +35,22 @@ type TLS struct {
3535}
3636
3737func setupTLS (cfg * TLS ) (* tls.Config , error ) {
38- var caCert []byte
38+ tlsClientConfig := & tls.Config {
39+ InsecureSkipVerify : cfg .InsecureSkipVerify ,
40+ ServerName : cfg .ServerName ,
41+ }
3942
4043 if len (cfg .CaFile ) > 0 {
4144 readFile , err := ioutil .ReadFile (cfg .CaFile )
4245 if err != nil {
4346 return nil , err
4447 }
45- caCert = readFile
46- }
4748
48- tlsClientConfig := & tls.Config {
49- InsecureSkipVerify : cfg .InsecureSkipVerify ,
50- ServerName : cfg .ServerName ,
51- }
52- if len (cfg .KeyFile ) > 0 && len (cfg .CertFile ) > 0 {
5349 tlsClientConfig .RootCAs = x509 .NewCertPool ()
54- tlsClientConfig .RootCAs .AppendCertsFromPEM (caCert )
50+ tlsClientConfig .RootCAs .AppendCertsFromPEM (readFile )
51+ }
5552
53+ if len (cfg .KeyFile ) > 0 && len (cfg .CertFile ) > 0 {
5654 cert , err := tls .LoadX509KeyPair (cfg .CertFile , cfg .KeyFile )
5755 if err != nil {
5856 return nil , fmt .Errorf ("could not read client certificate or key: %w" , err )
You can’t perform that action at this time.
0 commit comments