1
0
mirror of https://github.com/golang/go synced 2024-11-12 08:10:21 -07:00

crypto/x509: add Unwrap to SystemRootsError

This change modifies Go to add the Unwrap method to SystemRootsError

Updates #30322

Change-Id: Ibe63d1d0bc832fc0607f09053908d55275a6f350
GitHub-Last-Rev: 9a95bc6601
GitHub-Pull-Request: golang/go#41981
Reviewed-on: https://go-review.googlesource.com/c/go/+/262343
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Pantelis Sampaziotis 2020-10-14 19:42:13 +00:00 committed by Filippo Valsorda
parent 3a81338622
commit f7ef5ca54a
2 changed files with 10 additions and 0 deletions

View File

@ -187,6 +187,8 @@ func (se SystemRootsError) Error() string {
return msg
}
func (se SystemRootsError) Unwrap() error { return se.Err }
// errNotParsed is returned when a certificate without ASN.1 contents is
// verified. Platform-specific verification needs the ASN.1 contents.
var errNotParsed = errors.New("x509: missing ASN.1 contents; use ParseCertificate")

View File

@ -2005,3 +2005,11 @@ func TestSystemRootsError(t *testing.T) {
t.Errorf("error was not SystemRootsError: %v", err)
}
}
func TestSystemRootsErrorUnwrap(t *testing.T) {
var err1 = errors.New("err1")
err := SystemRootsError{Err: err1}
if !errors.Is(err, err1) {
t.Error("errors.Is failed, wanted success")
}
}