Skip to content

Commit

Permalink
chore: returning custom errors when verifying peer certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
WendelHime committed Jul 22, 2024
1 parent df00536 commit c5f6958
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ func (d *direct) verifyPeerCertificate(domain string, rawCerts [][]byte, _ [][]*
}
cert, err := x509.ParseCertificate(rawCerts[0])
if err != nil {
return err
return fmt.Errorf("failed to parse certificate: %v", err)
}
opts := x509.VerifyOptions{
Roots: d.certPool,
Expand All @@ -452,13 +452,13 @@ func (d *direct) verifyPeerCertificate(domain string, rawCerts [][]byte, _ [][]*
for i := 1; i < len(rawCerts); i++ {
intermediate, err := x509.ParseCertificate(rawCerts[i])
if err != nil {
return err
return fmt.Errorf("failed to parse intermediate certificate: %v", err)
}
opts.Intermediates.AddCert(intermediate)
}
_, err = cert.Verify(opts)
if err != nil {
return err
return fmt.Errorf("failed to verify certificate: %v", err)
}

return nil
Expand Down

0 comments on commit c5f6958

Please sign in to comment.