code: func fillCertFromLeaf(cert *Certificate, leaf *x509.Certificate) error {
  	if leaf.Subject.CommonName != "" {
  		cert.Names = []string{strings.ToLower(leaf.Subject.CommonName)}
  	}
  	for _, name := range leaf.DNSNames {
  		if name != leaf.Subject.CommonName {
  			cert.Names = append(cert.Names, strings.ToLower(name))
  		}
  	}
  	for _, ip := range leaf.IPAddresses {
  		if ipStr := ip.String(); ipStr != leaf.Subject.CommonName {
  			cert.Names = append(cert.Names, strings.ToLower(ipStr))
  		}
  	}
  	for _, email := range leaf.EmailAddresses {
  		if email != leaf.Subject.CommonName {
  			cert.Names = append(cert.Names, strings.ToLower(email))
  		}
  	}
  	if len(cert.Names) == 0 {
  		return errors.New("certificate has no names")
  	}
  	cert.NotAfter = leaf.NotAfter
  	return nil
  }
docs: // fillCertFromLeaf populates cert.Names and cert.NotAfter
  // using data in leaf.