Commit b8913577 authored by Russ Cox's avatar Russ Cox

crypto/x509: expose UnknownAuthorityError.Cert

This matches exposing CertificateInvalidError.Cert.
and (exposing but not the spelling of) HostnameError.Certificate.

Fixes #13519.

Change-Id: Ifae9a09e063d642c09de3cdee8a728ff06d3a5df
Reviewed-on: https://go-review.googlesource.com/32644
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent b2290229
......@@ -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
......
......@@ -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,
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment