예제 #1
0
func (lk LocalkubeServer) shouldGenerateCerts(ips []net.IP) bool {
	if !(util.CanReadFile(lk.GetPublicKeyCertPath()) &&
		util.CanReadFile(lk.GetPrivateKeyCertPath())) {
		fmt.Println("Regenerating certs because the files aren't readable")
		return true
	}

	cert, err := lk.loadCert(lk.GetPublicKeyCertPath())
	if err != nil {
		fmt.Println("Regenerating certs because there was an error loading the certificate: ", err)
		return true
	}

	certIPs := map[string]bool{}
	for _, certIP := range cert.IPAddresses {
		certIPs[certIP.String()] = true
	}

	for _, ip := range ips {
		if _, ok := certIPs[ip.String()]; !ok {
			fmt.Println("Regenerating certs becase an IP is missing: ", ip)
			return true
		}
	}
	return false
}
예제 #2
0
func GenerateCerts(caCert, caKey, pub, priv string, ip net.IP) error {
	if !(util.CanReadFile(caCert) && util.CanReadFile(caKey)) {
		if err := util.GenerateCACert(caCert, caKey); err != nil {
			return err
		}
	}

	ips := []net.IP{ip, internalIP}
	if err := util.GenerateSignedCert(pub, priv, ips, util.GetAlternateDNS(util.DefaultDNSDomain), caCert, caKey); err != nil {
		return err
	}
	return nil
}
예제 #3
0
func (lk LocalkubeServer) shouldGenerateCACerts() bool {
	if !(util.CanReadFile(lk.GetCAPublicKeyCertPath()) &&
		util.CanReadFile(lk.GetCAPrivateKeyCertPath())) {
		fmt.Println("Regenerating CA certs because the files aren't readable")
		return true
	}

	_, err := lk.loadCert(lk.GetCAPublicKeyCertPath())
	if err != nil {
		fmt.Println("Regenerating CA certs because there was an error loading the certificate: ", err)
		return true
	}

	return false
}