mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	Supports additional options for CreateDataset and DeleteDataset for dynamic provisioning. Bugfix for timeouts during CreateDataset
		
			
				
	
	
		
			35 lines
		
	
	
		
			743 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			743 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package flocker
 | 
						|
 | 
						|
import (
 | 
						|
	"crypto/tls"
 | 
						|
	"crypto/x509"
 | 
						|
	"io/ioutil"
 | 
						|
	"net/http"
 | 
						|
)
 | 
						|
 | 
						|
// newTLSClient returns a new TLS http client
 | 
						|
func newTLSClient(caCertPath, keyPath, certPath string) (*http.Client, error) {
 | 
						|
	// Client certificate
 | 
						|
	cert, err := tls.LoadX509KeyPair(certPath, keyPath)
 | 
						|
	if err != nil {
 | 
						|
		return nil, err
 | 
						|
	}
 | 
						|
 | 
						|
	// CA certificate
 | 
						|
	caCert, err := ioutil.ReadFile(caCertPath)
 | 
						|
	if err != nil {
 | 
						|
		return nil, err
 | 
						|
	}
 | 
						|
	caCertPool := x509.NewCertPool()
 | 
						|
	caCertPool.AppendCertsFromPEM(caCert)
 | 
						|
 | 
						|
	tlsConfig := &tls.Config{
 | 
						|
		Certificates: []tls.Certificate{cert},
 | 
						|
		RootCAs:      caCertPool,
 | 
						|
	}
 | 
						|
	tlsConfig.BuildNameToCertificate()
 | 
						|
	transport := &http.Transport{TLSClientConfig: tlsConfig}
 | 
						|
 | 
						|
	return &http.Client{Transport: transport}, nil
 | 
						|
}
 |