newTLSConfig constructs a client TLS configuration based on server defaults
(ctx context.Context, hostname string, isSecure bool)
| 33 | |
| 34 | // newTLSConfig constructs a client TLS configuration based on server defaults |
| 35 | func newTLSConfig(ctx context.Context, hostname string, isSecure bool) (*tls.Config, error) { |
| 36 | // PreferredServerCipherSuites should have no effect |
| 37 | tlsConfig := tlsconfig.ServerDefault() |
| 38 | tlsConfig.InsecureSkipVerify = !isSecure |
| 39 | |
| 40 | if isSecure { |
| 41 | hostDir := hostCertsDir(hostname) |
| 42 | log.G(ctx).Debugf("hostDir: %s", hostDir) |
| 43 | if err := loadTLSConfig(ctx, hostDir, tlsConfig); err != nil { |
| 44 | return nil, err |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | return tlsConfig, nil |
| 49 | } |
| 50 | |
| 51 | func hasFile(files []os.DirEntry, name string) bool { |
| 52 | for _, f := range files { |
no test coverage detected
searching dependent graphs…