mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 02:28:09 +00:00 
			
		
		
		
	plugins/cassandra: add tls_server_name (#11820)
* db/cassandra: add tls_server_name * Remove changes from deprecated engine
This commit is contained in:
		| @@ -27,6 +27,7 @@ type cassandraConnectionProducer struct { | |||||||
| 	Password           string      `json:"password" structs:"password" mapstructure:"password"` | 	Password           string      `json:"password" structs:"password" mapstructure:"password"` | ||||||
| 	TLS                bool        `json:"tls" structs:"tls" mapstructure:"tls"` | 	TLS                bool        `json:"tls" structs:"tls" mapstructure:"tls"` | ||||||
| 	InsecureTLS        bool        `json:"insecure_tls" structs:"insecure_tls" mapstructure:"insecure_tls"` | 	InsecureTLS        bool        `json:"insecure_tls" structs:"insecure_tls" mapstructure:"insecure_tls"` | ||||||
|  | 	TLSServerName      string      `json:"tls_server_name" structs:"tls_server_name" mapstructure:"tls_server_name"` | ||||||
| 	ProtocolVersion    int         `json:"protocol_version" structs:"protocol_version" mapstructure:"protocol_version"` | 	ProtocolVersion    int         `json:"protocol_version" structs:"protocol_version" mapstructure:"protocol_version"` | ||||||
| 	ConnectTimeoutRaw  interface{} `json:"connect_timeout" structs:"connect_timeout" mapstructure:"connect_timeout"` | 	ConnectTimeoutRaw  interface{} `json:"connect_timeout" structs:"connect_timeout" mapstructure:"connect_timeout"` | ||||||
| 	SocketKeepAliveRaw interface{} `json:"socket_keep_alive" structs:"socket_keep_alive" mapstructure:"socket_keep_alive"` | 	SocketKeepAliveRaw interface{} `json:"socket_keep_alive" structs:"socket_keep_alive" mapstructure:"socket_keep_alive"` | ||||||
| @@ -184,7 +185,7 @@ func (c *cassandraConnectionProducer) createSession(ctx context.Context) (*gocql | |||||||
| 	clusterConfig.SocketKeepalive = c.socketKeepAlive | 	clusterConfig.SocketKeepalive = c.socketKeepAlive | ||||||
|  |  | ||||||
| 	if c.TLS { | 	if c.TLS { | ||||||
| 		sslOpts, err := getSslOpts(c.certBundle, c.TLSMinVersion, c.InsecureTLS) | 		sslOpts, err := getSslOpts(c.certBundle, c.TLSMinVersion, c.TLSServerName, c.InsecureTLS) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, err | 			return nil, err | ||||||
| 		} | 		} | ||||||
| @@ -230,7 +231,7 @@ func (c *cassandraConnectionProducer) createSession(ctx context.Context) (*gocql | |||||||
| 	return session, nil | 	return session, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func getSslOpts(certBundle *certutil.CertBundle, minTLSVersion string, insecureSkipVerify bool) (*gocql.SslOptions, error) { | func getSslOpts(certBundle *certutil.CertBundle, minTLSVersion, serverName string, insecureSkipVerify bool) (*gocql.SslOptions, error) { | ||||||
| 	tlsConfig := &tls.Config{} | 	tlsConfig := &tls.Config{} | ||||||
| 	if certBundle != nil { | 	if certBundle != nil { | ||||||
| 		if certBundle.Certificate == "" && certBundle.PrivateKey != "" { | 		if certBundle.Certificate == "" && certBundle.PrivateKey != "" { | ||||||
| @@ -253,6 +254,10 @@ func getSslOpts(certBundle *certutil.CertBundle, minTLSVersion string, insecureS | |||||||
|  |  | ||||||
| 	tlsConfig.InsecureSkipVerify = insecureSkipVerify | 	tlsConfig.InsecureSkipVerify = insecureSkipVerify | ||||||
|  |  | ||||||
|  | 	if serverName != "" { | ||||||
|  | 		tlsConfig.ServerName = serverName | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	if minTLSVersion != "" { | 	if minTLSVersion != "" { | ||||||
| 		var ok bool | 		var ok bool | ||||||
| 		tlsConfig.MinVersion, ok = tlsutil.TLSLookup[minTLSVersion] | 		tlsConfig.MinVersion, ok = tlsutil.TLSLookup[minTLSVersion] | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jason O'Donnell
					Jason O'Donnell