diff --git a/src/crypto/x509/verify.go b/src/crypto/x509/verify.go index 6988ad7871..0d3de30bec 100644 --- a/src/crypto/x509/verify.go +++ b/src/crypto/x509/verify.go @@ -102,7 +102,7 @@ func (h HostnameError) Error() string { // UnknownAuthorityError results when the certificate issuer is unknown type UnknownAuthorityError struct { - cert *Certificate + Cert *Certificate // hintErr contains an error that may be helpful in determining why an // authority wasn't found. hintErr error diff --git a/src/crypto/x509/verify_test.go b/src/crypto/x509/verify_test.go index 5a7481fea1..15c4091444 100644 --- a/src/crypto/x509/verify_test.go +++ b/src/crypto/x509/verify_test.go @@ -290,10 +290,15 @@ func expectUsageError(t *testing.T, i int, err error) (ok bool) { } func expectAuthorityUnknown(t *testing.T, i int, err error) (ok bool) { - if _, ok := err.(UnknownAuthorityError); !ok { + e, ok := err.(UnknownAuthorityError) + if !ok { t.Errorf("#%d: error was not UnknownAuthorityError: %s", i, err) return false } + if e.Cert == nil { + t.Errorf("#%d: error was UnknownAuthorityError, but missing Cert: %s", i, err) + return false + } return true } @@ -1284,7 +1289,7 @@ func TestUnknownAuthorityError(t *testing.T) { t.Errorf("#%d: Unable to parse certificate -> %s", i, err) } uae := &UnknownAuthorityError{ - cert: c, + Cert: c, hintErr: fmt.Errorf("empty"), hintCert: c, }