RUBY-3694 Use correct CA when verifying OCSP endpoint (2.20.x) - #2945
Merged
Merged
Conversation
* use the next cert in the chain as the CA when verifying OCSP * don't assume the issuer is at a particular position in the chain * Fix incorrect method description
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR is a backport to version 2.20.x that fixes OCSP verification when dealing with certificate chains longer than two elements. The issue was that the driver was incorrectly using the last certificate in the chain as the CA for OCSP verification, which works only for two-element chains but fails for longer chains.
- Implements proper issuer certificate lookup for OCSP verification
- Refactors DNS testing infrastructure to support Ruby 3.0+ requirements
- Updates CI configuration to use Ubuntu instead of RHEL and mongosh instead of mongo
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/mongo/socket/ssl.rb | Adds find_issuer method and fixes CA certificate selection for OCSP verification |
| spec/integration/ocsp_verifier_spec.rb | Refactors OCSP test infrastructure and removes expired certificate tests |
| spec/support/common_shortcuts.rb | Updates DNS mocking implementation to use Async properly |
| spec/support/constraints.rb | Adds minimum_mri_version constraint helper |
| spec/integration/*_spec.rb | Updates SRV-related specs to require Ruby 3.0+ for DNS mocking |
| .evergreen/* | Updates CI configuration to use Ubuntu and mongosh |
comandeo-mongo
approved these changes
Aug 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport to 2.20.x
The driver was incorrectly using the last certificate in the chain as the CA when performing OCSP verification. This worked for the case where the chain had only two elements, but for longer chains, it was causing the verification to fail.
This change searches the cert chain for the issuer of the peer certificate, and uses that as the CA for the verification request.
Note: besides the fix described, the tests in the 2.20-stable branch were entirely broken---all of them failing---so the majority of the changes in this PR have turned out to be related to fixing or skipping tests. The meaningful change is in the
Mongo::Socket::SSLclass, here: https://github.com/mongodb/mongo-ruby-driver/pull/2945/files/fb48bb2899b22d2aa6b54da217ef45dd32740ac6#diff-cbf3617065668fb1d60c964cdff16bc2da1586476485bcf609d42e0303f3b389