Skip to content

Commit

Permalink
Bug 2097830: macOS: certificate is untrusted error
Browse files Browse the repository at this point in the history
More workarounds for golang issue
golang/go#52010
  • Loading branch information
cfergeau committed Dec 19, 2022
1 parent 80de5ed commit d6ee395
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/cli/login/error_translation.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func detectReason(err error) int {
return noServerFoundReason
case strings.Contains(err.Error(), "tls: oversized record received"):
return tlsOversizedRecordReason
// TODO: this is a temporary workaround until issue is resolved in upstream Go: https://github.com/golang/go/issues/52010
case strings.Contains(err.Error(), "certificate is not trusted"):
return certificateAuthorityUnknownReason
}
switch err.(type) {
case x509.UnknownAuthorityError:
Expand Down
5 changes: 5 additions & 0 deletions pkg/cli/login/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func promptForInsecureTLS(reader io.Reader, out io.Writer, reason error) bool {
insecureTLSRequestReason = fmt.Sprintf("The server is using a certificate that does not match its hostname: %s", reason.Error())
case x509.CertificateInvalidError:
insecureTLSRequestReason = fmt.Sprintf("The server is using an invalid certificate: %s", reason.Error())
default:
// TODO: this is a temporary workaround until issue is resolved in upstream Go: https://github.com/golang/go/issues/52010
if strings.Contains(reason.Error(), "certificate is not trusted") {
insecureTLSRequestReason = "The server uses a certificate signed by an unknown authority."
}
}
}
var input bool
Expand Down
6 changes: 6 additions & 0 deletions pkg/helpers/tokencmd/request_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,12 @@ func transportWithSystemRoots(issuer string, clientConfig *restclient.Config) (h
klog.V(4).Infof("falling back to kubeconfig CA due to possible x509 error: %v", err)
return restclient.TransportFor(clientConfig)
default:
// TODO: this is a temporary workaround until issue is resolved in upstream Go: https://github.com/golang/go/issues/52010
if strings.Contains(err.Error(), "certificate is not trusted") {
klog.V(4).Infof("falling back to kubeconfig CA due to possible x509 error: %v", err)
return restclient.TransportFor(clientConfig)
}

switch err {
case io.EOF, io.ErrUnexpectedEOF, io.ErrNoProgress:
// also fallback on various io errors
Expand Down

0 comments on commit d6ee395

Please sign in to comment.