Skip to content

Commit 80f0338

Browse files
joeshawagl
authored andcommitted
ocsp: remove error for > 1 certificate in response
Some OCSP responders contain more than one certificate, which can be used to "help the OCSP client verify the responders signature" (RFC 6960 section 4.2.1). This client doesn't do verification of the chain to the root, but it's not an error for a responder to send more than one. Fixes golang/go#21527 Change-Id: Ie23cfcb347a4f7cdfb1a0cbad2aa03a1242553af Reviewed-on: https://go-review.googlesource.com/57510 Reviewed-by: Adam Langley <[email protected]>
1 parent ae8bce0 commit 80f0338

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ocsp/ocsp.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,6 @@ func ParseResponseForCert(bytes []byte, cert, issuer *x509.Certificate) (*Respon
488488
return nil, err
489489
}
490490

491-
if len(basicResp.Certificates) > 1 {
492-
return nil, ParseError("OCSP response contains bad number of certificates")
493-
}
494-
495491
if n := len(basicResp.TBSResponseData.Responses); n == 0 || cert == nil && n > 1 {
496492
return nil, ParseError("OCSP response contains bad number of responses")
497493
}
@@ -544,6 +540,13 @@ func ParseResponseForCert(bytes []byte, cert, issuer *x509.Certificate) (*Respon
544540
}
545541

546542
if len(basicResp.Certificates) > 0 {
543+
// Responders should only send a single certificate (if they
544+
// send any) that connects the responder's certificate to the
545+
// original issuer. We accept responses with multiple
546+
// certificates due to a number responders sending them[1], but
547+
// ignore all but the first.
548+
//
549+
// [1] https://github.com/golang/go/issues/21527
547550
ret.Certificate, err = x509.ParseCertificate(basicResp.Certificates[0].FullBytes)
548551
if err != nil {
549552
return nil, err

0 commit comments

Comments
 (0)