From 8986d6b66cb5bcb9571764311cae9bd68d693653 Mon Sep 17 00:00:00 2001 From: Andrew Lytvynov Date: Tue, 13 Nov 2018 10:26:43 -0800 Subject: [PATCH] Remove unused funcs in certutil Kubernetes-commit: 162b3642921ef18a2f5d5489f034409936c42e27 --- util/cert/cert.go | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/util/cert/cert.go b/util/cert/cert.go index 0e160dab..3429c82c 100644 --- a/util/cert/cert.go +++ b/util/cert/cert.go @@ -260,34 +260,6 @@ func GenerateSelfSignedCertKeyWithFixtures(host string, alternateIPs []net.IP, a return certBuffer.Bytes(), keyBuffer.Bytes(), nil } -// FormatBytesCert receives byte array certificate and formats in human-readable format -func FormatBytesCert(cert []byte) (string, error) { - block, _ := pem.Decode(cert) - c, err := x509.ParseCertificate(block.Bytes) - if err != nil { - return "", fmt.Errorf("failed to parse certificate [%v]", err) - } - return FormatCert(c), nil -} - -// FormatCert receives certificate and formats in human-readable format -func FormatCert(c *x509.Certificate) string { - var ips []string - for _, ip := range c.IPAddresses { - ips = append(ips, ip.String()) - } - altNames := append(ips, c.DNSNames...) - res := fmt.Sprintf( - "Issuer: CN=%s | Subject: CN=%s | CA: %t\n", - c.Issuer.CommonName, c.Subject.CommonName, c.IsCA, - ) - res += fmt.Sprintf("Not before: %s Not After: %s", c.NotBefore, c.NotAfter) - if len(altNames) > 0 { - res += fmt.Sprintf("\nAlternate Names: %v", altNames) - } - return res -} - func ipsToStrings(ips []net.IP) []string { ss := make([]string, 0, len(ips)) for _, ip := range ips {