mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Merge pull request #125636 from my-git9/certsunused
kubeadm: Remove unused function in phases/certs
This commit is contained in:
commit
10ae1dbb52
@ -129,16 +129,6 @@ func CreateCACertAndKeyFiles(certSpec *KubeadmCert, cfg *kubeadmapi.InitConfigur
|
||||
)
|
||||
}
|
||||
|
||||
// NewCSR will generate a new CSR and accompanying key
|
||||
func NewCSR(certSpec *KubeadmCert, cfg *kubeadmapi.InitConfiguration) (*x509.CertificateRequest, crypto.Signer, error) {
|
||||
certConfig, err := certSpec.GetConfig(cfg)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "failed to retrieve cert configuration")
|
||||
}
|
||||
|
||||
return pkiutil.NewCSRAndKey(certConfig)
|
||||
}
|
||||
|
||||
// CreateCertAndKeyFilesWithCA loads the given certificate authority from disk, then generates and writes out the given certificate and key.
|
||||
// The certSpec and caCertSpec should both be one of the variables from this package.
|
||||
func CreateCertAndKeyFilesWithCA(certSpec *KubeadmCert, caCertSpec *KubeadmCert, cfg *kubeadmapi.InitConfiguration) error {
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
certutil "k8s.io/client-go/util/cert"
|
||||
@ -638,38 +637,6 @@ func TestValidateMethods(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewCSR(t *testing.T) {
|
||||
kubeadmCert := KubeadmCertAPIServer()
|
||||
cfg := testutil.GetDefaultInternalConfig(t)
|
||||
|
||||
certConfig, err := kubeadmCert.GetConfig(cfg)
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't get cert config: %v", err)
|
||||
}
|
||||
|
||||
csr, _, err := NewCSR(kubeadmCert, cfg)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("invalid signature on CSR: %v", err)
|
||||
}
|
||||
|
||||
assert.ElementsMatch(t, certConfig.Organization, csr.Subject.Organization, "organizations not equal")
|
||||
|
||||
if csr.Subject.CommonName != certConfig.CommonName {
|
||||
t.Errorf("expected common name %q, got %q", certConfig.CommonName, csr.Subject.CommonName)
|
||||
}
|
||||
|
||||
assert.ElementsMatch(t, certConfig.AltNames.DNSNames, csr.DNSNames, "dns names not equal")
|
||||
|
||||
assert.Len(t, csr.IPAddresses, len(certConfig.AltNames.IPs))
|
||||
|
||||
for i, ip := range csr.IPAddresses {
|
||||
if !ip.Equal(certConfig.AltNames.IPs[i]) {
|
||||
t.Errorf("[%d]: %v != %v", i, ip, certConfig.AltNames.IPs[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateCertificateFilesMethods(t *testing.T) {
|
||||
|
||||
var tests = []struct {
|
||||
|
Loading…
Reference in New Issue
Block a user