Skip to content

Commit df14352

Browse files
author
Ray Su
committed
fix(Mongo::Socket::SSL#verify_ocsp_endpoint!): use leaf cert instead of last one
1 parent 9c709b9 commit df14352

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/mongo/socket/ssl.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ def verify_ocsp_endpoint!(socket)
368368
end
369369

370370
cert = socket.peer_cert
371-
ca_cert = socket.peer_cert_chain.last
371+
# In the case where the leaf certificate and CA are the same, the chain may only contain one certificate.
372+
# If the chain has multiple certificates, the one directly after the leaf should be the issuer.
373+
ca_cert = socket.peer_cert_chain.length > 1 ? socket.peer_cert_chain[1] : cert
372374

373375
verifier = OcspVerifier.new(@host_name, cert, ca_cert, context.cert_store,
374376
**Utils.shallow_symbolize_keys(options))

0 commit comments

Comments
 (0)