Add certlist.go - a declarative list of all certs kubeadm requires

* Sub out New*CertAndKey for functions using the new certlist
This commit is contained in:
liz 2018-08-09 15:14:05 -04:00
parent 742b258ca2
commit f5e9eb8674
No known key found for this signature in database
GPG Key ID: 42D1F3A8C4A02586

View File

@ -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
}