mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
vclib: Modify x509.UnknownAuthorityError unwrap check
Modify unwrap error utility to make it work with go1.20 This version of Go introduces a new layer of wrapping via a new error type. The commit accounts for that while being compatible with go1.19 Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
This commit is contained in:
parent
e15cdb3513
commit
c31cc5ec46
@ -21,6 +21,7 @@ import (
|
|||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -187,12 +188,9 @@ func verifyWrappedX509UnkownAuthorityErr(t *testing.T, err error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Expected to receive an url.Error, got '%s' (%#v)", err.Error(), err)
|
t.Fatalf("Expected to receive an url.Error, got '%s' (%#v)", err.Error(), err)
|
||||||
}
|
}
|
||||||
x509Err, ok := urlErr.Err.(x509.UnknownAuthorityError)
|
var x509err x509.UnknownAuthorityError
|
||||||
if !ok {
|
if !errors.As(urlErr.Err, &x509err) {
|
||||||
t.Fatalf("Expected to receive a wrapped x509.UnknownAuthorityError, got: '%s' (%#v)", urlErr.Error(), urlErr)
|
t.Fatalf("Expected to receive a wrapped x509.UnknownAuthorityError, got: '%s' (%#v)", urlErr.Err.Error(), urlErr.Err)
|
||||||
}
|
|
||||||
if msg := x509Err.Error(); msg != "x509: certificate signed by unknown authority" {
|
|
||||||
t.Fatalf("Expected 'signed by unknown authority' error, got: '%s'", msg)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user