in client/internal/kubeconfig/validator.go [102:124]
func validateClientConfig(clientConfig *restclient.Config) error {
transportConfig, err := clientConfig.TransportConfig()
if err != nil {
return fmt.Errorf("unable to load transport configuration from existing kubeconfig: %w", err)
}
if _, err := transport.TLSConfigFor(transportConfig); err != nil {
return fmt.Errorf("unable to load TLS configuration from existing kubeconfig: %w", err)
}
certs, err := certutil.ParseCertsPEM(transportConfig.TLS.CertData)
if err != nil {
return fmt.Errorf("unable to load TLS certificates from existing kubeconfig: %w", err)
}
if len(certs) == 0 {
return fmt.Errorf("no client certificates found within kubeconfig")
}
now := time.Now()
for _, cert := range certs {
if now.After(cert.NotAfter) {
return fmt.Errorf("some part of the existing kubeconfig certificate has expired")
}
}
return nil
}