Skip to content

RUBY-3694 Use correct CA when verifying OCSP endpoint (2.20.x) #2945

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

Open
wants to merge 15 commits into
base: 2.20-stable
Choose a base branch
from

Conversation

jamis
Copy link
Contributor

@jamis jamis commented Aug 7, 2025

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::SSL class, here: https://github.com/mongodb/mongo-ruby-driver/pull/2945/files/fb48bb2899b22d2aa6b54da217ef45dd32740ac6#diff-cbf3617065668fb1d60c964cdff16bc2da1586476485bcf609d42e0303f3b389

* 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
@jamis jamis added the bug label Aug 7, 2025
@Copilot Copilot AI review requested due to automatic review settings August 8, 2025 14:46
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant