1
0
mirror of https://github.com/golang/go synced 2024-10-03 11:21:22 -06:00

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: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Russ Cox 2016-11-03 09:39:32 -04:00
parent b2290229c2
commit b89135777b
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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,
}