diff --git a/cmd/kubeadm/app/phases/certs/certs_test.go b/cmd/kubeadm/app/phases/certs/certs_test.go index 446f0ab35fe..08122d18707 100644 --- a/cmd/kubeadm/app/phases/certs/certs_test.go +++ b/cmd/kubeadm/app/phases/certs/certs_test.go @@ -17,7 +17,9 @@ limitations under the License. package certs import ( + "crypto" "crypto/rsa" + "crypto/tls" "crypto/x509" "fmt" "net" @@ -803,3 +805,17 @@ func TestCreateCertificateFilesMethods(t *testing.T) { testutil.AssertFileExists(t, tmpdir, test.expectedFiles...) } } + +func parseCertAndKey(basePath string, t *testing.T) (*x509.Certificate, crypto.PrivateKey) { + certPair, err := tls.LoadX509KeyPair(basePath+".crt", basePath+".key") + if err != nil { + t.Fatalf("couldn't parse certificate and key: %v", err) + } + + parsedCert, err := x509.ParseCertificate(certPair.Certificate[0]) + if err != nil { + t.Fatalf("couldn't parse certificate: %v", err) + } + + return parsedCert, certPair.PrivateKey +}