go.mod: bump client-go and api machinerie
I had to run `make generate`. Some API functions got additional parameters `Options` and `Context`. I used empty options and `context.TODO()` for now. Signed-off-by: leonnicolas <leonloechner@gmx.de>
This commit is contained in:
		
							
								
								
									
										6
									
								
								vendor/k8s.io/client-go/util/cert/cert.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/k8s.io/client-go/util/cert/cert.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -28,7 +28,7 @@ import ( | ||||
| 	"io/ioutil" | ||||
| 	"math/big" | ||||
| 	"net" | ||||
| 	"path" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| @@ -96,8 +96,8 @@ func GenerateSelfSignedCertKeyWithFixtures(host string, alternateIPs []net.IP, a | ||||
| 	maxAge := time.Hour * 24 * 365          // one year self-signed certs | ||||
|  | ||||
| 	baseName := fmt.Sprintf("%s_%s_%s", host, strings.Join(ipsToStrings(alternateIPs), "-"), strings.Join(alternateDNS, "-")) | ||||
| 	certFixturePath := path.Join(fixtureDirectory, baseName+".crt") | ||||
| 	keyFixturePath := path.Join(fixtureDirectory, baseName+".key") | ||||
| 	certFixturePath := filepath.Join(fixtureDirectory, baseName+".crt") | ||||
| 	keyFixturePath := filepath.Join(fixtureDirectory, baseName+".key") | ||||
| 	if len(fixtureDirectory) > 0 { | ||||
| 		cert, err := ioutil.ReadFile(certFixturePath) | ||||
| 		if err == nil { | ||||
|   | ||||
							
								
								
									
										17
									
								
								vendor/k8s.io/client-go/util/cert/io.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								vendor/k8s.io/client-go/util/cert/io.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -72,7 +72,22 @@ func WriteCert(certPath string, data []byte) error { | ||||
| // NewPool returns an x509.CertPool containing the certificates in the given PEM-encoded file. | ||||
| // Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates | ||||
| func NewPool(filename string) (*x509.CertPool, error) { | ||||
| 	certs, err := CertsFromFile(filename) | ||||
| 	pemBlock, err := ioutil.ReadFile(filename) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	pool, err := NewPoolFromBytes(pemBlock) | ||||
| 	if err != nil { | ||||
| 		return nil, fmt.Errorf("error creating pool from %s: %s", filename, err) | ||||
| 	} | ||||
| 	return pool, nil | ||||
| } | ||||
|  | ||||
| // NewPoolFromBytes returns an x509.CertPool containing the certificates in the given PEM-encoded bytes. | ||||
| // Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates | ||||
| func NewPoolFromBytes(pemBlock []byte) (*x509.CertPool, error) { | ||||
| 	certs, err := ParseCertsPEM(pemBlock) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/k8s.io/client-go/util/cert/pem.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/k8s.io/client-go/util/cert/pem.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -17,6 +17,7 @@ limitations under the License. | ||||
| package cert | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"crypto/x509" | ||||
| 	"encoding/pem" | ||||
| 	"errors" | ||||
| @@ -59,3 +60,14 @@ func ParseCertsPEM(pemCerts []byte) ([]*x509.Certificate, error) { | ||||
| 	} | ||||
| 	return certs, nil | ||||
| } | ||||
|  | ||||
| // EncodeCertificates returns the PEM-encoded byte array that represents by the specified certs. | ||||
| func EncodeCertificates(certs ...*x509.Certificate) ([]byte, error) { | ||||
| 	b := bytes.Buffer{} | ||||
| 	for _, cert := range certs { | ||||
| 		if err := pem.Encode(&b, &pem.Block{Type: CertificateBlockType, Bytes: cert.Raw}); err != nil { | ||||
| 			return []byte{}, err | ||||
| 		} | ||||
| 	} | ||||
| 	return b.Bytes(), nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										102
									
								
								vendor/k8s.io/client-go/util/cert/server_inspection.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								vendor/k8s.io/client-go/util/cert/server_inspection.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,102 @@ | ||||
| /* | ||||
| Copyright 2019 The Kubernetes Authors. | ||||
|  | ||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| you may not use this file except in compliance with the License. | ||||
| You may obtain a copy of the License at | ||||
|  | ||||
|     http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  | ||||
| Unless required by applicable law or agreed to in writing, software | ||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| See the License for the specific language governing permissions and | ||||
| limitations under the License. | ||||
| */ | ||||
|  | ||||
| package cert | ||||
|  | ||||
| import ( | ||||
| 	"crypto/tls" | ||||
| 	"crypto/x509" | ||||
| 	"fmt" | ||||
| 	"net/url" | ||||
| 	"strings" | ||||
| ) | ||||
|  | ||||
| // GetClientCANames gets the CA names for client certs that a server accepts.  This is useful when inspecting the | ||||
| // state of particular servers.  apiHost is "host:port" | ||||
| func GetClientCANames(apiHost string) ([]string, error) { | ||||
| 	// when we run this the second time, we know which one we are expecting | ||||
| 	acceptableCAs := []string{} | ||||
| 	tlsConfig := &tls.Config{ | ||||
| 		InsecureSkipVerify: true, // this is insecure to always get to the GetClientCertificate | ||||
| 		GetClientCertificate: func(hello *tls.CertificateRequestInfo) (*tls.Certificate, error) { | ||||
| 			acceptableCAs = []string{} | ||||
| 			for _, curr := range hello.AcceptableCAs { | ||||
| 				acceptableCAs = append(acceptableCAs, string(curr)) | ||||
| 			} | ||||
| 			return &tls.Certificate{}, nil | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	conn, err := tls.Dial("tcp", apiHost, tlsConfig) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := conn.Close(); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	return acceptableCAs, nil | ||||
| } | ||||
|  | ||||
| // GetClientCANamesForURL is GetClientCANames against a URL string like we use in kubeconfigs | ||||
| func GetClientCANamesForURL(kubeConfigURL string) ([]string, error) { | ||||
| 	apiserverURL, err := url.Parse(kubeConfigURL) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return GetClientCANames(apiserverURL.Host) | ||||
| } | ||||
|  | ||||
| // GetServingCertificates returns the x509 certs used by a server as certificates and pem encoded bytes. | ||||
| // The serverName is optional for specifying a different name to get SNI certificates.  apiHost is "host:port" | ||||
| func GetServingCertificates(apiHost, serverName string) ([]*x509.Certificate, [][]byte, error) { | ||||
| 	tlsConfig := &tls.Config{ | ||||
| 		InsecureSkipVerify: true, // this is insecure so that we always get connected | ||||
| 	} | ||||
| 	// if a name is specified for SNI, set it. | ||||
| 	if len(serverName) > 0 { | ||||
| 		tlsConfig.ServerName = serverName | ||||
| 	} | ||||
|  | ||||
| 	conn, err := tls.Dial("tcp", apiHost, tlsConfig) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	if err = conn.Close(); err != nil { | ||||
| 		return nil, nil, fmt.Errorf("failed to close connection : %v", err) | ||||
| 	} | ||||
|  | ||||
| 	peerCerts := conn.ConnectionState().PeerCertificates | ||||
| 	peerCertBytes := [][]byte{} | ||||
| 	for _, a := range peerCerts { | ||||
| 		actualCert, err := EncodeCertificates(a) | ||||
| 		if err != nil { | ||||
| 			return nil, nil, err | ||||
| 		} | ||||
| 		peerCertBytes = append(peerCertBytes, []byte(strings.TrimSpace(string(actualCert)))) | ||||
| 	} | ||||
|  | ||||
| 	return peerCerts, peerCertBytes, err | ||||
| } | ||||
|  | ||||
| // GetServingCertificatesForURL is GetServingCertificates against a URL string like we use in kubeconfigs | ||||
| func GetServingCertificatesForURL(kubeConfigURL, serverName string) ([]*x509.Certificate, [][]byte, error) { | ||||
| 	apiserverURL, err := url.Parse(kubeConfigURL) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 	return GetServingCertificates(apiserverURL.Host, serverName) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user