Skip to content

Commit

Permalink
crypto/x509: add Unwrap to SystemRootsError
Browse files Browse the repository at this point in the history
This change modifies Go to add the Unwrap method to SystemRootsError

Updates #30322

Change-Id: Ibe63d1d0bc832fc0607f09053908d55275a6f350
GitHub-Last-Rev: 9a95bc6
GitHub-Pull-Request: #41981
Reviewed-on: https://go-review.googlesource.com/c/go/+/262343
Reviewed-by: Damien Neil <[email protected]>
Reviewed-by: Filippo Valsorda <[email protected]>
Trust: Damien Neil <[email protected]>
Run-TryBot: Filippo Valsorda <[email protected]>
TryBot-Result: Go Bot <[email protected]>
  • Loading branch information
psampaz authored and FiloSottile committed Nov 6, 2020
1 parent 3a81338 commit f7ef5ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/crypto/x509/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions src/crypto/x509/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit f7ef5ca

Please sign in to comment.