Skip to content

Commit bae0072

Browse files
authored
Dont add the error from validating via issuer signature if the subsequent verification from extraCas succeeds (#28597)
* Dont add the error from validating via issuer signature if the subsequent verification from extraCas succeeds * changelog
1 parent aeca0cd commit bae0072

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

changelog/28597.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
auth/cert: When using ocsp_ca_certificates, an error was produced though extra certs validation succeeded.
3+
```

sdk/helper/ocsp/client.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -495,15 +495,19 @@ func validateOCSPParsedResponse(ocspRes *ocsp.Response, subject, issuer *x509.Ce
495495
var matchedCA *x509.Certificate
496496

497497
// Assumption 1 failed, try 2
498-
if err := ocspRes.Certificate.CheckSignatureFrom(issuer); err != nil {
499-
// Assumption 2 failed, try 3
500-
overallErr = multierror.Append(overallErr, err)
501-
502-
m, err := verifySignature(ocspRes, extraCas)
503-
if err != nil {
504-
overallErr = multierror.Append(overallErr, err)
498+
if sigFromIssuerErr := ocspRes.Certificate.CheckSignatureFrom(issuer); sigFromIssuerErr != nil {
499+
if len(extraCas) > 0 {
500+
// Assumption 2 failed, try 3
501+
m, err := verifySignature(ocspRes, extraCas)
502+
if err != nil {
503+
overallErr = multierror.Append(overallErr, sigFromIssuerErr)
504+
overallErr = multierror.Append(overallErr, err)
505+
} else {
506+
overallErr = nil
507+
matchedCA = m
508+
}
505509
} else {
506-
matchedCA = m
510+
overallErr = multierror.Append(overallErr, sigFromIssuerErr)
507511
}
508512
} else {
509513
matchedCA = ocspRes.Certificate

0 commit comments

Comments
 (0)