Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/x509: add Unwrap to SystemRootsError #41981

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
}