mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
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:
parent
742b258ca2
commit
f5e9eb8674
@ -17,7 +17,9 @@ limitations under the License.
|
|||||||
package certs
|
package certs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
@ -803,3 +805,17 @@ func TestCreateCertificateFilesMethods(t *testing.T) {
|
|||||||
testutil.AssertFileExists(t, tmpdir, test.expectedFiles...)
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user