Skip to content

Commit

Permalink
Add configuration to specify a TLS ServerName to use in the TLS hands…
Browse files Browse the repository at this point in the history
…hake when performing a raft join. (#10698) (#10731)
  • Loading branch information
ncabatoff committed Jan 19, 2021
1 parent 9b7b2f5 commit 6e6834c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
20 changes: 11 additions & 9 deletions http/sys_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func handleSysRaftJoinPost(core *vault.Core, w http.ResponseWriter, r *http.Requ
respondError(w, http.StatusBadRequest, err)
return
}
tlsConfig.ServerName = req.LeaderTLSServerName
}

if req.AutoJoinScheme != "" && (req.AutoJoinScheme != "http" && req.AutoJoinScheme != "https") {
Expand Down Expand Up @@ -99,13 +100,14 @@ type JoinResponse struct {
}

type JoinRequest struct {
AutoJoin string `json:"auto_join"`
AutoJoinScheme string `json:"auto_join_scheme"`
AutoJoinPort uint `json:"auto_join_port"`
LeaderAPIAddr string `json:"leader_api_addr"`
LeaderCACert string `json:"leader_ca_cert"`
LeaderClientCert string `json:"leader_client_cert"`
LeaderClientKey string `json:"leader_client_key"`
Retry bool `json:"retry"`
NonVoter bool `json:"non_voter"`
AutoJoin string `json:"auto_join"`
AutoJoinScheme string `json:"auto_join_scheme"`
AutoJoinPort uint `json:"auto_join_port"`
LeaderAPIAddr string `json:"leader_api_addr"`
LeaderCACert string `json:"leader_ca_cert"`
LeaderClientCert string `json:"leader_client_cert"`
LeaderClientKey string `json:"leader_client_key"`
LeaderTLSServerName string `json:"leader_tls_servername"`
Retry bool `json:"retry"`
NonVoter bool `json:"non_voter"`
}
5 changes: 5 additions & 0 deletions physical/raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ type LeaderJoinInfo struct {
// only be provided via Vault's configuration file.
LeaderClientKeyFile string `json:"leader_client_key_file"`

// LeaderTLSServerName is the optional ServerName to expect in the leader's
// certificate, instead of the host/IP we're actually connecting to.
LeaderTLSServerName string `json:"leader_tls_servername"`

// Retry indicates if the join process should automatically be retried
Retry bool `json:"-"`

Expand Down Expand Up @@ -226,6 +230,7 @@ func parseTLSInfo(leaderInfo *LeaderJoinInfo) (*tls.Config, error) {
return nil, err
}
}
tlsConfig.ServerName = leaderInfo.LeaderTLSServerName

return tlsConfig, nil
}
Expand Down
1 change: 1 addition & 0 deletions vault/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ func (c *Core) JoinRaftCluster(ctx context.Context, leaderInfos []*raft.LeaderJo
if err != nil {
return errwrap.Wrapf("failed to create TLS config: {{err}}", err)
}
leaderInfo.TLSConfig.ServerName = leaderInfo.LeaderTLSServerName
}

if leaderInfo.TLSConfig != nil {
Expand Down

0 comments on commit 6e6834c

Please sign in to comment.