Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new method to access a client config's TLSConfig. #20265

Merged
merged 3 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ type Config struct {
// commands such as 'vault operator raft snapshot' as this redirects to the
// primary node.
DisableRedirects bool
clientTLSConfig *tls.Config
}

// TLSConfig contains the parameters needed to configure TLS on the HTTP client
Expand Down Expand Up @@ -337,10 +338,15 @@ func (c *Config) configureTLS(t *TLSConfig) error {
if t.TLSServerName != "" {
clientTLSConfig.ServerName = t.TLSServerName
}
c.clientTLSConfig = clientTLSConfig

return nil
}

func (c *Config) TLSConfig() *tls.Config {
return c.clientTLSConfig.Clone()
ncabatoff marked this conversation as resolved.
Show resolved Hide resolved
}

// ConfigureTLS takes a set of TLS configurations and applies those to the
// HTTP client.
func (c *Config) ConfigureTLS(t *TLSConfig) error {
Expand Down Expand Up @@ -665,6 +671,7 @@ func (c *Client) CloneConfig() *Config {
newConfig.CloneHeaders = c.config.CloneHeaders
newConfig.CloneToken = c.config.CloneToken
newConfig.ReadYourWrites = c.config.ReadYourWrites
newConfig.clientTLSConfig = c.config.clientTLSConfig

// we specifically want a _copy_ of the client here, not a pointer to the original one
newClient := *c.config.HttpClient
Expand Down
3 changes: 3 additions & 0 deletions changelog/20265.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
* api: Add Config.TLSConfig method to fetch the TLS configuration from a client config.
```